From 0ce2a60ef62579ae9cc5e5b22a5fe322717a1dfb Mon Sep 17 00:00:00 2001 From: Durham Goode Date: Mon, 10 Jul 2017 15:53:12 -0700 Subject: [PATCH] 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 --- treemanifest/__init__.py | 42 ++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/treemanifest/__init__.py b/treemanifest/__init__.py index ddb9d571ed..70dd14c437 100644 --- a/treemanifest/__init__.py +++ b/treemanifest/__init__.py @@ -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)