Differences between revisions 23 and 24
Revision 23 as of 2008-04-08 07:24:18
Size: 3584
Editor: abuehl
Comment: +some links
Revision 24 as of 2008-04-20 00:09:43
Size: 5096
Editor: abuehl
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Tags in Mercurial == #pragma section-numbers 3
== Tag ==
Line 3: Line 4:
  ''Note: If you are migrating from ["CVS"], please [:CvsConcepts#tag:read this discussion of CVS tags] before you continue.'' (''Note: If you are migrating from ["CVS"], please [:CvsConcepts#tag:read this discussion of CVS tags] before you continue.'')
Line 5: Line 6:
''hg tag'' `hg tags`[[BR]]
`hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...`
Line 7: Line 9:
''hg tags'' 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 tags: local and regular.
Line 9: Line 11:
A tag is a symbolic identifier for a [:ChangeSet:changeset]. It can contain any characters except ":" (colon), "\r" (Carriage Return) or "\n" (Line Feed). 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].
Line 11: Line 13:
Mercurial has two kinds of tag. 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}}}).
Line 13: Line 15:
 * 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}}}).
[[TableOfContents]]
Line 67: Line 68:
=== Help texts ===
{{{
hg tags

list repository tags

    List the repository tags.

    This lists both regular and local tags. When the -v/--verbose switch
    is used, a third column "local" is printed for local tags.
}}}

{{{
hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...

add one or more tags for the current or given revision

    Name a particular revision using <name>.

    Tags are used to name particular revisions of the repository and are
    very useful to compare different revisions, to go back to significant
    earlier versions or to mark branch points as releases, etc.

    If no revision is given, the parent of the working directory is used,
    or tip if no revision is checked out.

    To facilitate version control, distribution, and merging of tags,
    they are stored as a file named ".hgtags" which is managed
    similarly to other project files and can be hand-edited if
    necessary. The file '.hg/localtags' is used for local tags (not
    shared among repositories).

    See 'hg help dates' for a list of formats valid for -d/--date.

options:

 -f --force replace existing tag
 -l --local make the tag local
 -r --rev revision to tag
    --remove remove a tag
 -m --message use <text> as commit message
 -d --date record datecode as commit date
 -u --user record user as committer
}}}

Tag

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

hg tagsBR hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...

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 tags: local and regular.

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

TableOfContents

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 [:Merge:mergeable] just like any other file

  • allow signing of tags
  • allow adding a tag to an already [:Commit:committed] changeset

  • allow changing tags in the future

Thus Mercurial stores tags as a file in the [:WorkingDirectory:working dir]. This file is called .hgtags and consists of a list of [:ChangeSetID: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 for the changeset being committed. Thus tagging a revision must be done as a second step. Thus, as above, the only changesets that can be tagged are ones already committed.

The fact that tags identify changesets and are also parts of changesets has some potentially confusing implications:

  • The changeset that a tag refers to is always older than the changeset that commits the tag itself.
  • [:Update:Updating] a working dir to a particular tag will take that directory back to a point before the tag itself existed.

  • [:Clone:Cloning] a repo to a particular tag will give you a new repo that does not have that tag.

<!> Common wisdom says that to avoid the confusion of a disappearing tag, you should clone the entire repo and then update the working directory to the tag. Thus preserving the tag in the repo.

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:head], with heads closer to the [:Tip:tip] taking precedence. Local tags override all other tags.

See also: [:MultipleHeads]

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.

Help texts

hg tags

list repository tags

    List the repository tags.

    This lists both regular and local tags. When the -v/--verbose switch
    is used, a third column "local" is printed for local tags.

hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...

add one or more tags for the current or given revision

    Name a particular revision using <name>.

    Tags are used to name particular revisions of the repository and are
    very useful to compare different revisions, to go back to significant
    earlier versions or to mark branch points as releases, etc.

    If no revision is given, the parent of the working directory is used,
    or tip if no revision is checked out.

    To facilitate version control, distribution, and merging of tags,
    they are stored as a file named ".hgtags" which is managed
    similarly to other project files and can be hand-edited if
    necessary. The file '.hg/localtags' is used for local tags (not
    shared among repositories).

    See 'hg help dates' for a list of formats valid for -d/--date.

options:

 -f --force    replace existing tag
 -l --local    make the tag local
 -r --rev      revision to tag
    --remove   remove a tag
 -m --message  use <text> as commit message
 -d --date     record datecode as commit date
 -u --user     record user as committer


CategoryCommand CategoryGlossary

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