Patchwork [6,of,6] treemanifest: make filesnotin() faster

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 11, 2015, 4:23 a.m.
Message ID <4ebfeb027ce588a72347.1426047818@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7994/
State Superseded
Commit cbe9d50d9e650490fb6942a8ff7f0ab64a99166f
Headers show

Comments

Martin von Zweigbergk - March 11, 2015, 4:23 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1425419406 28800
#      Tue Mar 03 13:50:06 2015 -0800
# Node ID 4ebfeb027ce588a72347788c8c23b2318d8fb6d3
# Parent  3ef6789854aac9bd1c36a630155a1242edef6a6d
treemanifest: make filesnotin() faster

Same rationale as the previous change.

Patch

diff -r 3ef6789854aa -r 4ebfeb027ce5 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
@@ -463,8 +463,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
 
     def matches(self, match):