开发者

Tagging in Subversion - how do I make the decision about continuing to work on my trunk vs. the new tag?

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 us开发者_如何学Cing 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?


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...


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.


Let's make is simpler:

Recommended way to create your project structure:

  • svnRoot/projectName/trunk (actual development line)
  • svnRoot/projectName/tags/Release_X.X.X (think in tags as label but they are just copies)
  • svnRoot/projectName/branches/Release_X.X.X (copy that can be updatable, a branch a sub-project)

Never commit over tag (you can but you shouldn't).

If you have need to develop somenthing without destroying someone else work, create a branch, then merge your branch with the trunk, but take care :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜