[PATCH 2 of 2 STABLE V2] tag: fix uncommitted merge check and error message (issue2542)

Kevin Bullock kbullock+mercurial at ringworld.org
Tue Dec 14 11:44:52 CST 2010


# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1291705374 -3600
# Branch stable
# Node ID 3492561282bcda8e2d983607fa50493822beb48c
# Parent  d3e7418583b79096a6e6a6c02e3329de02a1fe1a
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.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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:
diff --git a/tests/test-tag.t b/tests/test-tag.t
--- a/tests/test-tag.t
+++ b/tests/test-tag.t
@@ -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 ..


More information about the Mercurial-devel mailing list