merge: reduce manifest copying
authorMatt Mackall <mpm@selenic.com>
Wed, 04 Oct 2006 14:33:22 -0500
changeset 3248 751840e739a1
parent 3247 7a0d70b69d74
child 3249 f05c182430a0
merge: reduce manifest copying
mercurial/merge.py
--- a/mercurial/merge.py	Wed Oct 04 14:09:26 2006 -0500
+++ b/mercurial/merge.py	Wed Oct 04 14:33:22 2006 -0500
@@ -164,12 +164,7 @@
 
     return copy
 
-def filtermanifest(man, partial):
-    if partial:
-        for k in man.keys():
-            if not partial(k): del man[k]
-
-def manifestmerge(ui, m1, m2, ma, overwrite, backwards):
+def manifestmerge(ui, m1, m2, ma, overwrite, backwards, partial):
     """
     Merge manifest m1 with m2 using ancestor ma and generate merge action list
     """
@@ -187,6 +182,8 @@
 
     # Compare manifests
     for f, n in m1.iteritems():
+        if partial and not partial(f):
+            continue
         if f in m2:
             # are files different?
             if n != m2[f]:
@@ -206,7 +203,6 @@
             elif m1.execf(f) != m2.execf(f):
                 if overwrite or fmerge(f) != m1.execf(f):
                     act("update permissions", f, "e", m2.execf(f))
-            del m2[f]
         elif f in ma:
             if n != ma[f] and not overwrite:
                 if ui.prompt(
@@ -221,6 +217,10 @@
                 act("remote deleted", f, "r")
 
     for f, n in m2.iteritems():
+        if partial and not partial(f):
+            continue
+        if f in m1:
+            continue
         if f in ma:
             if overwrite or backwards:
                 act("recreating", f, "g", m2.execf(f), n)
@@ -337,8 +337,8 @@
         if wc.modified() or wc.added() or wc.removed():
             raise util.Abort(_("outstanding uncommitted changes"))
 
-    m1 = wc.manifest().copy()
-    m2 = p2.manifest().copy()
+    m1 = wc.manifest()
+    m2 = p2.manifest()
     ma = pa.manifest()
 
     # resolve the manifest to determine which files
@@ -351,9 +351,6 @@
     action = []
     copy = {}
 
-    filtermanifest(m1, partial)
-    filtermanifest(m2, partial)
-
     if not force:
         checkunknown(repo, m2, wc)
     if not branchmerge:
@@ -361,8 +358,7 @@
     if not (backwards or overwrite):
         copy = findcopies(repo, m1, m2, pa.rev())
 
-    action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards)
-    del m1, m2, ma
+    action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards, partial)
 
     ### apply phase