diff --git a/hgext/clonebundles.py b/hgext/clonebundles.py --- a/hgext/clonebundles.py +++ b/hgext/clonebundles.py @@ -324,6 +324,7 @@ def capabilities(orig, repo, proto): # missing file. if repo.vfs.exists(bundlecaches.CB_MANIFEST_FILE): caps.append(b'clonebundles') + caps.append(b'clonebundles_manifest') return caps diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py --- a/mercurial/wireprotov1peer.py +++ b/mercurial/wireprotov1peer.py @@ -338,8 +338,11 @@ class wirepeer(repository.peer): # Begin of ipeercommands interface. def clonebundles(self): - self.requirecap(b'clonebundles', _(b'clone bundles')) - return self._call(b'clonebundles') + if self.capable(b'clonebundles_manifest'): + return self._call(b'clonebundles_manifest') + else: + self.requirecap(b'clonebundles', _(b'clone bundles')) + return self._call(b'clonebundles') def _finish_inline_clone_bundle(self, stream): pass # allow override for httppeer diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py --- a/mercurial/wireprotov1server.py +++ b/mercurial/wireprotov1server.py @@ -301,6 +301,23 @@ def get_cached_bundle_inline(repo, proto @wireprotocommand(b'clonebundles', b'', permission=b'pull') def clonebundles(repo, proto): + """A legacy version of clonebundles_manifest + + This version filtered out new url scheme (like peer-bundle-cache://) to + avoid confusion in older clients. + """ + manifest_contents = bundlecaches.get_manifest(repo) + # Filter out peer-bundle-cache:// entries + modified_manifest = [] + for line in manifest_contents.splitlines(): + if line.startswith(bundlecaches.CLONEBUNDLESCHEME): + continue + modified_manifest.append(line) + return wireprototypes.bytesresponse(b'\n'.join(modified_manifest)) + + +@wireprotocommand(b'clonebundles_manifest', b'*', permission=b'pull') +def clonebundles_2(repo, proto, args): """Server command for returning info for available bundles to seed clones. Clients will parse this response and determine what bundle to fetch. @@ -314,15 +331,7 @@ def clonebundles(repo, proto): Otherwise, older clients would retrieve and error out on those. """ manifest_contents = bundlecaches.get_manifest(repo) - clientcapabilities = proto.getprotocaps() - if b'inlineclonebundles' in clientcapabilities: - return wireprototypes.bytesresponse(manifest_contents) - modified_manifest = [] - for line in manifest_contents.splitlines(): - if line.startswith(bundlecaches.CLONEBUNDLESCHEME): - continue - modified_manifest.append(line) - return wireprototypes.bytesresponse(b'\n'.join(modified_manifest)) + return wireprototypes.bytesresponse(manifest_contents) wireprotocaps = [ diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t --- a/tests/test-clonebundles.t +++ b/tests/test-clonebundles.t @@ -258,17 +258,16 @@ Feature works over SSH with inline bundl HTTP Supports ------------- -Or lack of it actually - -Feature does not use inline bundle over HTTP(S) because there is no protocaps support -(so no way for the client to announce that it supports inline clonebundles) $ hg clone -U http://localhost:$HGPORT http-inline-clone - requesting all changes + applying clone bundle from peer-bundle-cache://full.hg adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 2 files - new changesets 53245c60e682:aaff8d2ffbbf + finished applying clone bundle + searching for changes + no changes found + 2 local changesets published Pre-transmit Hook ----------------- @@ -657,7 +656,7 @@ on a 32MB system. $ hg clone -U --debug --config ui.available-memory=16MB http://localhost:$HGPORT gzip-too-large using http://localhost:$HGPORT/ sending capabilities command - sending clonebundles command + sending clonebundles_manifest command filtering http://localhost:$HGPORT1/gz-a.hg as it needs more than 2/3 of system memory no compatible clone bundles available on server; falling back to regular clone (you may want to report this to the server operator) @@ -690,7 +689,7 @@ on a 32MB system. $ hg clone -U --debug --config ui.available-memory=32MB http://localhost:$HGPORT gzip-too-large2 using http://localhost:$HGPORT/ sending capabilities command - sending clonebundles command + sending clonebundles_manifest command applying clone bundle from http://localhost:$HGPORT1/gz-a.hg bundle2-input-bundle: 1 params with-transaction bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported diff --git a/tests/test-stream-bundle-v2.t b/tests/test-stream-bundle-v2.t --- a/tests/test-stream-bundle-v2.t +++ b/tests/test-stream-bundle-v2.t @@ -90,7 +90,7 @@ Test that we can apply the bundle as a s $ hg clone http://localhost:$HGPORT stream-clone-implicit --debug using http://localhost:$HGPORT/ sending capabilities command - sending clonebundles command + sending clonebundles_manifest command applying clone bundle from http://localhost:$HGPORT1/bundle.hg bundle2-input-bundle: with-transaction bundle2-input-part: "stream2" (params: 3 mandatory) supported (stream-v2 !) @@ -148,7 +148,7 @@ Test that we can apply the bundle as a s $ hg clone --stream http://localhost:$HGPORT stream-clone-explicit --debug using http://localhost:$HGPORT/ sending capabilities command - sending clonebundles command + sending clonebundles_manifest command applying clone bundle from http://localhost:$HGPORT1/bundle.hg bundle2-input-bundle: with-transaction bundle2-input-part: "stream2" (params: 3 mandatory) supported (stream-v2 !)