changeset 40664:dba590f27c7a

changegroup: avoid instantiating storage if we are not using it Differential Revision: https://phab.mercurial-scm.org/D5280
author Kyle Lippincott <spectral@google.com>
date Thu, 15 Nov 2018 11:16:42 -0800
parents c53f0ead5781
children fb379b78b93e
files mercurial/changegroup.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Fri Nov 16 17:56:36 2018 -0500
+++ b/mercurial/changegroup.py	Thu Nov 15 11:16:42 2018 -0800
@@ -1043,18 +1043,25 @@
 
         while tmfnodes:
             tree, nodes = tmfnodes.popitem()
+
+            should_visit = self._matcher.visitdir(tree[:-1] or '.')
+            if tree and not should_visit:
+                continue
+
             store = mfl.getstorage(tree)
 
-            if not self._matcher.visitdir(store.tree[:-1] or '.'):
+            if not should_visit:
                 # No nodes to send because this directory is out of
                 # the client's view of the repository (probably
-                # because of narrow clones).
+                # because of narrow clones). Do this even for the root
+                # directory (tree=='')
                 prunednodes = []
             else:
                 # Avoid sending any manifest nodes we can prove the
                 # client already has by checking linkrevs. See the
                 # related comment in generatefiles().
                 prunednodes = self._prunemanifests(store, nodes, commonrevs)
+
             if tree and not prunednodes:
                 continue