diff mercurial/exchange.py @ 37170:b837655c1509

streamclonebundle: make sure we accept new stream clone bundle spec When asked specifically, the code do a sanity check on the clone bundle to ensure it's a stream bundle. As we introduced a new stream bundle spec, update the logic to support it. With this final changeset, we can now announce safely a stream v2 clone bundle and old clients would not crash trying to process it. This changeset address the last comment from Gregory Szorc on the stream v2 bundle series. Differential Revision: https://phab.mercurial-scm.org/D1957
author Boris Feld <boris.feld@octobus.net>
date Wed, 31 Jan 2018 17:15:44 +0100
parents a2b350d9f6ae
children f7d3915d5b3a
line wrap: on
line diff
--- a/mercurial/exchange.py	Wed Jan 31 11:44:33 2018 +0100
+++ b/mercurial/exchange.py	Wed Jan 31 17:15:44 2018 +0100
@@ -2180,6 +2180,18 @@
 
     return m
 
+def isstreamclonespec(bundlespec):
+    # Stream clone v1
+    if (bundlespec.compression == 'UN' and bundlespec.version == 's1'):
+        return True
+
+    # Stream clone v2
+    if (bundlespec.compression == 'UN' and bundlespec.version == '02' and \
+        bundlespec.contentopts.get('streamv2')):
+        return True
+
+    return False
+
 def filterclonebundleentries(repo, entries, streamclonerequested=False):
     """Remove incompatible clone bundle manifest entries.
 
@@ -2199,9 +2211,7 @@
 
                 # If a stream clone was requested, filter out non-streamclone
                 # entries.
-                comp = bundlespec.compression
-                version = bundlespec.version
-                if streamclonerequested and (comp != 'UN' or version != 's1'):
+                if streamclonerequested and not isstreamclonespec(bundlespec):
                     repo.ui.debug('filtering %s because not a stream clone\n' %
                                   entry['URL'])
                     continue