Differences between revisions 19 and 20
Revision 19 as of 2008-01-13 16:04:45
Size: 932
Editor: abuehl
Comment: lowercase links
Revision 20 as of 2008-02-10 20:39:00
Size: 2720
Editor: abuehl
Comment: Merge from FAQ/Tags
Deletions are marked like this. Additions are marked like this.
Line 16: Line 16:
=== How do tags work in Mercurial? ===

Tags work slightly differently in Mercurial than most revision
systems. The design attempts to meet the following requirements:

 * be version controlled and mergeable just like any other file
 * allow signing of tags
 * allow adding a tag to an already committed changeset
 * allow changing tags in the future

Thus Mercurial stores tags as a file in the working dir. This file is
called .hgtags and consists of a list of changeset I``Ds and their
corresponding tags. To add a tag to the system, simply add a line to
this file and then commit it for it to take effect. The {{{hg tag}}}
command will do this for you and {{{hg tags}}} will show the currently
effective tags.

Note that because tags refer to changeset I``Ds and the changeset ID is
effectively the sum of all the contents of the repository for that
change, it is impossible in Mercurial to simultaneously commit and add
a tag. Thus tagging a revision must be done as a second step.


=== What if I want to just keep local tags? ===

You can use "hg tag" command with an option {{{-l}}} or {{{--local}}}. This
will store the tag in the file .hg/localtags, which will not be
distributed or versioned. The format of this file is identical to the
one of .hgtags and the tags stored there are handled the same.


=== How do tags work with multiple heads? ===

The tags that are in effect at any given time are the tags specified
in each head, with heads closer to the tip taking precedence. Local
tags override all other tags.

=== What if multiple lines with different revisions use the same tag name in .hgtags? ===

Only the last line where the tag appears is taken into account.
The behavior is identical when this happens in .hg/localtags.

Tags in Mercurial

hg tag

hg tags

Note: If you are migrating from ["CVS"], please [:CvsConcepts#tag:read this discussion of CVS tags] before you continue.

A tag is a symbolic identifier for a [:ChangeSet:changeset]. It can contain any characters except ":" (colon), "\r" (Carriage Return) or "\n" (Line Feed).

Mercurial has two kinds of tag.

  • A local tag is a convenience identifier that is not revision controlled, does not propagate with other changes, and lives in the .hg/localtags file in a [:Repository:repository].

  • A "regular" tag (with no special specifier) is revision controlled, does propagate with other changes, and lives in the .hgtags file in a repository. (It is therefore possible to remove tags by editing .hgtags and committing the change - this being the nearest equivalent to cvs tag -d).

1. How do tags work in Mercurial?

Tags work slightly differently in Mercurial than most revision systems. The design attempts to meet the following requirements:

  • be version controlled and mergeable just like any other file
  • allow signing of tags
  • allow adding a tag to an already committed changeset
  • allow changing tags in the future

Thus Mercurial stores tags as a file in the working dir. This file is called .hgtags and consists of a list of changeset IDs and their corresponding tags. To add a tag to the system, simply add a line to this file and then commit it for it to take effect. The hg tag command will do this for you and hg tags will show the currently effective tags.

Note that because tags refer to changeset IDs and the changeset ID is effectively the sum of all the contents of the repository for that change, it is impossible in Mercurial to simultaneously commit and add a tag. Thus tagging a revision must be done as a second step.

2. What if I want to just keep local tags?

You can use "hg tag" command with an option -l or --local. This will store the tag in the file .hg/localtags, which will not be distributed or versioned. The format of this file is identical to the one of .hgtags and the tags stored there are handled the same.

3. How do tags work with multiple heads?

The tags that are in effect at any given time are the tags specified in each head, with heads closer to the tip taking precedence. Local tags override all other tags.

4. What if multiple lines with different revisions use the same tag name in .hgtags?

Only the last line where the tag appears is taken into account. The behavior is identical when this happens in .hg/localtags.


CategoryCommand CategoryGlossary

Tag (last edited 2013-09-01 02:00:16 by KevinBot)