The Python development team recently switched from using CVS hosted at SourceForge to Subversion hosted at svn.python.org. There are many similarities between the two, but there are some differences as well. This page provides general tips. More details about using Subversion as it relates specifically to Python development are available in the Python developer's FAQ.

(Most of the initial content came from a python-dev post by Tim Peters.)

Update vs. Status

CVS uses update for all sorts of things. SVN has different commands for several of the use cases CVS's update conflates:

Checkins

Revision numbers apply to the entire repository, not just to single files. Every checkin conceptually creates a new version of the entire repository, uniquely identified by its revision number. This is very powerful, but subtle, and CVS has nothing like it. A glimpse of its power was given just above, talking about the ease of reverting an entire checkin in one easy gulp.

Branching

You're working on a trunk sandbox and discover it's going to take longer than you hoped. Now you wish you had created a branch. This is actually dead easy: create a new branch of the trunk. svn switch your sandbox to that new branch; this leaves your local change alone, which is key. svn commit -- you're done! There's now a branch on the server matching your fiddled local state.

svn cp -m "Create new branch from rev xxx." svn+ssh://pythondev@svn.python.org/python/trunk \
    svn+ssh://pythondev@svn.python.org/python/branches/my-branch
svn switch svn+ssh://pythondev@svn.python.org/python/branches/my-branch
svn ci -m "Commit first modifications on my branch."

Making a branch or tag goes very fast under SVN. Because branches and tags are just conventionally-named directories, you can delete them (like any other directory) when you're done with them. These conspire to make simple applications of branches much more pleasant than under CVS.

File Modes

CVS uses text mode for files by default. SVN uses binary mode. The latter is safer, but creates endless low-level snags for x-platform development. I encourage Python developers to include this gibberish in their SVN config file:

[auto-props]
# Setting eol-style to native on all files is a trick:  if svn
# believes a new file is binary, it won't honor the eol-style
# auto-prop.  However, svn considers the request to set eol-style
# to be an error then, and if adding multiple files with one
# svn "add" cmd, svn will stop adding files after the first
# such error.  A future release of svn will probably consider
# this to be a warning instead (and continue adding files).
* = svn:eol-style=native
*.c = svn:keywords=Id
*.h = svn:keywords=Id
*.py = svn:keywords=Id

Then SVN will set the necessary svn:eol-style property to "native" on new text files you commit. I've never yet seen it tag a file inappropriately using this trick, but it's guaranteed to screw up _all_ text files without something like this (unless you have the patience and discipline to manually set eol-style=native on all new text files you add).

For the above to work you will also have to make sure the enable-auto-props configuration key is set to "yes".

CvsToSvn (last edited 2008-11-15 14:00:11 by localhost)

Unable to edit the page? See the FrontPage for instructions.