[PATCH 4 of 5 V2] treemanifest: make filesnotin() faster

Martin von Zweigbergk martinvonz at google.com
Mon Mar 16 18:27:10 CDT 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1425419406 28800
#      Tue Mar 03 13:50:06 2015 -0800
# Node ID cee77fda8c7108824307f1750aafcdd76f3409a2
# Parent  f2b1de4e1c9b70a2f1f4298f61c3a60e38f4bfef
treemanifest: make filesnotin() faster

Same rationale as the previous change.

diff -r f2b1de4e1c9b -r cee77fda8c71 mercurial/manifest.py
--- a/mercurial/manifest.py	Thu Feb 19 17:13:35 2015 -0800
+++ b/mercurial/manifest.py	Tue Mar 03 13:50:06 2015 -0800
@@ -482,8 +482,20 @@
 
     def filesnotin(self, m2):
         '''Set of files in this manifest that are not in the other'''
-        files = set(self.iterkeys())
-        files.difference_update(m2.iterkeys())
+        files = set()
+        def _filesnotin(t1, t2):
+            for d, m1 in t1._dirs.iteritems():
+                if d in t2._dirs:
+                    m2 = t2._dirs[d]
+                    _filesnotin(m1, m2)
+                else:
+                    files.update(m1.iterkeys())
+
+            for fn in t1._files.iterkeys():
+                if fn not in t2._files:
+                    files.add(t1._subpath(fn))
+
+        _filesnotin(self, m2)
         return files
 
     @propertycache


More information about the Mercurial-devel mailing list