views:

48

answers:

2

I'm running Tortoise SVN to manage a project. Obviously the principles around tagging apply to any implementation of SVN but in this question I'll be referring to some TortoiseSVN-specific dialog boxes and messages.


My working directory and the subversion repository structure both have a Source root directory and the Trunk, Tags and Branches directories underneath. (I couldn't figure out how to do a multilevel indented hierarchy in markdown without using bullets, so if someone could edit and fix this I'd appreciate it.)

I'm working out of the Trunk directory in my working copy and it's pointing at the Trunk directory in the repo. I want to apply a Tag "Release1" so I click the "Branch/tag..." menu option and set the repo path as my [repo_path/bla/Source/Tags/Release1" tag. This dialog box gives me the option to "Switch my working copy to new branch/tag".

I understand that if this option is left unchecked, the new "Release1" branch under /Tags" will be created but my working copy will remain on the previous "Trunk" path. If I do check this option (or use the Switch command) I understand that my working copy will switch to the new "Release1" branch under "/Tags".

Where I'm missing a concept is how to make this decision. It doesn't seem like I want to switch my working directory to the recently created tag since by definition (?) I want that tag to be a snapshot of my code as of a point in time. If I don't switch the working directory, I'll continue working off Trunk and when I'm ready to take another snapshot I'll make another tag. And so on...

Am I understanding this right or am I stating something incorrectly in the previous paragraph (e.g. the statement about not wanting to switch to the tag since the tag should represent a point in time snapshot) or otherwise missing something regarding how to make this decision?

+3  A: 

In Subversion, a tag is not a "label" you put on a revision; it's a copy of trunk (or a branch or whatever) at some point in time. Being just a copied directory, you could commit to it; but you shouldn't.

Once you do a tag, you should stay where you were (a branch or trunk) and work there, don't switch to the tag directory. If you commit to a tag directory, you'll change its contents, and then it's not being useful as a "snapshot" anymore.

When you create a branch, usually you would want to switch to it, but there may be a situation where you want to stay in trunk after the branch creation (eg. if coincidentally you notice there's a fix to do in trunk ASAP); it's your decision. You could always switch later at any time. When you create a tag, there isn't much of a decision to make; stay in the branch you are. I can't think of any case where switching to the tag would be of any use...

Nicolás
@Nicholas - But SVN's implementation of "labels" is via Tags right? And the way tags are implemented is by making a copy of whatever the current directory is to the new tag directory. But given this, I'm assuming that tagging *is* the proper way for me to achieve the point-in-time snapshot I want, correct? Lastly, in what cases would someone want to switch to the newly created tag directory, if (at least one of) the goal(s) is to take a snapshot?
Howiecamp
SVN has no concept of "labels" that I know of, dunno what you're talking about. //Yes, tagging is the proper way to do the point-in-time snapshot. // I don't know why someone would want to switch to the newly-created tag, but if you do, don't commit (technically possible, usually undesirable).Switching to a tag long after it was created is common though, to get the code for that snapshot (usually a versioned release).
Nicolás
Gotcha so essentially I keep working off Trunk. Agree? Regarding SVN not having a labels concept I think we're saying the same thing. What's called "labels" in other source control tools is called tags in SVN. Implemented differently but used to achieve the same effect.
Howiecamp
+1  A: 

In Subversion, there technically is no such thing as a "branch" or a "tag". To SVN, they are just copies of a directory. They are only special because of how you treat them.

Tag = make a copy of a project, but don't touch it after making a copy. You generally don't want to switch to the tag, because you (normally) won't be committing any changes there.

Branch = make a copy of a project, and do some work there. Generally work you do in a branch gets merged with the trunk at some point. If you are making a branch to work on immediately, you probably want to switch to the branch (check the box).

NOTE #1: While SVN itself does not have any special treatment of trunk/branches/tags, TortoiseSVN does have a UI hint to discourage committing to a tag. If you check out a tag (or make a tag and switch to it), do some work, then try to commit, TSVN will display a warning message. TSVN tries to guess what you were really trying to do.

NOTE #2: You don't necessarily need a tag for a point-in-time snapshot. The revision number of the repo does that for you.

msemack