exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
The functions already have a lot in common, but were structured a
little differently.
--- a/mercurial/exchange.py Fri Mar 25 16:01:40 2016 -0700
+++ b/mercurial/exchange.py Fri Mar 25 16:13:28 2016 -0700
@@ -701,23 +701,20 @@
_pushb2ctxcheckheads(pushop, bundler)
b2caps = bundle2.bundle2caps(pushop.remote)
- version = None
+ version = '01'
cgversions = b2caps.get('changegroup')
- if not cgversions: # 3.1 and 3.2 ship with an empty value
- cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push',
- pushop.outgoing)
- else:
+ if cgversions: # 3.1 and 3.2 ship with an empty value
cgversions = [v for v in cgversions
if v in changegroup.supportedoutgoingversions(
pushop.repo)]
if not cgversions:
raise ValueError(_('no common changegroup version'))
version = max(cgversions)
- cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push',
- pushop.outgoing,
- version=version)
+ cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push',
+ pushop.outgoing,
+ version=version)
cgpart = bundler.newpart('changegroup', data=cg)
- if version is not None:
+ if cgversions:
cgpart.addparam('version', version)
if 'treemanifest' in pushop.repo.requirements:
cgpart.addparam('treemanifest', '1')