How do I create a tag from an old revision in Subversion when using Assembla?

T. Brian Jones picture T. Brian Jones · Jun 22, 2012 · Viewed 22.3k times · Source

I use Assembla to manage my Subversion repository. I have started some major revisions to my codebase and want to create a Tag of my most recent production revision ( which I forgot to do when I pushed that rev live to production a few weeks ago ).

I'm currently on revision 588, and want to create a Tag of revision 577. How do I go about doing this from the command line using Subversion within Assembla?

Assume my Assembla SVN URL is: https://subversion.assembla.com/svn/my_assembla_svn_directory/

Answer

David W. picture David W. · Jun 22, 2012

You can always use the -r parameter to refer to a specific revision. When doing so, you can also use the @rev revision pinning to make sure you're referring to the layout of the Subversion revision at a particular revision. The following will create a tag from trunk on revision 577 and call this tag REV-1.2:

$ svn cp -r 577 https://subversion.assembla.com/svn/my_assembla_svn_directory/trunk
    https://subversion.assembla.com/svn/my_assembla_svn_directory/tags/REV-1.2

If you don't have a trunk, branches, and tags directories, you'll need to move your work in order to create some:

$ # Move the current directory to the "trunk"
$ svn cp https://subversion.assembla.com/svn/my_assembla_svn_directory \
    https://subversion.assembla.com/svn/my_assembla_svn_directory/trunk

$ # Make a corresponding tags and branches directories too
$ svn mkdir https://subversion.assembla.com/svn/my_assembla_svn_directory/branches
$ svn mkdir https://subversion.assembla.com/svn/my_assembla_svn_directory/tags

$ # Now, we can delete the old location. Let your developers know this,
$ # so they're not surprised by this and will be able to do a "svn relocate"
$ svn delete https://subversion.assembla.com/svn/my_assembla_svn_directory/

$ # Whoops. I should have done the tagging when I had a chance. 
$ #Oh well, we'll use the `@rev` pinning:

$ svn -r557 cp https://subversion.assembla.com/svn/my_assembla_svn_directory@557 \
      https://subversion.assembla.com/svn/my_assembla_svn_directory/tags/REL-1.2

Subversion doesn't implement tagging and branching except as a copy. This isn't unusual. Perforce implements branching in the same way. In fact, once you get use to it, it works out really well:

  • It's easy to see the valid branches and tags (simply do a svn ls on the right directory
  • The complete history of tags and branches are easy to see. You can see who made the change, when, why, etc.
  • The complete history of the tag or branch is shown. If someone changes a tag or branch, you see who did it very clearly.
  • It discourages the helter-skelter type of branching you see in many other version control systems when developers pick and choose over various branches and the trunk what to branch or tag. That makes tracking the history very difficult to do. Subversion's scheme encourages you to think of branches and tags as affecting all files in a project.