3658 |
3658 |
3659 Name a particular revision using <name>. |
3659 Name a particular revision using <name>. |
3660 |
3660 |
3661 Tags are used to name particular revisions of the repository and are |
3661 Tags are used to name particular revisions of the repository and are |
3662 very useful to compare different revisions, to go back to significant |
3662 very useful to compare different revisions, to go back to significant |
3663 earlier versions or to mark branch points as releases, etc. |
3663 earlier versions or to mark branch points as releases, etc. Changing |
|
3664 an existing tag is normally disallowed; use -f/--force to override. |
3664 |
3665 |
3665 If no revision is given, the parent of the working directory is |
3666 If no revision is given, the parent of the working directory is |
3666 used, or tip if no revision is checked out. |
3667 used, or tip if no revision is checked out. |
3667 |
3668 |
3668 To facilitate version control, distribution, and merging of tags, |
3669 To facilitate version control, distribution, and merging of tags, |
3669 they are stored as a file named ".hgtags" which is managed |
3670 they are stored as a file named ".hgtags" which is managed similarly |
3670 similarly to other project files and can be hand-edited if |
3671 to other project files and can be hand-edited if necessary. This |
3671 necessary. The file '.hg/localtags' is used for local tags (not |
3672 also means that tagging creates a new commit. The file |
3672 shared among repositories). |
3673 ".hg/localtags" is used for local tags (not shared among |
|
3674 repositories). |
|
3675 |
|
3676 Tag commits are usually made at the head of a branch. If the parent |
|
3677 of the working directory is not a branch head, :hg:`tag` aborts; use |
|
3678 -f/--force to force the tag commit to be based on a non-head |
|
3679 changeset. |
3673 |
3680 |
3674 See :hg:`help dates` for a list of formats valid for -d/--date. |
3681 See :hg:`help dates` for a list of formats valid for -d/--date. |
3675 |
3682 |
3676 Since tag names have priority over branch names during revision |
3683 Since tag names have priority over branch names during revision |
3677 lookup, using an existing branch name as a tag name is discouraged. |
3684 lookup, using an existing branch name as a tag name is discouraged. |
3710 elif not opts.get('force'): |
3717 elif not opts.get('force'): |
3711 for n in names: |
3718 for n in names: |
3712 if n in repo.tags(): |
3719 if n in repo.tags(): |
3713 raise util.Abort(_('tag \'%s\' already exists ' |
3720 raise util.Abort(_('tag \'%s\' already exists ' |
3714 '(use -f to force)') % n) |
3721 '(use -f to force)') % n) |
3715 if not opts.get('local') and repo.dirstate.parents()[1] != nullid: |
3722 if not opts.get('local'): |
3716 raise util.Abort(_('uncommitted merge')) |
3723 p1, p2 = repo.dirstate.parents() |
|
3724 if p2 != nullid: |
|
3725 raise util.Abort(_('uncommitted merge')) |
|
3726 bheads = repo.branchheads() |
|
3727 if not opts.get('force') and bheads and p1 not in bheads: |
|
3728 raise util.Abort(_('not at a branch head (use -f to force)')) |
3717 r = repo[rev_].node() |
3729 r = repo[rev_].node() |
3718 |
3730 |
3719 if not message: |
3731 if not message: |
3720 # we don't translate commit messages |
3732 # we don't translate commit messages |
3721 message = ('Added tag %s for changeset %s' % |
3733 message = ('Added tag %s for changeset %s' % |
4473 _('list the changed files of a revision'), _('REV')), |
4485 _('list the changed files of a revision'), _('REV')), |
4474 ] + walkopts + subrepoopts, |
4486 ] + walkopts + subrepoopts, |
4475 _('[OPTION]... [FILE]...')), |
4487 _('[OPTION]... [FILE]...')), |
4476 "tag": |
4488 "tag": |
4477 (tag, |
4489 (tag, |
4478 [('f', 'force', None, _('replace existing tag')), |
4490 [('f', 'force', None, _('force tag')), |
4479 ('l', 'local', None, _('make the tag local')), |
4491 ('l', 'local', None, _('make the tag local')), |
4480 ('r', 'rev', '', |
4492 ('r', 'rev', '', |
4481 _('revision to tag'), _('REV')), |
4493 _('revision to tag'), _('REV')), |
4482 ('', 'remove', None, _('remove a tag')), |
4494 ('', 'remove', None, _('remove a tag')), |
4483 # -l/--local is already there, commitopts cannot be used |
4495 # -l/--local is already there, commitopts cannot be used |