changeset 1665:3a56574f329a 0.8

Merge with crew
author Matt Mackall <mpm@selenic.com>
date Mon, 30 Jan 2006 12:04:36 +1300
parents 4338e33c973b (diff) 2d8dc84c9323 (current diff)
children 0fc1b588976f
files
diffstat 2 files changed, 38 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgmerge	Sun Jan 29 14:36:11 2006 +0100
+++ b/hgmerge	Mon Jan 30 12:04:36 2006 +1300
@@ -44,14 +44,37 @@
     cp "$LOCAL.orig" "$LOCAL"
 fi
 
-# on MacOS X try opendiff
-# (uses FileMerge.app, shipped with Apple's developer tools)
-if type opendiff > /dev/null 2>&1; then
-    opendiff "$LOCAL.orig" "$OTHER" -ancestor "$BASE" -merge "$LOCAL" || exit 1
-    # prevent $OTHER from being removed too early
-    # can surely be done in a more elegant way
-    sleep 1
-    exit 0
+# on MacOS X try FileMerge.app, shipped with Apple's developer tools
+# TODO: make proper temp files. foo.orig and foo.link are dangerous
+FILEMERGE='/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge'
+if type "$FILEMERGE" > /dev/null 2>&1; then
+    cp "$LOCAL.orig" "$LOCAL"
+    ln "$LOCAL" "$LOCAL.link"
+    # filemerge prefers the right by default
+    if ! "$FILEMERGE" -left "$OTHER" -right "$LOCAL" -ancestor "$BASE" -merge "$LOCAL"
+    then
+        echo "FileMerge failed to launch"
+        exit 1
+    fi
+    if ! test "$LOCAL" -ef "$LOCAL.link"
+    then
+        rm "$LOCAL.orig" "$LOCAL.link"
+        exit 0
+    else
+        rm "$LOCAL.link"
+        echo "$LOCAL is unchanged. Was the merge successful?"
+        select answer in yes no
+        do
+            if test "$answer" == "yes"
+            then
+                rm "$LOCAL.orig"
+                exit 0
+            else
+                exit 1
+            fi
+        done
+        exit 1
+    fi
 fi
 
 if [ -n "$DISPLAY" ]; then
--- a/mercurial/localrepo.py	Sun Jan 29 14:36:11 2006 +0100
+++ b/mercurial/localrepo.py	Mon Jan 30 12:04:36 2006 +1300
@@ -1383,6 +1383,8 @@
             self.ui.warn(_("aborting: outstanding uncommitted merges\n"))
             return 1
 
+        err = False
+
         p1, p2 = pl[0], node
         pa = self.changelog.ancestor(p1, p2)
         m1n = self.changelog.read(p1)[0]
@@ -1598,7 +1600,9 @@
         for f in files:
             self.ui.status(_("merging %s\n") % f)
             my, other, flag = merge[f]
-            self.merge3(f, my, other)
+            ret = self.merge3(f, my, other)
+            if ret:
+                err = True
             util.set_exec(self.wjoin(f), flag)
             if moddirstate:
                 if branch_merge:
@@ -1631,6 +1635,7 @@
 
         if moddirstate:
             self.dirstate.setparents(p1, p2)
+        return err
 
     def merge3(self, fn, my, other):
         """perform a 3-way merge in the working directory"""
@@ -1661,6 +1666,7 @@
 
         os.unlink(b)
         os.unlink(c)
+        return r
 
     def verify(self):
         filelinkrevs = {}