diff mercurial/exchange.py @ 31483:291951ad070b

merge with stable
author Augie Fackler <augie@google.com>
date Sat, 18 Mar 2017 12:27:52 -0400
parents 455677a7667f 10c0ee338535
children 282b288aa20c 9d6031df42c8
line wrap: on
line diff
--- a/mercurial/exchange.py	Sun Mar 05 22:22:32 2017 -0500
+++ b/mercurial/exchange.py	Sat Mar 18 12:27:52 2017 -0400
@@ -44,6 +44,9 @@
                          'bundle2': '02', #legacy
                         }
 
+# Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE.
+_bundlespecv1compengines = set(['gzip', 'bzip2', 'none'])
+
 def parsebundlespec(repo, spec, strict=True, externalnames=False):
     """Parse a bundle string specification into parts.
 
@@ -127,8 +130,12 @@
         if spec in util.compengines.supportedbundlenames:
             compression = spec
             version = 'v1'
+            # Generaldelta repos require v2.
             if 'generaldelta' in repo.requirements:
                 version = 'v2'
+            # Modern compression engines require v2.
+            if compression not in _bundlespecv1compengines:
+                version = 'v2'
         elif spec in _bundlespeccgversions:
             if spec == 'packed1':
                 compression = 'none'
@@ -139,6 +146,12 @@
             raise error.UnsupportedBundleSpecification(
                     _('%s is not a recognized bundle specification') % spec)
 
+    # Bundle version 1 only supports a known set of compression engines.
+    if version == 'v1' and compression not in _bundlespecv1compengines:
+        raise error.UnsupportedBundleSpecification(
+            _('compression engine %s is not supported on v1 bundles') %
+            compression)
+
     # The specification for packed1 can optionally declare the data formats
     # required to apply it. If we see this metadata, compare against what the
     # repo supports and error if the bundle isn't compatible.