changeset 4815:8808ea7da86b

merge: make test for fast-forward merge stricter (issue619) don't allow merging with an ancestor fix != on contexts add a test
author Matt Mackall <mpm@selenic.com>
date Thu, 05 Jul 2007 13:34:18 -0500
parents 452d171a1b39
children 5cc184800bf2 9797124581c9
files mercurial/context.py mercurial/merge.py tests/test-issue619 tests/test-issue619.out
diffstat 4 files changed, 37 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -40,6 +40,9 @@ class changectx(object):
         except AttributeError:
             return False
 
+    def __ne__(self, other):
+        return not (self == other)
+
     def __nonzero__(self):
         return self._rev != nullrev
 
@@ -185,6 +188,9 @@ class filectx(object):
         except AttributeError:
             return False
 
+    def __ne__(self, other):
+        return not (self == other)
+
     def filectx(self, fileid):
         '''opens an arbitrary revision of the file without
         opening a new filelog'''
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -523,7 +523,7 @@ def update(repo, node, branchmerge, forc
         raise util.Abort(_("outstanding uncommitted merges"))
     if pa == p1 or pa == p2: # is there a linear path from p1 to p2?
         if branchmerge:
-            if p1.branch() != p2.branch():
+            if p1.branch() != p2.branch() and pa != p2:
                 fastforward = True
             else:
                 raise util.Abort(_("there is nothing to merge, just use "
new file mode 100755
--- /dev/null
+++ b/tests/test-issue619
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+mkdir t
+cd t
+hg init
+echo a > a
+hg ci -Ama -d '1000000000 0'
+echo b > b
+hg branch b
+hg ci -Amb -d '1000000000 0'
+hg co -C 0
+
+echo fast-forward
+hg merge b
+hg ci -Ammerge -d '1000000000 0'
+
+echo bogus fast-forward should fail
+hg merge b
+
+echo done
new file mode 100644
--- /dev/null
+++ b/tests/test-issue619.out
@@ -0,0 +1,10 @@
+adding a
+marked working directory as branch b
+adding b
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+fast-forward
+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: there is nothing to merge, just use 'hg update' or look at 'hg heads'
+done