vcs.svn

High-Level interface to SVN repository.

Example:

svn = SVNRepository(working_copy='/tmp/working_dir')
svn.update(url='file:///path_to_local_repo', revision=1,
           force_and_clean=True)

Module Contents

Classes

SVNRepository

Interface to a SVN Repository.

Attributes

SVNCmd

logger

vcs.svn.SVNCmd
vcs.svn.logger
exception vcs.svn.SVNError(message: str, origin: str, process: e3.os.process.Run | None = None)

Bases: e3.vcs.VCSError

Exception raised by functions defined in E3.

class vcs.svn.SVNRepository(working_copy: str)

Interface to a SVN Repository.

Variables:
  • svn_bin – path to the SVN binary

  • log_stream – stream where the log commands will be redirected (default is stdout)

  • working_copy – path to the SVN working copy

property url: str | None

Return the last URL used for the checkout.

Raise:

SVNError

property current_revision: str | None

Return the current revision.

Raise:

SVNError

svn_bin
log_stream: TextIO | IO[str]
classmethod is_unix_svn() bool

Check if svn is handling unix paths or windows paths.

Returns:

True if unix paths should be used

classmethod local_url(repo_path: str) str

Return the url of a svn repository hosted locally.

Parameters:

repo_path – path to the repo

Returns:

the url that can be used as repository url

classmethod create(repo_path: str, initial_content_path: str | None = None) str

Create a local subversion repository.

This creates a local repository (not a working copy) that can be referenced by using file:// protocol. The purpose of the this function is mainly to test svn-related functions without relying on a remote repository.

Parameters:
  • repo_path – a local directory where to create the repository

  • initial_content_path – directory containing the initial content of the repository. If set to None an empty repository is created.

Returns:

the URL of the newly created repository

svn_cmd(cmd: SVNCmd, **kwargs: Any) e3.os.process.Run

Run a svn command.

Add the non-interactive option to all command (accepted on all SVN. subcommands from version 1.5).

Parameters:
  • cmd – the command line as a list of string, all None entries will be discarded

  • kwargs – additional parameters to provide to e3.os.process.Run

Returns:

Result of the Run of the SVN command

Raise:

SVNError

get_info(item: str) str | None

Return a specific item shown by svn info.

The –show-item option is only available from 1.9. :raise: SVNError

update(url: str | None = None, revision: str | None = None, force_and_clean: bool = False) bool

Update a working copy or checkout a new one.

If the directory is already a checkout, it tries to update it. If the directory is not associated to a (good) checkout or is empty it will checkout. The option –remove-unversioned of the svn subcommand cleanup exists only from svn version 1.9. :param url: URL of a SVN repository :param revision: specific revision (default is last) :param force_and_clean: if True: erase the content of non empty working_copy and use ‘–force’ option for the svn update/checkout command :return: True if any local changes detected in the working copy :raise: SVNError