tag: fix uncommitted merge check and error message (
issue2542)
This patch corrects the check for tagging on an uncommitted merge. We
should never commit a new tag changeset on an uncommitted merge, whether
or not --rev is specified. It also changes the error message from:
abort: cannot partially commit a merge (do not specify files or patterns)
to the much more accurate (and terse):
abort: uncommitted merge
Local tags are ok.
--- a/mercurial/commands.py Mon Dec 13 21:20:30 2010 -0600
+++ b/mercurial/commands.py Tue Dec 07 08:02:54 2010 +0100
@@ -3712,9 +3712,8 @@
if n in repo.tags():
raise util.Abort(_('tag \'%s\' already exists '
'(use -f to force)') % n)
- if not rev_ and repo.dirstate.parents()[1] != nullid:
- raise util.Abort(_('uncommitted merge - please provide a '
- 'specific revision'))
+ if not opts.get('local') and repo.dirstate.parents()[1] != nullid:
+ raise util.Abort(_('uncommitted merge'))
r = repo[rev_].node()
if not message:
--- a/tests/test-tag.t Mon Dec 13 21:20:30 2010 -0600
+++ b/tests/test-tag.t Tue Dec 07 08:02:54 2010 +0100
@@ -208,3 +208,37 @@
? editor
$ hg tag --local baz
$ hg revert --no-backup .hgtags
+
+ $ cd ..
+
+tagging on an uncommitted merge (issue2542)
+
+ $ hg init repo-tag-uncommitted-merge
+ $ cd repo-tag-uncommitted-merge
+ $ echo c1 > f1
+ $ hg ci -Am0
+ adding f1
+ $ hg branch b1
+ marked working directory as branch b1
+ $ echo c2 >> f1
+ $ hg ci -m1
+ $ hg up default
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg merge b1
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ (branch merge, don't forget to commit)
+
+ $ hg tag t1
+ abort: uncommitted merge
+ [255]
+ $ hg status
+ M f1
+ $ hg tag --rev 1 t2
+ abort: uncommitted merge
+ [255]
+ $ hg tag --rev 1 --local t3
+ $ hg tags -v
+ tip 1:9466ada9ee90
+ t3 1:9466ada9ee90 local
+
+ $ cd ..