changeset 27244:709977a4fc9d

exchange: standalone function to determine if bundle2 is requested This will be used in a subsequent patch.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 04 Dec 2015 13:31:01 -0800
parents 3abee2ba27af
children b288fb2724bf
files mercurial/exchange.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Fri Dec 04 13:15:14 2015 -0800
+++ b/mercurial/exchange.py	Fri Dec 04 13:31:01 2015 -0800
@@ -1421,6 +1421,11 @@
         return func
     return dec
 
+def bundle2requested(bundlecaps):
+    if bundlecaps is not None:
+        return any(cap.startswith('HG2') for cap in bundlecaps)
+    return False
+
 def getbundle(repo, source, heads=None, common=None, bundlecaps=None,
               **kwargs):
     """return a full bundle (with potentially multiple kind of parts)
@@ -1436,10 +1441,8 @@
     The implementation is at a very early stage and will get massive rework
     when the API of bundle is refined.
     """
+    usebundle2 = bundle2requested(bundlecaps)
     # bundle10 case
-    usebundle2 = False
-    if bundlecaps is not None:
-        usebundle2 = any((cap.startswith('HG2') for cap in bundlecaps))
     if not usebundle2:
         if bundlecaps and not kwargs.get('cg', True):
             raise ValueError(_('request for bundle10 must include changegroup'))