tags:

views:

116

answers:

2

Hi,

From here, it said hg tag 1.0 is to get my Mercurial repository to a tag name.

How can I switch my repository to that tag name?

$ hg tag myTag1.0
$ <edit more files>
$ hg commit -m "a message"
$ hg how to go back to that tag?

and if I make a new hg commit here, what will happen? Will it goes to the branch of myTag1.0? Or it will stay with default branch?

Thank you.

+4  A: 

Tags are not branches. Tags are markers for a particular commit - basically, a way to name commits. That's all. You don't "switch a repository to a tag" any more than you would "switch a repository to a commit" - you can check out a tag, but all that does is roll back your working copy to the corresponding changeset which was tagged.

Branches are created automatically in Mercurial when you commit code that doesn't directly build off of the current head revision.

See here for some more details:

http://mercurial.selenic.com/wiki/Tag

http://mercurial.selenic.com/wiki/Branch

Amber
+1  A: 

Just update to the tag name.

hg tag 1.0
... make changes ...
hg ci
hg up 1.0
Robert
The problem with this is that tags are committed as changes to the .hgtags file. So like this:Changeset: 350:e6e05f8b7536tag: tipdescription: added tag 1.0 for changset 5d0862b8c30bChangeset 349:5d0862b8c30btag: 1.0description:Fixed bugs X and Y, 1.0 pending testing.But now when you hg up 1.0, the tags don't exist, so any commit here will create a branch (new head) where 1.0 is not tagged.Not so much a problem, but something you must be aware of.
bobpaul
Hmm.. that does not maintain formatting, does it?
bobpaul