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, ) 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/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)) -@wireprotocommand('stream_out', permission='pull') -def stream(repo, proto): +@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/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 !)