Add --mbox option to the 'mail' command
[stgit] / gitmergeonefile.py
index 1cba193..2f327a3 100755 (executable)
@@ -121,7 +121,7 @@ def __conflict():
 #   $2 - file in branch1 SHA1 (or empty)
 #   $3 - file in branch2 SHA1 (or empty)
 #   $4 - pathname in repository
-#   $5 - orignal file mode (or empty)
+#   $5 - original file mode (or empty)
 #   $6 - file in branch1 mode (or empty)
 #   $7 - file in branch2 mode (or empty)
 #
@@ -140,7 +140,7 @@ __checkout_files()
 if orig_hash:
     # modified in both
     if file1_hash and file2_hash:
-        # if modes are the same (git-read-tree probably dealed with it)
+        # if modes are the same (git-read-tree probably dealt with it)
         if file1_hash == file2_hash:
             if os.system('git-update-index --cacheinfo %s %s %s'
                          % (file1_mode, file1_hash, path)) != 0:
@@ -180,6 +180,30 @@ if orig_hash:
             os.remove(path)
         __remove_files()
         sys.exit(os.system('git-update-index --remove -- %s' % path))
+    # file deleted in one and changed in the other
+    else:
+        # Do something here - we must at least merge the entry in the cache,
+        # instead of leaving it in U(nmerged) state. In fact, stg resolved
+        # does not handle that.
+
+        # Do the same thing cogito does - remove the file in any case.
+        os.system('git-update-index --remove -- %s' % path)
+
+        #if file1_hash:
+            ## file deleted upstream and changed in the patch. The patch is
+            ## probably going to move the changes elsewhere.
+
+            #os.system('git-update-index --remove -- %s' % path)
+        #else:
+            ## file deleted in the patch and changed upstream. We could re-delete
+            ## it, but for now leave it there - and let the user check if he
+            ## still wants to remove the file.
+
+            ## reset the cache to the first branch
+            #os.system('git-update-index --cacheinfo %s %s %s'
+                      #% (file1_mode, file1_hash, path))
+        __conflict()
+
 # file does not exist in origin
 else:
     # file added in both
@@ -218,8 +242,8 @@ else:
         __remove_files()
         sys.exit(os.system('git-checkout-index -u -f -- %s' % path))
 
-# Un-handled case
-print >> sys.stderr, 'Error: Un-handled merge conflict'
+# Unhandled case
+print >> sys.stderr, 'Error: Unhandled merge conflict'
 print >> sys.stderr, 'gitmergeonefile.py "%s" "%s" "%s" "%s" "%s" "%s" "%s"' \
       % tuple(sys.argv[1:8])
 __conflict()