changeset 21000:4cae06ae1562

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 10 Apr 2014 12:33:20 -0700
parents 1e28ec9744bf
children c93bb6a08fa1
files mercurial/bundle2.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Thu Apr 10 13:19:00 2014 -0700
+++ b/mercurial/bundle2.py	Thu Apr 10 12:33:20 2014 -0700
@@ -549,13 +549,20 @@
         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):