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