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.
Bases:
LibVCSException,TypeErrorRaised when required parameters are not passed.
Bases:
objectRun commands directly against SVN working copy.
Lite, typed, pythonic wrapper for svn(1).
- Parameters:
path (
StrPath) – Operates as PATH in the corresponding svn subcommand.progress_callback (
ProgressCallbackProtocol|None)
- Return type:
Examples
>>> Svn(path=tmp_path) <Svn path=...>
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 (
bool|None) – –non-interactive, defaults to Trueconfig_option (
Path|None) – –config-option,FILE:SECTION:OPTION=[VALUE]cwd (
libvcs._internal.types.StrOrBytesPath, optional) – Defaults tocwdmake_parents (
bool, default: True) – Creates checkout directory (:attr:`self.path) if it doesn’t already exist.check_returncode (
bool, default: None) – Passthrough toSvn.run()timeout (
float,optional) – Wall-clock seconds to wait before terminating the subprocess.None(default) preserves the legacy behaviour of blocking until the process exits. When the deadline is exceeded the process is sentSIGTERM(thenSIGKILLafter a grace period) andlibvcs.exc.CommandTimeoutErroris raised with any output collected so far.args (
_CMD)kwargs (
Any)
- Return type:
Examples
>>> svn = Svn(path=tmp_path) >>> svn.run(['help']) "usage: svn <subcommand> [options] [args]..."
Check out a working copy from an SVN repo.
Wraps svn checkout (co).
- Parameters:
url (
str)revision (
RevisionLiteral|str) – Number, ‘{ DATE }’, ‘HEAD’, ‘BASE’, ‘COMMITTED’, ‘PREV’force (
bool,optional) – force operation to runignore_externals (
bool,optional) – ignore externals definitionsdepth (
DepthLiteral) – 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 toSvn.run()
- 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...'
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 argsdepth (
DepthLiteral) – –depth ARG, Sparse checkout support, Optionalforce (
bool|None) – –force, Ignore already versioned pathsno_ignore – –no-ignore
- 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'
Show authorship for file line-by-line.
Wraps svn blame.
- Parameters:
target (
pathlib.Path) – path of filerevision (
RevisionLiteral|str) – Number, ‘{ DATE }’, ‘HEAD’, ‘BASE’, ‘COMMITTED’, ‘PREV’verbose (
bool) – -v, –verbose, output extra infouse_merge_history (
bool) – -g, –use-merge-history, show extra mergeg infoincremental (
bool) – –incremental, give output suitable for concatenationxml (
bool) – –xml, xml outputextensions (
str,optional) – Diff or blame tool (pass raw args).force (
bool,optional) – force operation to runkwargs (
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'
Output contents of files from working copy or repository URLs.
Wraps svn cat.
Connect or disconnect files with a changelist.
Wraps svn changelist (cl).
Recursively clean up working copy of locks. Unblocks operations.
Wraps svn cleanup.
Push changes from working copy to SVN repo.
Wraps svn commit (ci).
- Parameters:
targets (
pathlib.Path) – –targets ARG: contents of file ARG as additional argsdepth (
DepthLiteral) – –depth ARG, Sparse checkout support, Optionalencoding (
str|None) – –encoding, treat value as charset encoding passedkeep_changelists (
bool|None) – –keep_changelists, don’t delete changelists after commitforce_log (
bool|None) – –force-log, Ignore already versioned pathskwargs (
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 file or dir in this SVN working copy or repo.
Wraps svn copy (cp).
Remove file from this SVN working copy or repo.
Wraps svn delete (del, remove, rm).
Return diff of two files or revisions.
Wraps svn diff.
Export clean directory tree of working directory.
Wraps svn export.
SVN Help command.
Wraps svn help (?, h).
Import local directory into repository.
Wraps svn import.
Due to python limitation, .import isn’t possible.
Return info about this SVN repository.
Wraps svn info.
- 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
List files in SVN repository (without downloading them).
Wraps svn list (ls).
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 '...'."
Show logs from repository.
Wraps svn log.
Apply diffs between two places to SVN working copy.
Wraps svn merge.
Create directory in SVN working copy.
Wraps svn mkdir.
Move a file in SVN working copy.
Wraps svn move (mv, rename, ren).
Apply a patch to SVN working copy.
Wraps svn patch.
Remove a property for this SVN working copy.
Wraps svn propdel (pdel, pd).
Change a property for this SVN working copy.
Wraps svn propedit (pedit, pe).
Return a property for this SVN working copy.
Wraps svn propget (pget, pg).
Return list of properties for this SVN working copy.
Wraps svn proplist (plist, pl).
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).
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 '.'"
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 conflicts with this SVN working copy.
Wraps svn resolve.
Examples
>>> svn = Svn(path=tmp_path) >>> svn.checkout(url=f'file://{create_svn_remote_repo()}') '...Checked out revision ...' >>> svn.resolve(path='.') ''
Resolve this working copy’s conflicted state.
Wraps svn resolved.
Examples
>>> svn = Svn(path=tmp_path) >>> svn.checkout(url=f'file://{create_svn_remote_repo()}') '...Checked out revision ...' >>> svn.resolved(path='.') ''
Revert any changes to this SVN working copy.
Wraps svn revert.
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) ''
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 working copy to a different SVN repo URL.
Wraps svn switch (sw).
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 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."
Fetch latest changes to working copy.
Wraps svn update (up).
Examples
>>> svn = Svn(path=tmp_path) >>> svn.checkout(url=f'file://{create_svn_remote_repo()}') '...Checked out revision ...' >>> svn.update() "Updating ..."