[PATCH 7 of 8] bundle2: extract a _payloadchunks method for part

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Fri Apr 11 17:06:04 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1397158400 25200
#      Thu Apr 10 12:33:20 2014 -0700
# Node ID e6261a31c9a819d972f404f5c3301d6e5f5ff3f3
# Parent  95eaf9fabeb354ac0dc6f924ce1482e9a8bf1537
bundle2: extract a _payloadchunks method for part

We are preparing streaming capability for part. So the generation of payload
chunk will becomes more complex. We extract this part in its own function before
any changes.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -547,17 +547,24 @@ class part(object):
         ## finalize header
         headerchunk = ''.join(header)
         yield _pack(_fpartheadersize, len(headerchunk))
         yield headerchunk
         ## payload
+        for chunk in self._payloadchunks():
+            yield _pack(_fpayloadsize, len(chunk))
+            yield chunk
+        # end of payload
+        yield _pack(_fpayloadsize, 0)
+
+    def _payloadchunks(self):
+        """yield chunks of a the part payload
+
+        Exists to handle the different methods to provide data to a part."""
         # we only support fixed size data now.
         # This will be improved in the future.
         if len(self.data):
-            yield _pack(_fpayloadsize, len(self.data))
             yield self.data
-        # end of payload
-        yield _pack(_fpayloadsize, 0)
 
 @parthandler('changegroup')
 def handlechangegroup(op, inpart):
     """apply a changegroup part on the repo
 


More information about the Mercurial-devel mailing list