Mercurial > hg-stable
changeset 50701:4238e6b22fc4
clonebundles: introduce a new write protocol command
The old wire command does not take argument so we need a new command. We make
that new command take argument to prepare it for the future (like narrow
support).
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 19 Jun 2023 15:49:35 +0200 |
parents | f4e8c82e2cef |
children | b11421f3daf9 |
files | hgext/clonebundles.py mercurial/wireprotov1peer.py mercurial/wireprotov1server.py tests/test-clonebundles.t tests/test-stream-bundle-v2.t |
diffstat | 5 files changed, 33 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/clonebundles.py Mon Jun 19 11:28:45 2023 +0200 +++ b/hgext/clonebundles.py Mon Jun 19 15:49:35 2023 +0200 @@ -324,6 +324,7 @@ # missing file. if repo.vfs.exists(bundlecaches.CB_MANIFEST_FILE): caps.append(b'clonebundles') + caps.append(b'clonebundles_manifest') return caps
--- a/mercurial/wireprotov1peer.py Mon Jun 19 11:28:45 2023 +0200 +++ b/mercurial/wireprotov1peer.py Mon Jun 19 15:49:35 2023 +0200 @@ -338,8 +338,11 @@ # 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
--- a/mercurial/wireprotov1server.py Mon Jun 19 11:28:45 2023 +0200 +++ b/mercurial/wireprotov1server.py Mon Jun 19 15:49:35 2023 +0200 @@ -301,6 +301,23 @@ @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 @@ 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 = [
--- a/tests/test-clonebundles.t Mon Jun 19 11:28:45 2023 +0200 +++ b/tests/test-clonebundles.t Mon Jun 19 15:49:35 2023 +0200 @@ -258,17 +258,16 @@ 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 @@ $ 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 @@ $ 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
--- a/tests/test-stream-bundle-v2.t Mon Jun 19 11:28:45 2023 +0200 +++ b/tests/test-stream-bundle-v2.t Mon Jun 19 15:49:35 2023 +0200 @@ -90,7 +90,7 @@ $ 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 @@ $ 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 !)