Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireprotov1server.py @ 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 | 2aaabd8f4471 |
children | d718eddf01d9 |
line wrap: on
line diff
--- 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 = [