Thursday, May 17, 2007

Adding --parents

(Note: This is the first in hopefully a long series of more technical articles about the Subversion version control system. If you are one of our less technically inclined readers, feel free to skip it.)

The Subversion command line client is a jack-of-all-trades. For most people, it is their primary method of interacting with a Subversion working copy, and it has to be versatile enough to perform any action a user wants. The svn program itself has several subcommands which are used to invoke different client actions, such as svn add, svn copy, or svn commit. Each of these subcommands can also have a whole plethora of switches and options which affects the way it behaves.

As much as it does, the Subversion command line client often pales when compared to analogous Unix commands. This is understandable, given the extra versioning work that Subversion has to do, but most of our users would like svn cp to behave as close to cp as possible. (Due to Subversion's notion of atomicity, this turns out to be a non-trivial task. Making svn cp *.c dir work as expected is how I first got involved with Subversion development.)

The --parents switch is another feature that recently made its way into Subversion trunk. For Unix cp and mv, --parents will instruct the program to create any non-existent parent directories of the destination. svn cp and svn mv now behave the same way, for both working copy and repository destinations. This is useful if you want to create several nested server-side directories in the same revision, for instance. We've also added --parents sweetness to svn add, which instructs Subversion to recurse up the directory tree looking for a working copy and then version all the intermediate directories between it and the target of the add.

When used in conjunction with the sparse directories work, these features will hopefully allow you to version the exact bits of a complex directory hierarchy, without getting in your way.

No comments: