changeset 20947:c33d7bf53812

bundle2: feed a unbundle20 to the `processbundle` function The unbundle can comes from multiple sources. (on disk file, peer, etc) and (ultimately) of multiple type (bundle10, bundle20). The `processbundle` is no longer in charge of creating the bundle.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 02 Apr 2014 13:50:57 -0700
parents e910336539f7
children 329cd74b52bd
files mercurial/bundle2.py tests/test-bundle2.t
diffstat 2 files changed, 5 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Thu Apr 03 17:25:47 2014 -0700
+++ b/mercurial/bundle2.py	Wed Apr 02 13:50:57 2014 -0700
@@ -183,15 +183,11 @@
         return func
     return _decorator
 
-def processbundle(repo, stream):
+def processbundle(repo, unbundler):
     """This function process a bundle, apply effect to/from a repo
 
-    Currently it:
-    - parse a stream into an unbundle20 object
-    - iterate over each parts then search and use the proper handling code to
-      process the part.
-
-    Parts are processes in order.
+    It iterates over each part then searches for and uses the proper handling
+    code to process the part. Parts are processed in order.
 
     This is very early version of this function that will be strongly reworked
     before final usage.
@@ -199,11 +195,6 @@
     Unknown Mandatory part will abort the process.
     """
     ui = repo.ui
-    # Extraction of the unbundler object will most likely change. It may be
-    # done outside of this function, the unbundler would be passed as argument.
-    # in all case the unbundler will eventually be created by a
-    # `changegroup.readbundle` style function.
-    unbundler = unbundle20(ui, stream)
     # todo:
     # - replace this is a init function soon.
     # - exception catching
--- a/tests/test-bundle2.t	Thu Apr 03 17:25:47 2014 -0700
+++ b/tests/test-bundle2.t	Wed Apr 02 13:50:57 2014 -0700
@@ -74,7 +74,8 @@
   >     try:
   >         lock = repo.lock()
   >         try:
-  >             bundle2.processbundle(repo, sys.stdin)
+  >             unbundler = bundle2.unbundle20(ui, sys.stdin)
+  >             bundle2.processbundle(repo, unbundler)
   >         except KeyError, exc:
   >             raise util.Abort('missing support for %s' % exc)
   >     finally: