Tag Archive for 'mixed revisions'

Working with Mixed Revisions in Subversion

Apache Subversion is a flexible solution for version control that imposes few strict rules on the user. As part of this flexibility, working copies are not required to correspond to a single revision. These ‘mixed revision’ working copies are useful, as they allow users to work with files and directories with the range of revision numbers that best suits their particular project.

The fundamental concept behind mixed revisions in Subversion, is that a ‘svn commit’ does not automatically trigger ‘svn update.’ Subversion understands that just because you’re sending your changes to the repository, doesn’t necessarily mean you want other people’s changes in your working copy (or vice versa!) The ‘svn update’ command is crucial in keeping the ‘push’ and ‘pull’ operations independent in Subversion, allowing you to merge others’ changes from the repository into your working copy, without forcing you to publish any changes you’re working on.

It’s very common for the Subversion working copy to contain mixed revisions – often, users aren’t even aware of them! Whenever you run ‘svn commit’ on a particular file or folder, the working copy ends up with a mix of revisions, because the item you’ve just committed is at the HEAD revision, while the other items are at the previous revision. The working copy will continue to contain mixed revisions, until you run ‘svn update’ and bring the entire working copy to the same revision.

To find out whether your working copy contains mixed revisions, run:

svn status –verbose

This command will display the status of every item in your working copy – useful for discovering exactly what revisions make up your working copy!

Tagging Mixed Revisions

Although it’s possible to copy the file revisions in a working copy to create a tag, it is good practice to use repository URLs – this is especially true when your working copy contains mixed revisions. Creating a tag containing mixed revisions is slightly more complicated than creating a tag containing items at a single revision, as you need to make a snapshot of the exact working copy arrangement. ‘svn copy’ can be used here:

svn copy (working copy) (URL)

This creates a new directory that is an exact snapshot of the working copy, including all the mixed revisions.

Things to Watch out For

While mixed revisions give you more freedom in how you use Subversion, there are some issues to bear in mind when working with mixed revisions:

  • If a newer version of an item exists in the repository, you cannot commit the deletion of that item, without first updating your working copy. This is a measure to prevent users from destroying changes, before they have assessed them. Run ‘svn update’ to receive and inspect the latest changes, before making the decision to delete.
  • You cannot merge a mixed revision working copy. Run ‘svn update’ to bring all the files to the same revision, before running ‘svn merge.’
  • You cannot commit a metadata change to a directory, unless it’s fully up to date. Again, make sure you run ‘svn update’ prior to attempting your commit.
  • It is important to bear in mind that many client commands are sensitive to the working revision of the item they’re examining – e.g ‘svn log’ – and mixed revisions can complicate the use of these commands.