svn is a simple Subversion library for Python. I wrote it so that there could
be a lightweight and accessible library that was also available on PyPI. It is
compatible with both Python 2.7 and 3.3+.
The library wraps the svn commandline client, which should consequently be
installed on the local system.
Functions currently implemented:
list
info
log
checkout
export
cat
diff
diff_summary
status
add
commit
update
cleanup
In addition, there is also an "admin" class (svn.admin.Admin) that provides a
create method with which to create repositories.
You are more than welcome to submit pull-requests to add more support for
additional subcommands.
Usage
Usage is divided between two clients that either allow for access to a local
working-directory or a remote repository.
Both clients inherit a common set of methods that work with both local working-
directories and remote repositories.
svn.utility.get_client is provided for convenience. If you provide a location
that starts with a backslash, it will return a LocalClient instance. Otherwise,
it will return a RemoteClient instance.
You may pass username and password as optional arguments to both the
constructor and utility function.
LocalClient
LocalClient allows access to a local working copy.
RemoteClient
RemoteClient allows access to a remote repository.
SvnException
SvnException is raised whenever there is an issue with the svn repository. We
are no longer supporting catching ValueError.
checkout(path)
Checkout a remote repository:
import svn.remote
r = svn.remote.RemoteClient('https://repo.local/svn')
r.checkout('/tmp/working')
NOTE: The keys named with dashes, slashes, and hashes are considered
obsolete, and only available for backwards compatibility. We
have since moved to using only underscores to separate words.
cat(rel_filepath)
Get file-data as string.
import svn.local
l = svn.local.LocalClient('/tmp/test_repo')
content = l.cat('test_file')
There was a previous contribution to the diff implementation that has been
reported and confirmed to often throw an exception due to shoddy handling of
the file-paths in the output. It also made secondary shell calls and mixed both
text and XML output in the response. As a result of this, the decision has been
made to just reimplement it and reshape the output in a backwards-incompatible
way at the same time. If you need to stick to the older implementation, tie your
dependencies to the 0.3.46 release.