Patchwork [4,of,4,reviewed,by,Augie] bundle2: rename part to bundlepart

login
register
mail settings
Submitter Pierre-Yves David
Date April 12, 2014, 9:27 p.m.
Message ID <3d38ebb586fe5a3bb74c.1397338042@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4302/
State Accepted
Headers show

Comments

Pierre-Yves David - April 12, 2014, 9:27 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1397226974 25200
#      Fri Apr 11 07:36:14 2014 -0700
# Node ID 3d38ebb586fe5a3bb74c68c2464f948ede39e63d
# Parent  27ab4b8d250352987f68c7060c8dde5df81ec635
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.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -501,16 +501,16 @@  class unbundle20(object):
         while payloadsize:
             payload.append(self._readexact(payloadsize))
             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
     handler.
     """
@@ -596,13 +596,13 @@  def handlechangegroup(op, inpart):
     ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
     op.records.add('changegroup', {'return': ret})
     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):
     p = dict(inpart.advisoryparams)
     ret = int(p['return'])
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -602,11 +602,11 @@  def getbundle(repo, source, heads=None, 
     bundler = bundle2.bundle20(repo.ui)
     def cgchunks(cg=cg):
         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()))
 
 class PushRaced(RuntimeError):
     """An exception raised during unbunding that indicate a push race"""
diff --git a/tests/test-bundle2.t b/tests/test-bundle2.t
--- a/tests/test-bundle2.t
+++ b/tests/test-bundle2.t
@@ -35,12 +35,13 @@  Create an extension to test bundle2 API
   > 
   > @bundle2.parthandler('test:ping')
   > 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'),
   >           ('', 'unknown', False, 'include an unknown mandatory part in the bundle'),
   >           ('', 'parts', False, 'include some arbitrary parts to the bundle'),
@@ -68,32 +69,32 @@  Create an extension to test bundle2 API
   >             cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None)
   >             def cgchunks(cg=cg):
   >                 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:
   >        file = sys.stdout
   >     else: