changeset 2814:0f787997e3c2

Merge: move most tests to the beginning
author Matt Mackall <mpm@selenic.com>
date Tue, 08 Aug 2006 10:35:19 -0500
parents 56f99f5aab34
children 4870f795f681
files mercurial/merge.py
diffstat 1 files changed, 18 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Tue Aug 08 09:26:00 2006 -0500
+++ b/mercurial/merge.py	Tue Aug 08 10:35:19 2006 -0500
@@ -53,12 +53,30 @@
     if not wlock:
         wlock = repo.wlock()
 
+    ### check phase
+
     pl = repo.dirstate.parents()
     if not force and pl[1] != nullid:
         raise util.Abort(_("outstanding uncommitted merges"))
 
     p1, p2 = pl[0], node
     pa = repo.changelog.ancestor(p1, p2)
+
+    # is there a linear path from p1 to p2?
+    linear_path = (pa == p1 or pa == p2)
+    if branchmerge and linear_path:
+        raise util.Abort(_("there is nothing to merge, just use "
+                           "'hg update' or look at 'hg heads'"))
+
+    if not force and not linear_path and not branchmerge:
+        raise util.Abort(_("this update spans a branch, use 'hg merge' "
+                           "or 'hg update -C' to lose changes"))
+
+    modified, added, removed, deleted, unknown = repo.changes()
+    if branchmerge and not forcemerge:
+        if modified or added or removed:
+            raise util.Abort(_("outstanding uncommitted changes"))
+
     m1n = repo.changelog.read(p1)[0]
     m2n = repo.changelog.read(p2)[0]
     man = repo.manifest.ancestor(m1n, m2n)
@@ -69,19 +87,6 @@
     ma = repo.manifest.read(man)
     mfa = repo.manifest.readflags(man)
 
-    modified, added, removed, deleted, unknown = repo.changes()
-
-    # is this a jump, or a merge?  i.e. is there a linear path
-    # from p1 to p2?
-    linear_path = (pa == p1 or pa == p2)
-
-    if branchmerge and linear_path:
-        raise util.Abort(_("there is nothing to merge, just use "
-                           "'hg update' or look at 'hg heads'"))
-    if branchmerge and not forcemerge:
-        if modified or added or removed:
-            raise util.Abort(_("outstanding uncommitted changes"))
-
     if not forcemerge and not force:
         for f in unknown:
             if f in m2:
@@ -234,21 +239,6 @@
     if linear_path or force:
         # we don't need to do any magic, just jump to the new rev
         p1, p2 = p2, nullid
-    else:
-        if not branchmerge:
-            repo.ui.status(_("this update spans a branch"
-                             " affecting the following files:\n"))
-            fl = merge.keys() + get.keys()
-            fl.sort()
-            for f in fl:
-                cf = ""
-                if f in merge:
-                    cf = _(" (resolve)")
-                repo.ui.status(" %s%s\n" % (f, cf))
-            repo.ui.warn(_("aborting update spanning branches!\n"))
-            repo.ui.status(_("(use 'hg merge' to merge across branches"
-                             " or 'hg update -C' to lose changes)\n"))
-            return 1
 
     xp1 = hex(p1)
     xp2 = hex(p2)