]> scripts.mit.edu Git - wizard.git/commitdiff
Add some automatic resolutions for whole-file.
authorEdward Z. Yang <ezyang@mit.edu>
Sat, 6 Feb 2010 08:29:07 +0000 (03:29 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Sat, 6 Feb 2010 08:29:12 +0000 (03:29 -0500)
* If common and theirs are present, but ours isn't, don't
  include ours.
* If theirs is present, but common and ours isn't, add theirs.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
wizard/app/__init__.py

index 391f8d8956aeb0f1192d04e7fa07cc2e51c0aeda..f9bb240426c4166d99db2cd24bb6fc85d529dcbd 100644 (file)
@@ -241,9 +241,20 @@ class Application(object):
         """
         resolved = True
         files = set()
+        files = {}
         for status in shell.eval("git", "ls-files", "--unmerged").splitlines():
-            files.add(status.split()[-1])
-        for file in files:
+            mode, hash, role, name = status.split()
+            files.setdefault(name, set()).add(int(role))
+        for file, roles in files.items():
+            # some automatic resolutions
+            if 1 not in roles and 2 not in roles and 3 in roles:
+                # upstream added a file, but it conflicted for whatever reason
+                shell.call("git", "add", file)
+                continue
+            elif 1 in roles and 2 not in roles and 3 in roles:
+                # user deleted the file, but upstream changed it
+                shell.call("git", "rm", file)
+                continue
             # manual resolutions
             if file in self.resolutions:
                 contents = open(file, "r").read()