Merge with mainline
authorMatt Mackall <mpm@selenic.com>
Sun, 17 Sep 2006 16:02:09 -0500
changeset 3105 ef4e5d05bac4
parent 3104 e6818b0b8154 (diff)
parent 3100 09e8aecd8016 (current diff)
child 3106 7c7469d41ade
Merge with mainline
mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -107,8 +107,7 @@ def update(repo, node, branchmerge=False
     repo.ui.debug(_(" ancestor %s local %s remote %s\n") %
                   (short(p1), short(p2), short(pa)))
 
-    action = {}
-    forget = []
+    action = []
 
     # update m1 from working dir
     umap = dict.fromkeys(unknown)
@@ -127,7 +126,7 @@ def update(repo, node, branchmerge=False
         # prevent the dirstate from listing the file when it is no
         # longer in the manifest.
         if linear_path and f not in m2:
-            forget.append(f)
+            action.append((f, "f"))
 
     if partial:
         for f in m1.keys():
@@ -146,31 +145,31 @@ def update(repo, node, branchmerge=False
                 # are both different from the ancestor?
                 if not overwrite and n != a and m2[f] != a:
                     repo.ui.debug(_(" %s versions differ, resolve\n") % f)
-                    action[f] = (fmerge(f, m1, m2, ma), n[:20], m2[f])
+                    action.append((f, "m", fmerge(f, m1, m2, ma), n[:20], m2[f]))
                     queued = 1
                 # are we clobbering?
                 # is remote's version newer?
                 # or are we going back in time and clean?
                 elif overwrite or m2[f] != a or (backwards and not n[20:]):
                     repo.ui.debug(_(" remote %s is newer, get\n") % f)
-                    action[f] = (m2.execf(f), m2[f], None)
+                    action.append((f, "g", m2.execf(f), m2[f]))
                     queued = 1
             elif n[20:] in ("u","a"):
                 # this unknown file is the same as the checkout
                 # we need to reset the dirstate if the file was added
-                action[f] = (m2.execf(f), m2[f], None)
+                action.append((f, "g", m2.execf(f), m2[f]))
 
             # do we still need to look at mode bits?
             if not queued and m1.execf(f) != m2.execf(f):
                 if overwrite:
                     repo.ui.debug(_(" updating permissions for %s\n") % f)
-                    util.set_exec(repo.wjoin(f), m2.execf(f))
+                    action.append((f, "e", m2.execf(f)))
                 else:
                     mode = fmerge(f, m1, m2, ma)
                     if mode != m1.execf(f):
                         repo.ui.debug(_(" updating permissions for %s\n")
                                       % f)
-                        util.set_exec(repo.wjoin(f), mode)
+                        action.append((f, "e", m2.execf(f)))
             del m2[f]
         elif f in ma:
             if n != ma[f]:
@@ -180,19 +179,19 @@ def update(repo, node, branchmerge=False
                         (_(" local changed %s which remote deleted\n") % f) +
                          _("(k)eep or (d)elete?"), _("[kd]"), _("k"))
                 if r == _("d"):
-                    action[f] = (None, None, None)
+                    action.append((f, "r"))
             else:
                 repo.ui.debug(_("other deleted %s\n") % f)
-                action[f] = (None, None, None)
+                action.append((f, "r"))
         else:
             # file is created on branch or in working directory
             if overwrite and n[20:] != "u":
                 repo.ui.debug(_("remote deleted %s, clobbering\n") % f)
-                action[f] = (None, None, None)
+                action.append((f, "r"))
             elif not n[20:]: # same as parent
                 if backwards:
                     repo.ui.debug(_("remote deleted %s\n") % f)
-                    action[f] = (None, None, None)
+                    action.append((f, "r"))
                 else:
                     repo.ui.debug(_("local modified %s, keeping\n") % f)
             else:
@@ -208,14 +207,14 @@ def update(repo, node, branchmerge=False
                     (_("remote changed %s which local deleted\n") % f) +
                      _("(k)eep or (d)elete?"), _("[kd]"), _("k"))
             if r == _("k"):
-                action[f] = (m2.execf(f), n, None)
+                action.append((f, "g", m2.execf(f), n))
         elif f not in ma:
             repo.ui.debug(_("remote created %s\n") % f)
-            action[f] = (m2.execf(f), n, None)
+            action.append((f, "g", m2.execf(f), n))
         else:
             if overwrite or backwards:
                 repo.ui.debug(_("local deleted %s, recreating\n") % f)
-                action[f] = (m2.execf(f), n, None)
+                action.append((f, "g", m2.execf(f), n))
             else:
                 repo.ui.debug(_("local deleted %s\n") % f)
 
@@ -236,13 +235,12 @@ def update(repo, node, branchmerge=False
 
     # update files
     updated, merged, removed, unresolved = 0, 0, 0, 0
-    files = action.keys()
-    files.sort()
-    for f in files:
-        flag, my, other = action[f]
+    action.sort()
+    for a in action:
+        f, m = a[:2]
         if f[0] == "/":
             continue
-        if not my:
+        if m == "r": # remove
             repo.ui.note(_("removing %s\n") % f)
             util.audit_path(f)
             try:
@@ -252,38 +250,43 @@ def update(repo, node, branchmerge=False
                     repo.ui.warn(_("update failed to remove %s: %s!\n") %
                                  (f, inst.strerror))
             removed +=1
-        elif other:
+        elif m == "m": # merge
+            flag, my, other = a[2:]
             repo.ui.status(_("merging %s\n") % f)
             if merge3(repo, f, my, other, xp1, xp2):
                 unresolved += 1
             util.set_exec(repo.wjoin(f), flag)
             merged += 1
-        else:
+        elif m == "g": # get
+            flag, node = a[2:]
             repo.ui.note(_("getting %s\n") % f)
-            t = repo.file(f).read(my)
+            t = repo.file(f).read(node)
             repo.wwrite(f, t)
             util.set_exec(repo.wjoin(f), flag)
             updated += 1
+        elif m == "e": # exec
+            flag = a[2:]
+            util.set_exec(repo.wjoin(f), flag)
 
     # update dirstate
     if not partial:
         repo.dirstate.setparents(p1, p2)
-        repo.dirstate.forget(forget)
-        files = action.keys()
-        files.sort()
-        for f in files:
-            flag, my, other = action[f]
-            if not my:
+        for a in action:
+            f, m = a[:2]
+            if m == "r": # remove
                 if branchmerge:
                     repo.dirstate.update([f], 'r')
                 else:
                     repo.dirstate.forget([f])
-            elif not other:
+            elif m == "f": # forget
+                repo.dirstate.forget([f])
+            elif m == "g": # get
                 if branchmerge:
                     repo.dirstate.update([f], 'n', st_mtime=-1)
                 else:
                     repo.dirstate.update([f], 'n')
-            else:
+            elif m == "m": # merge
+                flag, my, other = a[2:]
                 if branchmerge:
                     # We've done a branch merge, mark this file as merged
                     # so that we properly record the merger later