D4783: narrow: add 'narrowstream' server capability to use streamclones with narrow
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 patch adds a new server capability "narrowstream" which will dictate
whether the server is capable of serving narrow-stream clones or not.
This also add support for getting include and exclude arguments as part of
stream_out wireprotocol call. We don't use those arguments yet, but we will use
in future.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4783
AFFECTED FILES
mercurial/configitems.py
mercurial/help/config.txt
mercurial/wireprotov1server.py
tests/test-http-bundle1.t
CHANGE DETAILS
diff --git a/tests/test-http-bundle1.t b/tests/test-http-bundle1.t
--- a/tests/test-http-bundle1.t
+++ b/tests/test-http-bundle1.t
@@ -297,7 +297,7 @@
"GET /?cmd=capabilities HTTP/1.1" 401 - (no-reposimplestore !)
"GET /?cmd=capabilities HTTP/1.1" 200 - (no-reposimplestore !)
"GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
- "GET /?cmd=stream_out HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
+ "GET /?cmd=stream_out HTTP/1.1" 200 - x-hgarg-1:excludes=&includes= x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
"GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
"GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D5fed3813f7f5e1824344fdc9cf8f63bb662c292d x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
"GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -286,6 +286,9 @@
caps.append('bundle2=' + urlreq.quote(capsblob))
caps.append('unbundle=%s' % ','.join(bundle2.bundlepriority))
+ if repo.ui.configbool('server', 'stream-narrow-clones'):
+ caps.append('narrowstream')
+
return proto.addcapabilities(repo, caps)
# If you are writing an extension and consider wrapping this function. Wrap
@@ -535,12 +538,17 @@
output = output.getvalue() if output else ''
return wireprototypes.bytesresponse('%d\n%s' % (int(r), output))
- at wireprotocommand('stream_out', permission='pull')
-def stream(repo, proto):
+ at wireprotocommand('stream_out', '*', permission='pull')
+def stream(repo, proto, args):
'''If the server supports streaming clone, it advertises the "stream"
capability with a value representing the version and flags of the repo
it is serving. Client checks to see if it understands the format.
'''
+ includes = None
+ excludes = None
+ if 'narrowstream' in _capabilities(repo, proto):
+ includes = args.get('includes')
+ excludes = args.get('excludes')
return wireprototypes.streamreslegacy(
streamclone.generatev1wireproto(repo))
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1839,6 +1839,10 @@
Older Mercurial clients only support zlib compression and this setting
has no effect for legacy clients.
+``stream-narrow-clones``
+ Whether the server supports streaming narrow clones or not.
+ (default: False)
+
``uncompressed``
Whether to allow clients to clone a repository using the
uncompressed streaming protocol. This transfers about 40% more
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -991,6 +991,9 @@
coreconfigitem('server', 'streamunbundle',
default=False,
)
+coreconfigitem('server', 'stream-narrow-clones',
+ default=False,
+)
coreconfigitem('server', 'uncompressed',
default=True,
)
To: pulkit, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list