# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 2017-09-14 17:20:05
# Node ID f010097c885c6a852f62fe89bcccb8d30d1ff598
# Parent  cc7b37c906164789f0ea35bd520bb416a2318190

bundle2: move part processing to a separate function

Now that the part processing loop is tiny, let's move it to a separate function.
This will allow extensions to completely replace the part processing logic,
without having to replace the overall bundle processing logic or the stream
maintenance logic.

This will be useful for the infinitepush extension, so it can completely take
over receiving a bundle and rerouting it to a side store. This will also make it
easier to upstream the infinitepush functionality later.

Differential Revision: https://phab.mercurial-scm.org/D709

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -447,12 +447,15 @@ def processbundle(repo, unbundler, trans
         msg.append('\n')
         repo.ui.debug(''.join(msg))
 
+    processparts(repo, op, unbundler)
+
+    return op
+
+def processparts(repo, op, unbundler):
     with partiterator(repo, op, unbundler) as parts:
         for part in parts:
             _processpart(op, part)
 
-    return op
-
 def _processchangegroup(op, cg, tr, source, url, **kwargs):
     ret = cg.apply(op.repo, tr, source, url, **kwargs)
     op.records.add('changegroup', {