D4873: treemanifests: extract _loaddifflazy from _diff, use in _filesnotin

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Wed Oct 3 22:22:40 UTC 2018


spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4873

AFFECTED FILES
  mercurial/manifest.py

CHANGE DETAILS

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -724,6 +724,28 @@
             loadlazy(k + '/')
         return visit
 
+    def _loaddifflazy(self, t1, t2):
+        """load items in t1 and t2 if they're needed for diffing.
+
+        The criteria currently is:
+        - if it's not present in _lazydirs in either t1 or t2, load it in the
+          other (it may already be loaded or it may not exist, doesn't matter)
+        - if it's present in _lazydirs in both, compare the nodeid; if it
+          differs, load it in both
+        """
+        toloadlazy = []
+        for d, v1 in t1._lazydirs.iteritems():
+            v2 = t2._lazydirs.get(d)
+            if not v2 or v2[1] != v1[1]:
+                toloadlazy.append(d)
+        for d, v1 in t2._lazydirs.iteritems():
+            if d not in t1._lazydirs:
+                toloadlazy.append(d)
+
+        for d in toloadlazy:
+            t1._loadlazy(d)
+            t2._loadlazy(d)
+
     def __len__(self):
         self._load()
         size = len(self._files)
@@ -957,8 +979,7 @@
                 return
             t1._load()
             t2._load()
-            t1._loadalllazy()
-            t2._loadalllazy()
+            self._loaddifflazy(t1, t2)
             for d, m1 in t1._dirs.iteritems():
                 if d in t2._dirs:
                     m2 = t2._dirs[d]
@@ -1113,18 +1134,7 @@
                 return
             t1._load()
             t2._load()
-            toloadlazy = []
-            for d, v1 in t1._lazydirs.iteritems():
-                v2 = t2._lazydirs.get(d)
-                if not v2 or v2[1] != v1[1]:
-                    toloadlazy.append(d)
-            for d, v1 in t2._lazydirs.iteritems():
-                if d not in t1._lazydirs:
-                    toloadlazy.append(d)
-
-            for d in toloadlazy:
-                t1._loadlazy(d)
-                t2._loadlazy(d)
+            self._loaddifflazy(t1, t2)
 
             for d, m1 in t1._dirs.iteritems():
                 m2 = t2._dirs.get(d, emptytree)



To: spectral, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list