bundle2: add a devel option controling bundle version used for exchange
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 02 Aug 2016 14:48:21 +0200
changeset 29683 6786c3f8684d
parent 29682 2db085d5f5a2
child 29684 ff5d5751fc1b
bundle2: add a devel option controling bundle version used for exchange We need an official way to force bundle1 to be used in test. We introduce a new option 'devel.legacy.exchange' to control this. When specified, this option will control the list of bundle version Mercurial consider when exchanging with a peer. Current valid value are 'bundle1' and 'bundle2'. Using this option in all tests will allow us to remove the 'experimental.bundle2-exp' option. We will simplify the code once the experimental option is dropped.
mercurial/exchange.py
--- a/mercurial/exchange.py	Wed Aug 03 15:01:23 2016 +0200
+++ b/mercurial/exchange.py	Tue Aug 02 14:48:21 2016 +0200
@@ -260,10 +260,23 @@
 def _forcebundle1(op):
     """return true if a pull/push must use bundle1
 
-    Feel free to nuke this function when we drop the experimental option"""
-    return not (op.repo.ui.configbool('experimental', 'bundle2-exp', True)
-                and op.remote.capable('bundle2'))
+    This function is used to allow testing of the older bundle version"""
+    ui = op.repo.ui
+    forcebundle1 = False
+    # The goal is this config is to allow developper to choose the bundle
+    # version used during exchanged. This is especially handy during test.
+    # Value is a list of bundle version to be picked from, highest version
+    # should be used.
+    #
+    # developer config: devel.legacy.exchange
+    exchange = ui.configlist('devel', 'legacy.exchange')
+    if not exchange:
+        forcebundle1 = not ui.configbool('experimental', 'bundle2-exp', True)
+        # developer config: devel.legacy.exchange
+    else:
+        forcebundle1 = 'bundle2' not in exchange and 'bundle1' in exchange
 
+    return forcebundle1 or not op.remote.capable('bundle2')
 
 class pushoperation(object):
     """A object that represent a single push operation