# HG changeset patch # User Gregory Szorc # Date 1449264661 28800 # Node ID 709977a4fc9dadb2964497d16f678603e5e37d69 # Parent 3abee2ba27afe20911ecab59a00aa8528b979284 exchange: standalone function to determine if bundle2 is requested This will be used in a subsequent patch. diff -r 3abee2ba27af -r 709977a4fc9d mercurial/exchange.py --- 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'))