[PATCH 1 of 1 RESEND RFC] tag: abort if not at a branch head

Adrian Buehlmann adrian at cadifra.com
Thu Dec 9 14:34:04 CST 2010


On 2010-12-07 05:06, Kevin Bullock wrote:
> # HG changeset patch
> # User Kevin Bullock <kbullock at ringworld.org>
> # Date 1291694650 21600
> # Node ID d30fb522fd1ab9025f137d3fa40b84f171709bb8
> # Parent  c73745762f33cb19feb9dd6ddfc9962c459b9679
> tag: abort if not at a branch head
> 
> Since it's usually only desirable to make tag commits on top of branch
> heads, abort if the working dir parent is not a branch head. -f/--force
> may be passed to commit at a non-head anyway.
> 
> Does not abort if working dir parent is a named branch head but not a
> topological head.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -3665,16 +3665,23 @@
>  
>      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.
> +    earlier versions or to mark branch points as releases, etc. Changing
> +    an existing tag is normally disallowed; use -f/--force to override.
>  
>      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).
> +    they are stored as a file named ".hgtags" which is managed similarly
> +    to other project files and can be hand-edited if necessary. This
> +    also means that tagging creates a new commit. The file
> +    ".hg/localtags" is used for local tags (not shared among
> +    repositories).
> +
> +    Tag commits are usually made at the head of a branch. If the parent
> +    of the working directory is not a branch head, :hg:`tag` aborts; use
> +    -f/--force to force the tag commit to be based on a non-head
> +    changeset.
>  
>      See :hg:`help dates` for a list of formats valid for -d/--date.
>  
> @@ -3717,6 +3724,11 @@
>              if n in repo.tags():
>                  raise util.Abort(_('tag \'%s\' already exists '
>                                     '(use -f to force)') % n)
> +        wctx = repo[None]
> +        bheads = repo.branchheads()
> +        if not opts.get('local') and bheads \
> +                and not [x for x in wctx.parents() if x.node() in bheads]:
> +            raise util.Abort(_('not at a branch head (use -f to force)'))

For the uncommitted merges thing:

I've just filed http://mercurial.selenic.com/bts/issue2542
"tag should abort on uncommitted merge"

It might help to fix that first. Feel free to take over my other
unfinished tag patch for stable for that (TODO there: needs a test
change that passes mpm's requirements).


More information about the Mercurial-devel mailing list