changeset 21005:3d38ebb586fe

bundle2: rename part to bundlepart We are going to introduce an `unbundlepart` dedicated to reading bundle. So we need to rename the one used to create bundle. Even if dedicated to creation, this is still used for unbundling until we get the new class.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 11 Apr 2014 07:36:14 -0700
parents 27ab4b8d2503
children 723e41ad59b4
files mercurial/bundle2.py mercurial/exchange.py tests/test-bundle2.t
diffstat 3 files changed, 20 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Fri Apr 11 16:43:01 2014 -0400
+++ b/mercurial/bundle2.py	Fri Apr 11 07:36:14 2014 -0700
@@ -503,12 +503,12 @@
             payloadsize = self._unpack(_fpayloadsize)[0]
             self.ui.debug('payload chunk size: %i\n' % payloadsize)
         payload = ''.join(payload)
-        current = part(parttype, manparams, advparams, data=payload)
+        current = bundlepart(parttype, manparams, advparams, data=payload)
         current.id = partid
         return current
 
 
-class part(object):
+class bundlepart(object):
     """A bundle2 part contains application level payload
 
     The part `type` is used to route the part to the application level
@@ -598,9 +598,9 @@
     if op.reply is not None:
         # This is definitly not the final form of this
         # return. But one need to start somewhere.
-        op.reply.addpart(part('reply:changegroup', (),
-                         [('in-reply-to', str(inpart.id)),
-                          ('return', '%i' % ret)]))
+        op.reply.addpart(bundlepart('reply:changegroup', (),
+                                    [('in-reply-to', str(inpart.id)),
+                                     ('return', '%i' % ret)]))
 
 @parthandler('reply:changegroup')
 def handlechangegroup(op, inpart):
--- a/mercurial/exchange.py	Fri Apr 11 16:43:01 2014 -0400
+++ b/mercurial/exchange.py	Fri Apr 11 07:36:14 2014 -0700
@@ -604,7 +604,7 @@
         yield 'HG10UN'
         for c in cg.getchunks():
             yield c
-    part = bundle2.part('changegroup', data=cgchunks())
+    part = bundle2.bundlepart('changegroup', data=cgchunks())
     bundler.addpart(part)
     return bundle2.unbundle20(repo.ui, util.chunkbuffer(bundler.getchunks()))
 
--- a/tests/test-bundle2.t	Fri Apr 11 16:43:01 2014 -0400
+++ b/tests/test-bundle2.t	Fri Apr 11 07:36:14 2014 -0700
@@ -37,8 +37,9 @@
   > def pinghandler(op, part):
   >     op.ui.write('received ping request (id %i)\n' % part.id)
   >     if op.reply is not None:
-  >         op.reply.addpart(bundle2.part('test:pong',
-  >                                       [('in-reply-to', str(part.id))]))
+  >         rpart = bundle2.bundlepart('test:pong',
+  >                                    [('in-reply-to', str(part.id))])
+  >         op.reply.addpart(rpart)
   > 
   > @command('bundle2',
   >          [('', 'param', [], 'stream level parameter'),
@@ -70,28 +71,28 @@
   >                 yield 'HG10UN'
   >                 for c in cg.getchunks():
   >                    yield c
-  >             part = bundle2.part('changegroup', data=cgchunks())
+  >             part = bundle2.bundlepart('changegroup', data=cgchunks())
   >             bundler.addpart(part)
   > 
   >     if opts['parts']:
-  >        part = bundle2.part('test:empty')
+  >        part = bundle2.bundlepart('test:empty')
   >        bundler.addpart(part)
   >        # add a second one to make sure we handle multiple parts
-  >        part = bundle2.part('test:empty')
+  >        part = bundle2.bundlepart('test:empty')
   >        bundler.addpart(part)
-  >        part = bundle2.part('test:song', data=ELEPHANTSSONG)
+  >        part = bundle2.bundlepart('test:song', data=ELEPHANTSSONG)
   >        bundler.addpart(part)
-  >        part = bundle2.part('test:math',
-  >                            [('pi', '3.14'), ('e', '2.72')],
-  >                            [('cooking', 'raw')],
-  >                            '42')
+  >        part = bundle2.bundlepart('test:math',
+  >                                  [('pi', '3.14'), ('e', '2.72')],
+  >                                  [('cooking', 'raw')],
+  >                                  '42')
   >        bundler.addpart(part)
   >     if opts['unknown']:
-  >        part = bundle2.part('test:UNKNOWN',
-  >                            data='some random content')
+  >        part = bundle2.bundlepart('test:UNKNOWN',
+  >                                  data='some random content')
   >        bundler.addpart(part)
   >     if opts['parts']:
-  >        part = bundle2.part('test:ping')
+  >        part = bundle2.bundlepart('test:ping')
   >        bundler.addpart(part)
   > 
   >     if path is None: