TortoiseSVN is a Subversion client, implemented as a Microsoft Windows shell extension, that helps programmers manage different versions of the source code for their programs. It is free software released under the GNU General Public License. TortoiseSVN won the SourceForge.net 2007 Community Choice Award for Best Tool or Utility for Developers. Use the command line svn client or your favorite SVN client (TortoiseSVN, for example). Your local copy of the project is called a working copy in Subversion and you get it by issuing the command svn checkout where is a repository URL. Remember that TortoiseSVN is a GUI client, and this automation guide shows you how to make the TortoiseSVN dialogs appear to collect user input. If you want to write a script which requires no input, you should use the official Subversion command line client instead. Another option would be that you install the Subversion binaries.
Latest versionReleased:
Intuitive Subversion wrapper.
Project description
svn is a simple Subversion library for Python. I wrote it so that there couldbe a lightweight and accessible library that was also available on PyPI. It iscompatible with both Python 2.7 and 3.3+.
The library wraps the svn
commandline client, which should consequently beinstalled 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 acreate
method with which to create repositories.
You are more than welcome to submit pull-requests to add more support foradditional subcommands.
Usage is divided between two clients that either allow for access to a localworking-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 locationthat 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 theconstructor 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. Weare no longer supporting catching ValueError.
checkout(path)
Checkout a remote repository:
Common Functionality
These methods are available on both clients.
info(rel_path=None)
Get information about the directory.
NOTE: The keys named with dashes, slashes, and hashes are consideredobsolete, and only available for backwards compatibility. Wehave since moved to using only underscores to separate words.
cat(rel_filepath)
Get file-data as string.
log_default(timestamp_from_dt=None, timestamp_to_dt=None, limit=None, rel_filepath=', stop_on_copy=False, revision_from=None, revision_to=None, changelist=False)
Perform a log-listing that can be bounded by time or revision number and/ortake a maximum-count.
export(to_path, revision=None, force=False)
Checkout the tree without embedding an meta-information.
We can also use force
option to force the svn export.
list(extended=False, rel_path=None)
Return either a flat-list of filenames or a list of objects describing evenmore information about each.
list_recursive(rel_path=None, yield_dirs=False, path_filter_cb=None)
List all entries at and beneath the root or given relative-path.
diff_summary(start_revision, end_revision)
A lower-level diff summary that doesn't actually provide the contentdifferences.
diff(start_revision, end_revision)
Diffs between start and end revisions
There was a previous contribution to the diff implementation that has beenreported and confirmed to often throw an exception due to shoddy handling ofthe file-paths in the output. It also made secondary shell calls and mixed bothtext and XML output in the response. As a result of this, the decision has beenmade to just reimplement it and reshape the output in a backwards-incompatibleway at the same time. If you need to stick to the older implementation, tie yourdependencies to the 0.3.46 release.
Release historyRelease notifications | RSS feed
1.0.1
1.0.0
0.3.46
0.3.45
0.3.44
0.3.43
0.3.42
0.3.41
0.3.40
0.3.39
0.3.38
0.3.37
0.3.36
0.3.35
0.3.34
Tortoisesvn Client Download
0.3.33
0.3.32
0.3.31
0.3.30
0.3.29
0.3.28
0.3.27
0.3.26
0.3.25
0.3.24
0.3.23
0.3.22
0.3.21
0.3.20
0.3.19
0.3.18
0.3.17
0.3.16
0.3.15
0.3.14
0.3.13
Tortoisesvn Ssh Client
0.3.12
0.3.11
0.3.10
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.1.0dev pre-release
0.3.3-dirty
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size svn-1.0.1.tar.gz (12.8 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for svn-1.0.1.tar.gz
Algorithm | Hash digest |
---|---|
SHA256 | 55f81f07853cc1d66d4800b0cfe2d3376ff02361a2b2361459dc22a0fab95247 |
MD5 | b88e1d57f14f027a58ce08f26ebf7f55 |
BLAKE2-256 | 2ba5a23ed647d0cbdac48de23d822581e273f087364c57e2cd1c3efc979e91f5 |
Remarks
Apache Subversion (SVN) is a universal and centralized open source version control system. Subversion is currently a project under Apache Software Foundation (ASF) and is licensed under the Apache License, Version 2.0.
Subversion is designed to manage and control files and directories and track changes made to them; it acts as a reliable time machine and management tool for the collaboratively developed projects. It can easily answer the standard questions any version control system has to answer reliably. For example,
- How did the project/file FOO look like on 12/12/2012 ?
- What changes were introduced by USERNAME or on 20/12/2012 ?
- Who modified the particular string since the last review?
- and much-much more.
Versions
Version | What's new? | Release Date |
---|---|---|
1.9.x | Numerous usability and performance improvements | 2015-08-05 |
1.8.x | Improved rename tracking, automatic reintegration merges, inherited versioned properties, built-in conflict resolution tool | 2013-06-18 |
1.7.x | Complete rewrite of the working copy library, improved HTTP protocol usage | 2011-10-11 |
1.6.x | Identifying tree conflicts, improved interactive conflict resolution, repo-relative URLs support | 2009-03-20 |
1.5.x | Merge and branch tracking (svn:mergeinfo ), interactive file conflict resolution, sparse checkouts, improved svn:externals syntax | 2008-06-19 |
1.4.x | svnsync tool for repository replication, new and improved working copy library | 2006-09-10 |
1.3.x | High-level logging of user operations on the server side, performance improvements | 2005-12-30 |
1.2.x | Support for lock-modify-unlock model (i.e. locking), DAV autoversioning, FSFS is used by default for new repositories | 2005-05-21 |
1.1.x | New repository backend (FSFS), symlink versioning | 2004-09-29 |
1.0.x | Initial public release | 2004-02-23 |
Apache Subversion 1.9.x is currently the latest and best SVN release that is fully supported. Subversion 1.8.x is partially supported. Subversion 1.7.x and earlier versions are no longer supported.
Installation and initial setup
Install the svn
client to start collaborating on the project that is using Subversion as its version control system.
To install Subversion, you can build it yourself from a source code release or download a binary package pre-built for your operating system. The list of sites where you can obtain a compiled Subversion client (svn
) for various operating systems is available at the official binary packages page. If you feel like compiling the software for yourself, grab the source at the Source Code page.
With Subversion, you are not limited to using only the standard svn
command-line client. There are some notable graphical Subversion clients for various operating systems and most of the IDEs nowadays provide robust integration with SVN right out of the box or via plugins. For the list of graphical clients, check the Wikipedia page: https://en.wikipedia.org/wiki/Comparison_of_Subversion_clients.
Right after you install the client you should be able to run it by issuing the command svn
. You should see the following:
Everything is mostly ready. Now you should create a local workspace called a working copy which is going to be connected to the remote central repository. In other words, you are going to checkout a working copy. You are going to operate with the versioned data with the help of the working copy and can publish your changes (called committing in SVN) so that others working on the same project can see them and benefit from your changes. To later fetch the future changes made by others from the repository, you would update your working copy. These basic operations are covered in other examples.
Checking out a working copy
To begin making modifications to the project's data, you have to obtain a local copy of the versioned project. Use the command line svn
client or your favorite SVN client (TortoiseSVN, for example). Your local copy of the project is called a working copy in Subversion and you get it by issuing the command svn checkout <URL>
where <URL>
is a repository URL. e.g.
Alternatively, you can use svn co <URL>
as a shorthand in order to checkout a local copy.
As a result, you will get a working copy of the /trunk
of a project called MyProject that resides in MyRepo repository. The working copy will be located in a directory called trunk
on your computer relative to the directory you issued the command in.
If you wish to have a different name for your working copy you can add that as a parameter to the end of the command. e.g.
This will create a working copy called MyProjectSource
.
Note that instead of checking out the trunk, you could check out some branch, private shelve or a tag (assuming they already exist in the repository); you can have unlimited number of local working copies on your machine.
You could get the working copy of the whole repository MyRepo, too. But you should refrain from doing so. Generally speaking, you do not need to have a working copy of the whole repository for your work because your working copy can be instantly switched to another development branch / tag / whatever. Moreover, Subversion repository can contain a number of (un)related projects and it's better to have a dedicated working copy for each of them, not a single working copy for all of the projects.
Checking out a working copy at a specific revision
To get version 5394 use:
Or the shorter version:
Or by using pegged revisions:
If already checked out, you can use the update
command to move a to a particular revision, by doing:
Committing your local changes to the repository
To publish the changes you made in your working copy, run the svn commit
command.
IMPORTANT: Review your changes before committing them! Use svn status
and svn diff
to review the changes. Also, make sure you are in the correct path before performing a commit. If you updated many files across various directories, you should be at the appropriate level to include all of them beneath your location.
Here is an example of the commit command:
Alternatively, svn ci
is the shorthand for svn commit
Note the -m (--message)
option. Good commit messages help others understand why a commit was made. Also, on the server side it's possible to enforce non-empty messages, and even enforce that each commit message mentions an existing ticket in your bug tracking system.
Creating and applying patches
A patch is a file that show the differences between two revisions or between your local repository and the last revision your repository is pointing.
To share or save a patch of your local uncommitted changes either for peer review or to apply later, do:
To get a patch from the differences between two revisions:
To apply a patch, run:
In order to apply the patch successfully, you must run the command from the same path where the patch was created.
Exporting the versioned data (plain download)
If you want to get the versioned project's data, but you don't need any of the version control capabilities offered by Subversion, you could run svn export <URL>
command. Here is an example:
As a result, you will get the project's data export, but unlike with a working copy, you won't be able to run svn
commands on it. The export is just a plain download of the data.
If some time later you'd want to convert the downloaded data to a fully-functional working copy, run svn checkout <URL>
to the directory where you ran the export to.
Making changes in your local working copy
The working copy (WC) is your local and private workspace that you use to interact with the central Subversion repository. You use the working copy to modify the contents of your project and fetch changes committed by others.
The working copy contains your project's data and looks and acts like a regular directory on your local file system, but with one major difference -- the working copy tracks the status and changes of files and directories within. You can think of the working copy as of a regular directory with a version-control flavor added by a hidden .svn
metadata directory at its root.
Most of the time, you are going to perform modifications to the project's data by modifying the contents of the working copy. As soon as you are satisfied with the modifications and you've reviewed them thoroughly, you are ready to publish them to the central repository.
You can perform any actions with your project's data within the working copy, but operations that involve copying, moving, renaming and deleting must be performed using the corresponding svn
commands:
Modifying existing files. Modify the files as you usually do using your favorite text processor, graphics editor, audio editing software, IDE, etc. As soon as you save the changes to disk, Subversion will recognize them automatically.
Adding new files. Put new files to the working copy and Subversion will recognize them as unversioned. It will not automatically start tracking the new files unless you run
svn add
command:Moving files and directories. Move files and directories using
svn move
command:Renaming files and directories. Rename files and directories using
svn rename
command:NOTE:
svn rename
command is an alias ofsvn move
command.Copying files and directories. Copy files and directories using
svn copy
command:Deleting files and directories. Delete files and directories using
svn delete
command:Checking the status of files and directories in the working copy. Review your changes using
svn status
(orsvn st
for short) command:IMPORTANT: Always review your changes before committing them. This will help you to avoid committing unnecessary or irrelevant changes.
Reverting changes. Revert your changes using
svn revert
command:Reverting all changes: From the repository's root:
IMPORTANT: Reverted uncommitted changes will be lost forever. You won't be able to recover the reverted changes. Use
svn revert
with caution! If you want to keep the changes but need to revert, save them in a patch. See example of how to create and apply a patch.
Revert or rollback of a file
To restore a file to the latest updated svn version, i.e. undo the local changes, you can use revert
:
To restore a file to an older version (revision XXX) use update
:
Warning: in both cases you will lose any local changes in the file because it will be overwritten.
To only view the older version of a file use cat
:
And to view the differences with your local version of the file:
Reviewing the logs
Running svn log
will show you all the commit messages, you probably want to review only certain revisions.
View the
n
most recent revisions:svn log -n
View a specific revision:
svn log -c rXXX
View the paths affected:
svn log -v -c rXXX
Updating a working copy
You are not the only person working on the project, right? This means that your colleagues are also making modifications to the project's data. To stay up to date and to fetch the modifications committed by others, you should run svn update
command in your working copy. As a result, your working copy will sync with the repository and download the changes made by your colleagues.
Shorthand for svn update
is svn up
.
It is a rule to run svn update
before committing your changes.
Using a password-protected repository
A Subversion repository can be configured so that certain contents or commands are only accessible to certain users. In order to access this restricted content, you will need to specify a username and password.
Your username and password can be specified directly as part of the command:
Unfortunately, this causes your password to appear in plaintext on the console. To avoid this possible security problem, specify a username but not a password. Doing this will cause a password prompt to appear, allowing you to enter your password without exposing it:
Providing no authentication information at all causes Subversion to prompt you for both the username and password:
While the first method is less secure, it's frequently seen in automated scripts since it is difficult for many types of script to provide information to an interactive prompt.
Note: commands that only operate on your working copy (such as revert
or status
) will never require a password, only commands that require communicating with the repository server.