[PATCH STABLE] tag: fix uncommitted merge check and error message
Adrian Buehlmann
adrian at cadifra.com
Tue Dec 7 09:41:18 CST 2010
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1291705374 -3600
# Branch stable
# Node ID 740431a08c60d9b5dc3e7ce1a5b18a75e38276b5
# Parent acebcefa86d45560e271359663f9c0d9d5663573
tag: fix uncommitted merge check and error message
Before this patch, 'hg tag' without --local aborted with
abort: cannot partially commit a merge (do not specify files or patterns)
even if --rev was specified, if there was a uncommitted merge.
We cannot commit a new tag changeset if there is a uncommitted merge, even
if --rev is specified.
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 @@ def tag(ui, repo, name1, *names, **opts)
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
@@ -196,3 +196,40 @@ test custom commit messages
$ hg log -l1 --template "{desc}\n"
custom tag message
second line
+
+ $ cd ..
+
+tagging with a uncommitted merge
+
+ $ hg init r4
+ $ cd r4
+ $ echo c1 > f1
+ $ hg add f1
+ $ hg ci -m0
+ $ echo foo >> f1
+ $ hg ci -m1
+ $ hg up -q 0
+ $ echo c2 > f2
+ $ hg add f2
+ $ hg ci -m2
+ created new head
+ $ hg heads -q
+ 2:9adf12931dba
+ 1:3ec40a953f20
+ $ hg merge
+ 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 tag --rev 1 t2
+ abort: uncommitted merge
+ [255]
+ $ hg tag --rev 1 --local t3
+ $ hg tags -v
+ tip 2:9adf12931dba
+ t3 1:3ec40a953f20 local
+
+ $ cd ..
+
More information about the Mercurial-devel
mailing list