streamclone: pass narrowing related info in _walkstreamfiles()
authorPulkit Goyal <pulkit@yandex-team.ru>
Wed, 03 Oct 2018 17:59:05 +0300
changeset 40339 f0e8f27768eb
parent 40338 af62936c2508
child 40340 2d45b549392f
streamclone: pass narrowing related info in _walkstreamfiles() This patch build a matcher using the include and exclude arguments we have in generatev2() and pass that matcher into _walkstreamfiles(). This will help us in filtering files we stream depending on the includes and excludes passed in by the user. Differential Revision: https://phab.mercurial-scm.org/D4851
mercurial/streamclone.py
--- a/mercurial/streamclone.py	Wed Sep 26 17:20:04 2018 +0300
+++ b/mercurial/streamclone.py	Wed Oct 03 17:59:05 2018 +0300
@@ -16,6 +16,7 @@
     branchmap,
     cacheutil,
     error,
+    narrowspec,
     phases,
     pycompat,
     repository,
@@ -194,8 +195,8 @@
     return True
 
 # This is it's own function so extensions can override it.
-def _walkstreamfiles(repo):
-    return repo.store.walk()
+def _walkstreamfiles(repo, matcher=None):
+    return repo.store.walk(matcher)
 
 def generatev1(repo):
     """Emit content for version 1 of a streaming clone.
@@ -553,8 +554,12 @@
         entries = []
         totalfilesize = 0
 
+        matcher = None
+        if includes or excludes:
+            matcher = narrowspec.match(repo.root, includes, excludes)
+
         repo.ui.debug('scanning\n')
-        for name, ename, size in _walkstreamfiles(repo):
+        for name, ename, size in _walkstreamfiles(repo, matcher):
             if size:
                 entries.append((_srcstore, name, _fileappend, size))
                 totalfilesize += size