revert: remove set(mf) because it's O(manifest)
authorDurham Goode <durham@fb.com>
Wed, 01 Mar 2017 19:51:05 -0800
changeset 31134 c22253c4c1b8
parent 31133 23080c03a604
child 31140 dc8996f855d9
revert: remove set(mf) because it's O(manifest) The revert code had a 'set(manifest)' line in it, which has a runtime equivalent to the size of the manifest. With alternative manifest implementations, like treemanifest, this can be extra expensive. Let's rewrite it to be O(changes) instead of O(manifest size).
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Mon Feb 13 14:05:24 2017 +0100
+++ b/mercurial/cmdutil.py	Wed Mar 01 19:51:05 2017 -0800
@@ -2976,11 +2976,11 @@
         clean    = set(changes.clean)
         modadded = set()
 
-        # split between files known in target manifest and the others
-        smf = set(mf)
-
         # determine the exact nature of the deleted changesets
-        deladded = _deleted - smf
+        deladded = set(_deleted)
+        for path in _deleted:
+            if path in mf:
+                deladded.remove(path)
         deleted = _deleted - deladded
 
         # We need to account for the state of the file in the dirstate,
@@ -3024,7 +3024,10 @@
         # in case of merge, files that are actually added can be reported as
         # modified, we need to post process the result
         if p2 != nullid:
-            mergeadd = dsmodified - smf
+            mergeadd = set(dsmodified)
+            for path in dsmodified:
+                if path in mf:
+                    mergeadd.remove(path)
             dsadded |= mergeadd
             dsmodified -= mergeadd