D4784: streamclone: pass includes and excludes to stream_out wireprotocol cmd

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Thu Sep 27 20:27:12 UTC 2018


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

REVISION SUMMARY
  This adds client side logic to pass includes and excludes to the stream_out()
  wireprotocol command. Tests are not added because there is not server side logic
  yet to filter out data to stream.
  
  1. no-check-commit because it touches a function with foo_bar naming

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/streamclone.py
  mercurial/wireprotov1peer.py

CHANGE DETAILS

diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -409,8 +409,10 @@
             self.ui.status(_('remote: '), l)
         yield d
 
-    def stream_out(self):
-        return self._callstream('stream_out')
+    def stream_out(self, includes=[], excludes=[]):
+        i = wireprototypes.encodelist(includes)
+        e = wireprototypes.encodelist(excludes)
+        return self._callstream('stream_out', includes=i, excludes=e)
 
     def getbundle(self, source, **kwargs):
         kwargs = pycompat.byteskwargs(kwargs)
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -132,8 +132,19 @@
 
     repo.ui.status(_('streaming all changes\n'))
 
+    narrowsupport = (remote.capable('narrowstream') and
+                     remote.capable('exp-narrow-1'))
+    if (pullop.includepats or pullop.excludepats) and not narrowsupport:
+        repo.ui.status(_('server does not support narrow stream clones, cloning'
+                         ' full repository\n'))
     with remote.commandexecutor() as e:
-        fp = e.callcommand('stream_out', {}).result()
+        if narrowsupport:
+            args = {}
+            args['includes'] = pullop.includepats
+            args['excludes'] = pullop.excludepats
+            fp = e.callcommand('stream_out', args).result()
+        else:
+            fp = e.callcommand('stream_out', {}).result()
 
     # TODO strictly speaking, this code should all be inside the context
     # manager because the context manager is supposed to ensure all wire state



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


More information about the Mercurial-devel mailing list