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

22,933

Solution 1

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.

Solution 2

Straight from the SVN documentation:

If you want to create a snapshot of /calc/trunk exactly as it looks in the HEAD revision, make a copy of it:

$ svn copy http://svn.example.com/repos/calc/trunk \
           http://svn.example.com/repos/calc/tags/release-1.0 \
           -m "Tagging the 1.0 release of the 'calc' project."

Committed revision 902.

This example assumes that a /calc/tags directory already exists. (If it doesn't, you can create it using svn mkdir.) After the copy completes, the new release-1.0 directory is forever a snapshot of how the /trunk directory looked in the HEAD revision at the time you made the copy. Of course, you might want to be more precise about exactly which revision you copy, in case somebody else may have committed changes to the project when you weren't looking. So if you know that revision 901 of /calc/trunk is exactly the snapshot you want, you can specify it by passing -r 901 to the svn copy command.

(emphasis mine)

Share:
22,933

Related videos on Youtube

T. Brian Jones
Author by

T. Brian Jones

I'm a programmer and systems architect who loves to analyze massive data sets. I have a degree in Mechanical Engineering and an MBA. Before becoming a full time computer jockey, I was a manufacturing and design engineer doing industrial automation and robotics. I have experience with: OSX, Linux, HTML & CSS, PHP, MySQL, MongoDB, Sphinx, ElasticSearch, CodeIgniter, CakePHP, Slim Framework, SupervisorD, Amazon Web Services ( VPC, EC2, EBS, RDS, SQS, & S3, etc., etc. ), Subversion & Assembla, GIT & Github, Jira & Confluence, API Design, Big Data management and analysis, and large scale web-crawling. I've also worked with proprietary industrial automation languages (like GE Fanuc).

Updated on June 23, 2020

Comments

  • T. Brian Jones
    T. Brian Jones almost 4 years

    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/

  • RCross
    RCross about 6 years
    Unfortunately, there's no simple command to get revision 577 back from /tags/REV-1.2. If you run "svn info" against that tag, it will show HEAD + 1 from when you ran your retrospective tagging command. This can make it difficult to, for example, get the commits between two tags.