[PATCH] merge: give clearer error messages when there is nothing to merge
Greg Ward
greg-hg at gerg.ca
Mon Jun 14 13:45:53 CDT 2010
# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1276536677 14400
# Node ID c6971a790206f824df9b25607fa4d030baad92fd
# Parent 39d4534094c12f1b679be1e203e6b5cc21a4f859
merge: give clearer error messages when there is nothing to merge
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -462,18 +462,28 @@
fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
fastforward = False
+ errprefix = _('nothing to merge')
+ errself = _('attempt to merge current changeset with itself')
+ errancestor = _('attempt to merge with an ancestor of the working dir')
+ errdesc = _('attempt to merge with a descendant of the working dir')
+
### check phase
if not overwrite and len(pl) > 1:
raise util.Abort(_("outstanding uncommitted merges"))
if branchmerge:
- if pa == p2:
- raise util.Abort(_("can't merge with ancestor"))
+ if p1 == p2:
+ raise util.Abort('%s\n(%s)' % (errprefix, errself))
+ elif pa == p2:
+ raise util.Abort('%s\n(%s)' % (errprefix, errancestor))
elif pa == p1:
if p1.branch() != p2.branch():
fastforward = True
else:
- raise util.Abort(_("nothing to merge (use 'hg update'"
- " or check 'hg heads')"))
+ # we could advise the user to update to the latest branch
+ # head, but we should check that there is a later branch
+ # head first
+ raise util.Abort('%s\n(%s)' % (errprefix, errdesc))
+
if not force and (wc.files() or wc.deleted()):
raise util.Abort(_("outstanding uncommitted changes "
"(use 'hg status' to list changes)"))
diff --git a/tests/test-issue619.out b/tests/test-issue619.out
--- a/tests/test-issue619.out
+++ b/tests/test-issue619.out
@@ -6,5 +6,6 @@
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
bogus fast-forward should fail
-abort: can't merge with ancestor
+abort: nothing to merge
+(attempt to merge with an ancestor of the working dir)
done
More information about the Mercurial-devel
mailing list