libvcs.cmd.svn#

For subversion, aka svn(1)

Busman’s holiday?

We need to fill these SVN commands and their tests to exquisite perfection, like the artisans in those Michelin-star videos on YouTube. We welcome your contributions, providing you “color between the lines” and stick to the interface. Get in, ‘APIs unstable until we fit the spec.

class libvcs.cmd.svn.Svn(*, dir, progress_callback=None)[source]#

Bases: object

Lite, typed, pythonic wrapper for svn(1).

Parameters:

Examples

>>> Svn(dir=tmp_path)
<Svn dir=...>
__init__(*, dir, progress_callback=None)[source]#

Lite, typed, pythonic wrapper for svn(1).

Parameters:
Return type:

None

Examples

>>> Svn(dir=tmp_path)
<Svn dir=...>
dir: Path#

Directory to check out

progress_callback: Optional[ProgressCallbackProtocol] = None#
run(args, *, quiet=None, username=None, password=None, no_auth_cache=None, non_interactive=True, trust_server_cert=None, config_dir=None, config_option=None, make_parents=True, check_returncode=None, **kwargs)[source]#

Passing None to a subcommand option, the flag won’t be passed unless otherwise stated.

svn help and svn help [cmd]

Wraps svn’s Options.

Parameters:
Return type:

str

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.run(['help'])
"usage: svn <subcommand> [options] [args]..."
Return type:

str

Parameters:
checkout(*, url, revision=None, force=None, ignore_externals=None, depth=None, quiet=None, username=None, password=None, no_auth_cache=None, non_interactive=True, trust_server_cert=None, make_parents=True, check_returncode=False)[source]#

Check out a working copy from an SVN repo.

Wraps svn checkout (co).

Parameters:
  • url (str) –

  • revision (Union[RevisionLiteral, str]) – Number, ‘{ DATE }’, ‘HEAD’, ‘BASE’, ‘COMMITTED’, ‘PREV’

  • force (bool, optional) – force operation to run

  • ignore_externals (bool, optional) – ignore externals definitions

  • depth (Optional[Literal[‘infinity’, ‘empty’, ‘files’, ‘immediates’]]) – Sparse checkout support, Optional

  • make_parents (bool, default: True) – Creates checkout directory (:attr:`self.dir) if it doesn’t already exist.

  • check_returncode (bool, default: True) – Passthrough to Svn.run()

  • quiet (Optional[bool]) –

  • username (Optional[str]) –

  • password (Optional[str]) –

  • no_auth_cache (Optional[bool]) –

  • non_interactive (Optional[bool]) –

  • trust_server_cert (Optional[bool]) –

Return type:

str

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn_remote_repo = create_svn_remote_repo()
>>> svn.checkout(url=f'file://{svn_remote_repo}')
'...Checked out revision ...'
>>> svn.checkout(url=f'file://{svn_remote_repo}', revision=10)
'svn: E160006: No such revision 10...'
Return type:

str

Parameters:
add(*, path, targets=None, depth=None, force=None, auto_props=None, no_auto_props=None, parents=None)[source]#

Passing None means the flag won’t be passed unless otherwise stated.

Wraps svn add.

Parameters:
Return type:

str

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...'
>>> new_file = tmp_path / 'new.txt'
>>> new_file.write_text('example text', encoding="utf-8")
12
>>> svn.add(path=new_file)
'A  new.txt'
Return type:

str

Parameters:
auth(remove=None, show_passwords=None, **kwargs)[source]#

Wraps svn auth.

Parameters:
  • remove (str, optional) – Remove matching auth credentials

  • show_passwords (bool, optional) – Show cached passwords

  • kwargs (Any) –

Return type:

str

Examples

>>> Svn(dir=tmp_path).auth()
"Credentials cache in '...' is empty"
Return type:

str

Parameters:
blame(target, *, revision=None, verbose=None, force=None, use_merge_history=None, incremental=None, xml=None, extensions=None, **kwargs)[source]#

Wraps svn blame.

Parameters:
  • target (pathlib.Path) – path of file

  • revision (Union[RevisionLiteral, str]) – Number, ‘{ DATE }’, ‘HEAD’, ‘BASE’, ‘COMMITTED’, ‘PREV’

  • verbose (bool) – -v, –verbose, output extra info

  • use_merge_history (bool) – -g, –use-merge-history, show extra mergeg info

  • incremental (bool) – –incremental, give output suitable for concatenation

  • xml (bool) – –xml, xml output

  • extensions (str, optional) – Diff or blame tool (pass raw args).

  • force (bool, optional) – force operation to run

  • kwargs (Any) –

Return type:

str

Examples

>>> svn = Svn(dir=tmp_path)
>>> repo = create_svn_remote_repo()
>>> svn.checkout(url=f'file://{repo}')
'...Checked out revision ...'
>>> new_file = tmp_path / 'new.txt'
>>> new_file.write_text('example text', encoding="utf-8")
12
>>> svn.add(path=new_file)
'A  new.txt'
>>> svn.commit(path=new_file, message='My new commit')
'...'
>>> svn.blame('new.txt')
'4        ... example text'
Return type:

str

Parameters:
cat(*args, **kwargs)[source]#

Wraps svn cat.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

changelist(*args, **kwargs)[source]#

Wraps svn changelist (cl).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

cleanup(*args, **kwargs)[source]#

Wraps svn cleanup.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

commit(*, path, targets=None, message=None, no_unlock=None, file=None, depth=None, encoding=None, force_log=None, keep_changelists=None, include_externals=None, **kwargs)[source]#

Wraps svn commit (ci).

Parameters:
Return type:

str

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...'
>>> new_file = tmp_path / 'new.txt'
>>> new_file.write_text('example text', encoding="utf-8")
12
>>> svn.add(path=new_file)
'A  new.txt'
>>> svn.commit(path=new_file, message='My new commit')
'Adding          new.txt...Transmitting file data...Committed revision 4.'
Return type:

str

Parameters:
copy(*args, **kwargs)[source]#

Wraps svn copy (cp).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

delete(*args, **kwargs)[source]#

Wraps svn delete (del, remove, rm).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

diff(*args, **kwargs)[source]#

Wraps svn diff.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

export(*args, **kwargs)[source]#

Wraps svn export.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

help(*args, **kwargs)[source]#

Wraps svn help (?, h).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

import_(*args, **kwargs)[source]#

Wraps svn import.

Due to python limitation, .import isn’t possible.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

info(target=None, targets=None, changelist=None, revision=None, depth=None, incremental=None, recursive=None, xml=None, *args, **kwargs)[source]#

Wraps svn info.

Parameters:
  • targets (pathlib.Path) – –targets ARG: contents of file ARG as additional args

  • xml (bool) – –xml, xml output

  • revision (Union[RevisionLiteral, str]) – Number, ‘{ DATE }’, ‘HEAD’, ‘BASE’, ‘COMMITTED’, ‘PREV’

  • depth (Optional[Literal[‘infinity’, ‘empty’, ‘files’, ‘immediates’]]) – –depth ARG, Sparse checkout support, Optional

  • incremental (bool) – –incremental, give output suitable for concatenation

  • target (Optional[Union[str, PathLike[str]]]) –

  • changelist (Optional[List[str]]) –

  • recursive (Optional[bool]) –

  • args (Any) –

  • kwargs (Any) –

Return type:

str

_list(*args, **kwargs)[source]#

Wraps svn list (ls).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

lock(targets=None, force=None, **kwargs)[source]#

Wraps svn lock.

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...Checked out revision ...'
>>> svn.lock(targets='samplepickle')
"'samplepickle' locked by user '...'."
Return type:

str

Parameters:
log(*args, **kwargs)[source]#

Wraps svn log.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

merge(*args, **kwargs)[source]#

Wraps svn merge.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

mergelist(*args, **kwargs)[source]#

Wraps svn mergelist.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

mkdir(*args, **kwargs)[source]#

Wraps svn mkdir.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

move(*args, **kwargs)[source]#

Wraps svn move (mv, rename, ren).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

patch(*args, **kwargs)[source]#

Wraps svn patch.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

propdel(*args, **kwargs)[source]#

Wraps svn propdel (pdel, pd).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

propedit(*args, **kwargs)[source]#

Wraps svn propedit (pedit, pe).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

propget(*args, **kwargs)[source]#

Wraps svn propget (pget, pg).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

proplist(*args, **kwargs)[source]#

Wraps svn proplist (plist, pl).

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

propset(name, path=None, value=None, value_path=None, target=None, *args, **kwargs)[source]#

Wraps svn propset (pset, ps).

Parameters:
Return type:

str

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...Checked out revision ...'
>>> svn.propset(name="my_prop", value="value", path=".")
"property 'my_prop' set on '.'"
Return type:

str

Parameters:
relocate(*, to_path, **kwargs)[source]#

Wraps svn relocate.

Examples

>>> svn = Svn(dir=tmp_path / 'initial_place')
>>> repo_path = create_svn_remote_repo()
>>> svn.checkout(url=repo_path.as_uri())
'...Checked out revision ...'
>>> new_place = repo_path.rename(tmp_path / 'new_place')
>>> svn.relocate(to_path=new_place.absolute().as_uri())
''
Return type:

str

Parameters:
resolve(path, targets=None, depth=None, force=None, *args, **kwargs)[source]#

Wraps svn resolve.

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...Checked out revision ...'
>>> svn.resolve(path='.')
''
Return type:

str

Parameters:
resolved(*, path, targets=None, depth=None, force=None, **kwargs)[source]#

Wraps svn resolved.

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...Checked out revision ...'
>>> svn.resolved(path='.')
''
Return type:

str

Parameters:
revert(*, path, targets=None, depth=None, force=None, **kwargs)[source]#

Wraps svn revert.

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...Checked out revision ...'
>>> new_file = tmp_path / 'new.txt'
>>> new_file.write_text('example text', encoding="utf-8")
12
>>> svn.add(path=new_file)
'A  new.txt'
>>> svn.commit(path=new_file, message='My new commit')
'...'
>>> svn.revert(path=new_file)
''
Return type:

str

Parameters:
status(*args, **kwargs)[source]#

Wraps svn status (stat, st).

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...Checked out revision ...'
>>> svn.status()
''
Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –

switch(*, to_path, path, ignore_ancestry=None, **kwargs)[source]#

Wraps svn switch (sw).

Examples

>>> svn = Svn(dir=tmp_path / 'initial_place')
>>> repo_path = create_svn_remote_repo()
>>> svn.checkout(url=(repo_path / 'sampledir').as_uri())
'...Checked out revision ...'
>>> other_dir = repo_path / 'otherdir'
>>> svn.switch(to_path=other_dir.as_uri(), path='.', ignore_ancestry=True)
'D...Updated to revision...'
Return type:

str

Parameters:
unlock(targets=None, force=None, **kwargs)[source]#

Wraps svn unlock.

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...Checked out revision ...'
>>> svn.lock(targets='samplepickle')
"'samplepickle' locked by user '...'."
>>> svn.unlock(targets='samplepickle')
"'samplepickle' unlocked."
Return type:

str

Parameters:
update(accept=None, changelist=None, diff3_cmd=None, editor_cmd=None, force=None, ignore_externals=None, parents=None, quiet=None, revision=None, set_depth=None, *args, **kwargs)[source]#

Wraps svn update (up).

Examples

>>> svn = Svn(dir=tmp_path)
>>> svn.checkout(url=f'file://{create_svn_remote_repo()}')
'...Checked out revision ...'
>>> svn.update()
"Updating ..."
Return type:

str

Parameters:
upgrade(*args, **kwargs)[source]#

Wraps svn upgrade.

Return type:

str

Parameters:
  • args (Any) –

  • kwargs (Any) –