treemanifest: refactor pack part creation to its own function

Summary:
A future patch will use this same logic to create pack parts, so let's make it
reusable.

Test Plan: Ran the tests

Reviewers: #mercurial, mitrandir

Reviewed By: mitrandir

Subscribers: medson, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5326175

Signature: t1:5326175:1498751898:bf71081ab6309aa48c5ccadfd7e46d7d67588367
This commit is contained in:
Durham Goode 2017-07-10 15:53:12 -07:00
parent 0a0ba996ea
commit 0ce2a60ef6

View File

@ -780,26 +780,34 @@ def _registerbundle2parts():
return return
pushop.stepsdone.add('treepack') pushop.stepsdone.add('treepack')
part = createtreepackpart(pushop.repo, pushop.outgoing,
TREEGROUP_PARTTYPE2)
bundler.addpart(part)
def createtreepackpart(repo, outgoing, partname):
rootdir = '' rootdir = ''
mfnodes = [] mfnodes = []
basemfnodes = [] basemfnodes = []
directories = [] directories = []
outgoing = pushop.outgoing
for node in outgoing.missing: for node in outgoing.missing:
mfnode = pushop.repo[node].manifestnode() mfnode = repo[node].manifestnode()
mfnodes.append(mfnode) mfnodes.append(mfnode)
basectxs = pushop.repo.set('parents(roots(%ln))', outgoing.missing) basectxs = repo.set('parents(roots(%ln))', outgoing.missing)
for basectx in basectxs: for basectx in basectxs:
basemfnodes.append(basectx.manifestnode()) basemfnodes.append(basectx.manifestnode())
packstream = generatepackstream(pushop.repo, rootdir, mfnodes, packstream = generatepackstream(repo, rootdir, mfnodes,
basemfnodes, directories) basemfnodes, directories)
part = bundler.newpart(TREEGROUP_PARTTYPE2, data=packstream) part = bundle2.bundlepart(
partname,
data = packstream)
part.addparam('version', '1') part.addparam('version', '1')
part.addparam('cache', 'False') part.addparam('cache', 'False')
part.addparam('category', PACK_CATEGORY) part.addparam('category', PACK_CATEGORY)
return part
def pull(orig, ui, repo, *pats, **opts): def pull(orig, ui, repo, *pats, **opts):
result = orig(ui, repo, *pats, **opts) result = orig(ui, repo, *pats, **opts)
repo = repo.unfiltered() repo = repo.unfiltered()