libvcs.cmd.svn
¶
For subversion, aka svn(1)
Run svn (subversion) commands directly against SVN working copy.
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.
- exception libvcs.cmd.svn.SvnPropsetValueOrValuePathRequired(*args)[source]¶
Bases:
LibVCSException
,TypeError
Raised when required parameters are not passed.
- Parameters:
args (object)
- Return type:
None
- class libvcs.cmd.svn.Svn(*, path, progress_callback=None)[source]¶
Bases:
object
Run commands directly against SVN working copy.
Lite, typed, pythonic wrapper for svn(1).
- Parameters:
path (
Union
[str
,PathLike
[str
]]) â Operates as PATH in the corresponding svn subcommand.progress_callback (ProgressCallbackProtocol | None)
Examples
>>> Svn(path=tmp_path) <Svn path=...>
- __init__(*, path, progress_callback=None)[source]¶
Lite, typed, pythonic wrapper for svn(1).
- Parameters:
path (
Union
[str
,PathLike
[str
]]) â Operates as PATH in the corresponding svn subcommand.progress_callback (ProgressCallbackProtocol | None)
- Return type:
None
Examples
>>> Svn(path=tmp_path) <Svn path=...>
-
path:
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]¶
Run a command for this SVN working copy.
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:
non_interactive (
Optional
[bool
]) â ânon-interactive, defaults to Trueconfig_dir (
Optional
[Path
]) â âconfig-dirconfig_option (
Optional
[Path
]) â âconfig-option,FILE:SECTION:OPTION=[VALUE]
cwd (
libvcs._internal.types.StrOrBytesPath
, optional) â Defaults tocwd
make_parents (bool, default:
True
) â Creates checkout directory (:attr:`self.path) if it doesnât already exist.check_returncode (bool, default:
None
) â Passthrough toSvn.run()
args (str | bytes | PathLike[str] | PathLike[bytes] | Sequence[str | bytes | PathLike[str] | PathLike[bytes]])
kwargs (Any)
- Return type:
Examples
>>> svn = Svn(path=tmp_path) >>> svn.run(['help']) "usage: svn <subcommand> [options] [args]..."
- 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, Optionalmake_parents (bool, default:
True
) â Creates checkout directory (:attr:`self.path) if it doesnât already exist.check_returncode (bool, default: True) â Passthrough to
Svn.run()
quiet (bool | None)
username (str | None)
password (str | None)
no_auth_cache (bool | None)
non_interactive (bool | None)
trust_server_cert (bool | None)
- Return type:
Examples
>>> svn = Svn(path=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...'
- add(*, path, targets=None, depth=None, force=None, auto_props=None, no_auto_props=None, parents=None)[source]¶
Stage an unversioned file to be pushed to repository next commit.
Passing None means the flag wonât be passed unless otherwise stated.
Wraps svn add.
- Parameters:
targets (pathlib.Path) â âtargets ARG: contents of file ARG as additional args
depth (
Optional
[Literal
['infinity'
,'empty'
,'files'
,'immediates'
]]) â âdepth ARG, Sparse checkout support, Optionalforce (
Optional
[bool
]) â âforce, Ignore already versioned pathsno_ignore â âno-ignore
path (list[Path] | Path)
- Return type:
Examples
>>> svn = Svn(path=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'
- auth(remove=None, show_passwords=None, **kwargs)[source]¶
Manage stored authentication credentials.
Wraps svn auth.
- Parameters:
- Return type:
Examples
>>> Svn(path=tmp_path).auth() "Credentials cache in '...' is empty"
- blame(target, *, revision=None, verbose=None, force=None, use_merge_history=None, incremental=None, xml=None, extensions=None, **kwargs)[source]¶
Show authorship for file line-by-line.
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:
Examples
>>> svn = Svn(path=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'
- cat(*args, **kwargs)[source]¶
Output contents of files from working copy or repository URLs.
Wraps svn cat.
- changelist(*args, **kwargs)[source]¶
Connect or disconnect files with a changelist.
Wraps svn changelist (cl).
- cleanup(*args, **kwargs)[source]¶
Recursively clean up working copy of locks. Unblocks operations.
Wraps svn cleanup.
- 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]¶
Push changes from working copy to SVN repo.
Wraps svn commit (ci).
- Parameters:
targets (pathlib.Path) â âtargets ARG: contents of file ARG as additional args
depth (
Optional
[Literal
['infinity'
,'empty'
,'files'
,'immediates'
]]) â âdepth ARG, Sparse checkout support, Optionalencoding (
Optional
[str
]) â âencoding, treat value as charset encoding passedkeep_changelists (
Optional
[bool
]) â âkeep_changelists, donât delete changelists after commitforce_log (
Optional
[bool
]) â âforce-log, Ignore already versioned pathspath (list[Path] | Path)
message (str | None)
no_unlock (bool | None)
file (Path | None)
include_externals (bool | None)
kwargs (Any)
- Return type:
Examples
>>> svn = Svn(path=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.'
- copy(*args, **kwargs)[source]¶
Copy file or dir in this SVN working copy or repo.
Wraps svn copy (cp).
- delete(*args, **kwargs)[source]¶
Remove file from this SVN working copy or repo.
Wraps svn delete (del, remove, rm).
- export(*args, **kwargs)[source]¶
Export clean directory tree of working directory.
Wraps svn export.
- import_(*args, **kwargs)[source]¶
Import local directory into repository.
Wraps svn import.
Due to python limitation, .import isnât possible.
- info(target=None, targets=None, changelist=None, revision=None, depth=None, incremental=None, recursive=None, xml=None, *args, **kwargs)[source]¶
Return info about this SVN repository.
Wraps svn info.
- Return type:
- Parameters:
- targetspathlib.Path
âtargets ARG: contents of file ARG as additional args
- xmlbool
âxml, xml output
- revisionUnion[RevisionLiteral, str]
Number, â{ DATE }â, âHEADâ, âBASEâ, âCOMMITTEDâ, âPREVâ
- depth :
âdepth ARG, Sparse checkout support, Optional
- incrementalbool
âincremental, give output suitable for concatenation
- ls(*args, **kwargs)[source]¶
List files in SVN repository (without downloading them).
Wraps svn list (ls).
- lock(targets=None, force=None, **kwargs)[source]¶
Lock path or URLs for working copy or repository.
Wraps svn lock.
Examples
>>> svn = Svn(path=tmp_path) >>> svn.checkout(url=f'file://{create_svn_remote_repo()}') '...Checked out revision ...' >>> svn.lock(targets='samplepickle') "'samplepickle' locked by user '...'."
- merge(*args, **kwargs)[source]¶
Apply diffs between two places to SVN working copy.
Wraps svn merge.
- propdel(*args, **kwargs)[source]¶
Remove a property for this SVN working copy.
Wraps svn propdel (pdel, pd).
- propedit(*args, **kwargs)[source]¶
Change a property for this SVN working copy.
Wraps svn propedit (pedit, pe).
- propget(*args, **kwargs)[source]¶
Return a property for this SVN working copy.
Wraps svn propget (pget, pg).
- proplist(*args, **kwargs)[source]¶
Return list of properties for this SVN working copy.
Wraps svn proplist (plist, pl).
- propset(name, path=None, value=None, value_path=None, target=None, *args, **kwargs)[source]¶
Set property for this SVN working copy or a remote revision.
Note: Setting remote properties via ârevprop does not work yet.
Wraps svn propset (pset, ps).
- Parameters:
- Return type:
Examples
>>> svn = Svn(path=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 '.'"
- relocate(*, to_path, **kwargs)[source]¶
Set the SVN repository URL for this working copy.
Wraps svn relocate.
Examples
>>> svn = Svn(path=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()) ''
- resolve(path, targets=None, depth=None, force=None, *args, **kwargs)[source]¶
Resolve conflicts with this SVN working copy.
Wraps svn resolve.
- Return type:
- Parameters:
Examples
>>> svn = Svn(path=tmp_path) >>> svn.checkout(url=f'file://{create_svn_remote_repo()}') '...Checked out revision ...' >>> svn.resolve(path='.') ''
- resolved(*, path, targets=None, depth=None, force=None, **kwargs)[source]¶
Resolve this working copyâs conflicted state.
Wraps svn resolved.
- Return type:
- Parameters:
Examples
>>> svn = Svn(path=tmp_path) >>> svn.checkout(url=f'file://{create_svn_remote_repo()}') '...Checked out revision ...' >>> svn.resolved(path='.') ''
- revert(*, path, targets=None, depth=None, force=None, **kwargs)[source]¶
Revert any changes to this SVN working copy.
Wraps svn revert.
- Return type:
- Parameters:
Examples
>>> svn = Svn(path=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) ''
- status(*args, **kwargs)[source]¶
Return status of this SVN working copy.
Wraps svn status (stat, st).
Examples
>>> svn = Svn(path=tmp_path) >>> svn.checkout(url=f'file://{create_svn_remote_repo()}') '...Checked out revision ...' >>> svn.status() ''
- switch(*, to_path, path, ignore_ancestry=None, **kwargs)[source]¶
Switch working copy to a different SVN repo URL.
Wraps svn switch (sw).
- Return type:
- Parameters:
Examples
>>> svn = Svn(path=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...'
- unlock(targets=None, force=None, **kwargs)[source]¶
Unlock path or URL reserved by another user.
Wraps svn unlock.
Examples
>>> svn = Svn(path=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."
- 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]¶
Fetch latest changes to working copy.
Wraps svn update (up).
- Return type:
- Parameters:
Examples
>>> svn = Svn(path=tmp_path) >>> svn.checkout(url=f'file://{create_svn_remote_repo()}') '...Checked out revision ...' >>> svn.update() "Updating ..."