Peg revisions in SVN

One feature missing from early (and even relatively recent; less than v1.5) versions of Subversion is the ability to specify universally the exact revision of a file/directory within a repository across all commands/features (such as “svn switch” and externals). The difference between:

  • “file X/Y/Z which existed at revision 99”, and
  • “the file which exists if you backtrack from HEAD to revision 99 on path X/Y/Z”

is subtle but continues to catch many people out, especially those of us who use older (< 1.5) versions of SVN for one reason or another, typically because RHEL/CentOS 5 include SVN 1.4. I won’t attempt to rewrite the excellent chapter about peg and operative revisions in the online Version Control with Subversion book, but it’s worth remarking on nonetheless. It’s caused myself and my colleagues no end of headaches when trying to do predictable deployments using a specified SVN URL. Essentially, it means these two things are not necessarily equivalent:

svn sw svn+ssh://user@myrepo/X/Y/Z@99 myworkingcopy


svn sw -r 99 svn+ssh://user@myrepo/X/Y/Z myworkingcopy

If, between revision 99 and HEAD, you’ve renamed some directories within the path X/Y/Z, then backtracking the history of the current X/Y/Z (as of HEAD; this is the operative revision) doesn’t necessarily lead you back to X/Y/Z as it was at revision 99 (the peg revision). This is quite common when rearranging SVN repositories.

One Response to “Peg revisions in SVN”

  1. Andrei MR says:

    Hi. You called the chapter about peg and operative revisions in the Subversion book “excellent.” It most definitely is not — how dare you say so? It is *your* article that is excellent. You explained it in far fewer words, and I finally understand it.

    So thanks.

Leave a Reply