[PATCH 1 of 1] merge: allow merging with different-branch ancestor

Dirkjan Ochtman dirkjan at ochtman.nl
Thu Jan 1 13:40:51 CST 2009


# HG changeset patch
# User Dirkjan Ochtman <dirkjan at ochtman.nl>
# Date 1230837338 -3600
# Node ID 3a87e045b6a68893a52e7ec107f56e2832487011
# Parent  016a7319e76ba15474a89199657c5aa39bd3b339
merge: allow merging with different-branch ancestor

diff -r 016a7319e76b -r 3a87e045b6a6 mercurial/merge.py
--- a/mercurial/merge.py	Wed Dec 31 18:00:35 2008 -0600
+++ b/mercurial/merge.py	Thu Jan 01 20:15:38 2009 +0100
@@ -445,14 +445,13 @@
         if not overwrite and len(pl) > 1:
             raise util.Abort(_("outstanding uncommitted merges"))
         if branchmerge:
-            if pa == p2:
+            if pa in (p1, p2) and p1.branch() != p2.branch():
+                fastforward = True
+            elif pa == p2:
                 raise util.Abort(_("can't merge with ancestor"))
             elif pa == p1:
-                if p1.branch() != p2.branch():
-                    fastforward = True
-                else:
-                    raise util.Abort(_("nothing to merge (use 'hg update'"
-                                       " or check 'hg heads')"))
+                raise util.Abort(_("nothing to merge (use 'hg update'"
+                                   " or check 'hg heads')"))
             if not force and (wc.files() or wc.deleted()):
                 raise util.Abort(_("outstanding uncommitted changes"))
         elif not overwrite:
diff -r 016a7319e76b -r 3a87e045b6a6 tests/test-merge-ancestor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-merge-ancestor	Thu Jan 01 20:15:38 2009 +0100
@@ -0,0 +1,16 @@
+echo "[extensions]" >> $HGRCPATH
+echo "graphlog=" >> $HGRCPATH
+
+hg init test
+cd test
+
+echo a > a
+hg ci -Ama
+
+hg branch b
+echo c > c
+hg ci -Amc
+hg glog
+
+hg up b
+hg merge default
diff -r 016a7319e76b -r 3a87e045b6a6 tests/test-merge-ancestor.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-merge-ancestor.out	Thu Jan 01 20:15:38 2009 +0100
@@ -0,0 +1,18 @@
+adding a
+marked working directory as branch b
+adding c
+@  changeset:   1:27d13011d2cd
+|  branch:      b
+|  tag:         tip
+|  user:        test
+|  date:        Thu Jan 01 00:00:00 1970 +0000
+|  summary:     c
+|
+o  changeset:   0:cb9a9f314b8b
+   user:        test
+   date:        Thu Jan 01 00:00:00 1970 +0000
+   summary:     a
+
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+(branch merge, don't forget to commit)


More information about the Mercurial-devel mailing list