[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Using tags with SVN

From: David Weintraub <qazwart_at_gmail.com>
Date: Mon, 4 Apr 2011 10:44:10 -0400

On Fri, Apr 1, 2011 at 8:52 AM, Stirnweiss, Siegmund SZ/HZA-ZIT3
<stirnseg_at_schaeffler.com> wrote:
>> Now, there's nothing in Subversion preventing you from attaching a tag
>> to a particular version of a file. You simply copy files to the tag
>> directory one at a time. When a file gets approved, you "tag" it. It's
>> not the standard way to do it, but I've seen shops that do.
> What exactly do you mean with copy? Do you mean a "svn copy"? Or do you
> mean a file system copy?

In Subversion, there is no such thing as a special meta-data that
marks branches or tags as CVS has. Instead, you merely use directories
to mark branches and tags. This isn't all that unusual. Perforce
(another popular version control system) also uses directories for
branching and they call it "Interfile-branching".

For those who are use to branches being more than mere directory
structures, this seems strange. After all, what's the difference
between a directory in a module and a branch in Subversion? Then
again, what's the difference between a module and a directory in CVS?
Both merely use user conventions to maintain a structure that doesn't
exist in the underlying software.

And, Subversion's branching system work. I first ran into using
directories for branching with Perforce (another popular version
control system). Perforce called it "Interfile-branching". The
developers actually found it much easier to work with than the CVS
method of doing branches.

Branches were no longer mysterious piece of meta-data that remained
hidden. Instead, they were visible and easy to see. In CVS, to find
the names of all branches ever used in your project, you'll have to do
a "cvs log" on all the files in your module, and then grep out the
branch names and sort through them. In Subversion and Perforce, you
merely have to list the branch names as you would a directory.

In Subversion, the custom is to create three directories called
"tags", "branches", and "trunk". The "branches" directory stores all
of your branches, and the "tags" directory is for your tags. The
"trunk" directory is for your mainline development much like the
"trunk" in CVS is for. Some people put these on the root of the
repository, others put them in the root of the module.

Let's say I do my development on "trunk", and I want to make a branch,
in Subversion I would simply make a copy:

svn cp -m"Making branch 'foo'" http://svn/repository/module/trunk

In Subversion, the standard way of doing development is to do your
mainline development work on "trunk", then when you're work is either
feature complete, or you're ready to do a code freeze, you create a
release branch:

    svn cp -m"Making branch for release 1.2"

This allows some of the developers to continue working on the release
while others work on future development.

Once all the work is complete for Release 1.2 on the Release 1.2
branch, you can create a tag:

    svn cp -m"Tagging release REL-1.2"

There is nothing in Subversion that prevents you from creating an
"approved" branch or tag and allowing you to copy individual files to
that branch or tag when they are approved.

Let's say instead of merely creating a "trunk", "tags", and "branches"
directory, you create a "trunk", "tags", "branches" and
"approved-files" directory. The "approved-files" directory are the
files that have been approved for each release. (Notice I didn't
specify if "approve-files" is a tag or a branch. It doesn't make any

    svn cp -m"Approved file foo.java"

Now, you can actually see what files have been approved and what files
have not yet been approved by merely listing the files on each branch:

     $ svn ls -R http://svn/repository/module/branches/1.2 #All files
     $ svn ls -R http://svn/repository/module/approved-files/1.2
#Approved files

Of course, if you insist on doing things exactly the same way you do
in CVS, there's nothing in Subversion that's stopping you. The below
is how I tag a particular file in "trunk" with the "Q" tag:

     $ cvs rtag -l -m"This is how we approve file foo.java in CVS" Q

     $ svn cp -R -m"Approved file foo.java just like we do in CVS"

And, to build off the "Q" tag, you simply do a checkout just like
you'd do in CVS:

    $ cvs co -rQ module
    $ svn co http://svn/repository/module/tags/Q

And, if you need to "move" the tag "Q", simply copy the replacement
file to the "Q" tag:

    $ cvs rtag -F -r1. -l -m"Revision of foo.java
has been approved" Q module/main/java/foo.java

    $ svn copy -r2339 -m"Revision #2339 of 'foo.java" has been
approved" http://svn/repository/module/trunk/main/java/foo.java

In fact, Subversion has a big advantage over CVS if you insist on
doing this. In Subversion, you can get the history of the changes to
your "Q" tag:

    $ svn log http://svn/repository/module/tags/Q/src/main/java/foo.java

This wil list all of the revisions ever tagged as "Q" for "foo.java".
It will list the dates when that tag was applied, who applied that
tag, and their comment. There's no way to do this in standard CVS.

David Weintraub
Received on 2011-04-04 16:46:02 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.