# HG changeset patch
# User Gregory Szorc <gregory.sz...@gmail.com>
# Date 1489692795 25200
#      Thu Mar 16 12:33:15 2017 -0700
# Branch stable
# Node ID 35019434aad6952ee9b3b41ee78a5a3efea9a0ab
# Parent  8fed20619acd7a4346408e5819a1c91c52a39ed2
exchange: use v2 bundles for modern compression engines (issue5506)

Previously, `hg bundle zstd` on a non-generaldelta repo would
attempt to use a v1 bundle. This would fail because zstd is not
supported on v1 bundles.

This patch changes the behavior to automatically use a v2 bundle
when the user explicitly requests a bundlespec that is a compression
engine not supported on v1. If the bundlespec is <engine>-v1, it is
still explicitly rejected because that request cannot be fulfilled.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -130,8 +130,12 @@ def parsebundlespec(repo, spec, strict=T
         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'
diff --git a/tests/test-bundle-type.t b/tests/test-bundle-type.t
--- a/tests/test-bundle-type.t
+++ b/tests/test-bundle-type.t
@@ -187,9 +187,7 @@ Explicit request for zstd on non-general
   $ hg --config format.usegeneraldelta=false init nogd
   $ hg -q -R nogd pull t1
   $ hg -R nogd bundle -a -t zstd nogd-zstd
-  abort: compression engine zstd is not supported on v1 bundles
-  (see 'hg help bundle' for supported values for --type)
-  [255]
+  1 changesets found
 
 zstd-v1 always fails
 
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to