[PATCH 2 of 3] exchange: standalone function to determine if bundle2 is requested

Gregory Szorc gregory.szorc at gmail.com
Fri Dec 4 17:21:00 CST 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1449264661 28800
#      Fri Dec 04 13:31:01 2015 -0800
# Node ID 5acc4e2032fc698dc529b31b13a65541767ebecb
# Parent  7ae3d0f3e3a4612b44cd4512a6e44ed0da1fb712
exchange: standalone function to determine if bundle2 is requested

This will be used in a subsequent patch.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1420,8 +1420,13 @@ def getbundle2partsgenerator(stepname, i
             getbundle2partsorder.insert(idx, stepname)
         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)
 
@@ -1435,12 +1440,10 @@ def getbundle(repo, source, heads=None, 
 
     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'))
 


More information about the Mercurial-devel mailing list