[PATCH 7 of 8] exchange: use getchangegroupchunks()
Gregory Szorc
gregory.szorc at gmail.com
Thu Aug 4 23:17:03 EDT 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1470364829 25200
# Thu Aug 04 19:40:29 2016 -0700
# Node ID 4c9b71d4c61cf99cd75469bff7d58bf0b2241bdd
# Parent 0270c4c4c1aef296d0405950a34bdef3aaa01f30
exchange: use getchangegroupchunks()
changegroup.getlocalchangegroupraw() is a one-liner that calls
getchangegroupchunks(). exchange.py is the only caller of this
function. Let's refactor exchange.py to use the new generic API.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -713,20 +713,22 @@ def _pushb2ctx(pushop, bundler):
cgversions = b2caps.get('changegroup')
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)
- cgpart = bundler.newpart('changegroup', data=cg)
+
+ chunks = changegroup.getchangegroupchunks(pushop.repo,
+ pushop.outgoing,
+ version,
+ 'push')[1]
+ cgpart = bundler.newpart('changegroup', data=chunks)
if cgversions:
cgpart.addparam('version', version)
if 'treemanifest' in pushop.repo.requirements:
cgpart.addparam('treemanifest', '1')
def handlereply(op):
"""extract addchangegroup returns from server reply"""
cgreplies = op.records.getreplies(cgpart.id)
assert len(cgreplies['changegroup']) == 1
@@ -1568,24 +1570,23 @@ def _getbundlechangegrouppart(bundler, r
cgversions = b2caps.get('changegroup')
if cgversions: # 3.1 and 3.2 ship with an empty value
cgversions = [v for v in cgversions
if v in changegroup.supportedoutgoingversions(repo)]
if not cgversions:
raise ValueError(_('no common changegroup version'))
version = max(cgversions)
outgoing = discovery.outgoingheadsandcommon(repo, heads, common)
- cg = changegroup.getlocalchangegroupraw(repo, source, outgoing,
- bundlecaps=bundlecaps,
- version=version)
-
- if not cg:
+ chunks = changegroup.getchangegroupchunks(repo, outgoing,
+ version, source,
+ bundlecaps=bundlecaps)[1]
+ if not chunks:
return
- part = bundler.newpart('changegroup', data=cg)
+ part = bundler.newpart('changegroup', data=chunks)
if cgversions:
part.addparam('version', version)
part.addparam('nbchanges', str(len(outgoing.missing)), mandatory=False)
if 'treemanifest' in repo.requirements:
part.addparam('treemanifest', '1')
@getbundle2partsgenerator('listkeys')
def _getbundlelistkeysparts(bundler, repo, source, bundlecaps=None,
More information about the Mercurial-devel
mailing list