##// END OF EJS Templates
bundle2: update all ``addpart`` callers to ``newpart``...
Pierre-Yves David -
r21600:5e08f3b6 default
parent child Browse files
Show More
@@ -321,11 +321,10 b' def processbundle(repo, unbundler, trans'
321 if output is not None:
321 if output is not None:
322 output = op.ui.popbuffer()
322 output = op.ui.popbuffer()
323 if output:
323 if output:
324 outpart = bundlepart('b2x:output',
324 op.reply.newpart('b2x:output',
325 advisoryparams=[('in-reply-to',
325 advisoryparams=[('in-reply-to',
326 str(part.id))],
326 str(part.id))],
327 data=output)
327 data=output)
328 op.reply.addpart(outpart)
329 part.read()
328 part.read()
330 except Exception, exc:
329 except Exception, exc:
331 if part is not None:
330 if part is not None:
@@ -409,7 +408,7 b' class bundle20(object):'
409 self._parts.append(part)
408 self._parts.append(part)
410
409
411 def newpart(self, typeid, *args, **kwargs):
410 def newpart(self, typeid, *args, **kwargs):
412 """create a new part for the containers"""
411 """create a new part and add it to the containers"""
413 part = bundlepart(typeid, *args, **kwargs)
412 part = bundlepart(typeid, *args, **kwargs)
414 self.addpart(part)
413 self.addpart(part)
415 return part
414 return part
@@ -214,16 +214,13 b' def _pushbundle2(pushop):'
214 bundler = bundle2.bundle20(pushop.ui, caps)
214 bundler = bundle2.bundle20(pushop.ui, caps)
215 # create reply capability
215 # create reply capability
216 capsblob = bundle2.encodecaps(pushop.repo.bundle2caps)
216 capsblob = bundle2.encodecaps(pushop.repo.bundle2caps)
217 bundler.addpart(bundle2.bundlepart('b2x:replycaps', data=capsblob))
217 bundler.newpart('b2x:replycaps', data=capsblob)
218 if not pushop.force:
218 if not pushop.force:
219 part = bundle2.bundlepart('B2X:CHECK:HEADS',
219 bundler.newpart('B2X:CHECK:HEADS', data=iter(pushop.remoteheads))
220 data=iter(pushop.remoteheads))
221 bundler.addpart(part)
222 extrainfo = _pushbundle2extraparts(pushop, bundler)
220 extrainfo = _pushbundle2extraparts(pushop, bundler)
223 # add the changegroup bundle
221 # add the changegroup bundle
224 cg = changegroup.getlocalbundle(pushop.repo, 'push', pushop.outgoing)
222 cg = changegroup.getlocalbundle(pushop.repo, 'push', pushop.outgoing)
225 cgpart = bundle2.bundlepart('B2X:CHANGEGROUP', data=cg.getchunks())
223 cgpart = bundler.newpart('B2X:CHANGEGROUP', data=cg.getchunks())
226 bundler.addpart(cgpart)
227 stream = util.chunkbuffer(bundler.getchunks())
224 stream = util.chunkbuffer(bundler.getchunks())
228 try:
225 try:
229 reply = pushop.remote.unbundle(stream, ['force'], 'push')
226 reply = pushop.remote.unbundle(stream, ['force'], 'push')
@@ -670,8 +667,7 b' def getbundle(repo, source, heads=None, '
670 b2caps.update(bundle2.decodecaps(blob))
667 b2caps.update(bundle2.decodecaps(blob))
671 bundler = bundle2.bundle20(repo.ui, b2caps)
668 bundler = bundle2.bundle20(repo.ui, b2caps)
672 if cg:
669 if cg:
673 part = bundle2.bundlepart('b2x:changegroup', data=cg.getchunks())
670 bundler.newpart('b2x:changegroup', data=cg.getchunks())
674 bundler.addpart(part)
675 _getbundleextrapart(bundler, repo, source, heads=heads, common=common,
671 _getbundleextrapart(bundler, repo, source, heads=heads, common=common,
676 bundlecaps=bundlecaps, **kwargs)
672 bundlecaps=bundlecaps, **kwargs)
677 return util.chunkbuffer(bundler.getchunks())
673 return util.chunkbuffer(bundler.getchunks())
@@ -805,9 +805,7 b' def unbundle(repo, proto, heads):'
805 os.unlink(tempname)
805 os.unlink(tempname)
806 except bundle2.UnknownPartError, exc:
806 except bundle2.UnknownPartError, exc:
807 bundler = bundle2.bundle20(repo.ui)
807 bundler = bundle2.bundle20(repo.ui)
808 part = bundle2.bundlepart('B2X:ERROR:UNKNOWNPART',
808 bundler.newpart('B2X:ERROR:UNKNOWNPART', [('parttype', str(exc))])
809 [('parttype', str(exc))])
810 bundler.addpart(part)
811 return streamres(bundler.getchunks())
809 return streamres(bundler.getchunks())
812 except util.Abort, inst:
810 except util.Abort, inst:
813 # The old code we moved used sys.stderr directly.
811 # The old code we moved used sys.stderr directly.
@@ -829,9 +827,7 b' def unbundle(repo, proto, heads):'
829 except error.PushRaced, exc:
827 except error.PushRaced, exc:
830 if getattr(exc, 'duringunbundle2', False):
828 if getattr(exc, 'duringunbundle2', False):
831 bundler = bundle2.bundle20(repo.ui)
829 bundler = bundle2.bundle20(repo.ui)
832 part = bundle2.bundlepart('B2X:ERROR:PUSHRACED',
830 bundler.newpart('B2X:ERROR:PUSHRACED', [('message', str(exc))])
833 [('message', str(exc))])
834 bundler.addpart(part)
835 return streamres(bundler.getchunks())
831 return streamres(bundler.getchunks())
836 else:
832 else:
837 return pusherr(str(exc))
833 return pusherr(str(exc))
@@ -47,9 +47,7 b' Create an extension to test bundle2 API'
47 > op.ui.write('received ping request (id %i)\n' % part.id)
47 > op.ui.write('received ping request (id %i)\n' % part.id)
48 > if op.reply is not None and 'ping-pong' in op.reply.capabilities:
48 > if op.reply is not None and 'ping-pong' in op.reply.capabilities:
49 > op.ui.write_err('replying to ping request (id %i)\n' % part.id)
49 > op.ui.write_err('replying to ping request (id %i)\n' % part.id)
50 > rpart = bundle2.bundlepart('test:pong',
50 > op.reply.newpart('test:pong', [('in-reply-to', str(part.id))])
51 > [('in-reply-to', str(part.id))])
52 > op.reply.addpart(rpart)
53 >
51 >
54 > @bundle2.parthandler('test:debugreply')
52 > @bundle2.parthandler('test:debugreply')
55 > def debugreply(op, part):
53 > def debugreply(op, part):
@@ -83,11 +81,11 b' Create an extension to test bundle2 API'
83 >
81 >
84 > if opts['reply']:
82 > if opts['reply']:
85 > capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville'
83 > capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville'
86 > bundler.addpart(bundle2.bundlepart('b2x:replycaps', data=capsstring))
84 > bundler.newpart('b2x:replycaps', data=capsstring)
87 >
85 >
88 > if opts['pushrace']:
86 > if opts['pushrace']:
89 > dummynode = '01234567890123456789'
87 > dummynode = '01234567890123456789'
90 > bundler.addpart(bundle2.bundlepart('b2x:check:heads', data=dummynode))
88 > bundler.newpart('b2x:check:heads', data=dummynode)
91 >
89 >
92 > revs = opts['rev']
90 > revs = opts['rev']
93 > if 'rev' in opts:
91 > if 'rev' in opts:
@@ -99,31 +97,22 b' Create an extension to test bundle2 API'
99 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
97 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
100 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing)
98 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing)
101 > cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None)
99 > cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None)
102 > part = bundle2.bundlepart('b2x:changegroup', data=cg.getchunks())
100 > bundler.newpart('b2x:changegroup', data=cg.getchunks())
103 > bundler.addpart(part)
104 >
101 >
105 > if opts['parts']:
102 > if opts['parts']:
106 > part = bundle2.bundlepart('test:empty')
103 > bundler.newpart('test:empty')
107 > bundler.addpart(part)
108 > # add a second one to make sure we handle multiple parts
104 > # add a second one to make sure we handle multiple parts
109 > part = bundle2.bundlepart('test:empty')
105 > bundler.newpart('test:empty')
110 > bundler.addpart(part)
106 > bundler.newpart('test:song', data=ELEPHANTSSONG)
111 > part = bundle2.bundlepart('test:song', data=ELEPHANTSSONG)
107 > bundler.newpart('test:debugreply')
112 > bundler.addpart(part)
108 > bundler.newpart('test:math',
113 > part = bundle2.bundlepart('test:debugreply')
114 > bundler.addpart(part)
115 > part = bundle2.bundlepart('test:math',
116 > [('pi', '3.14'), ('e', '2.72')],
109 > [('pi', '3.14'), ('e', '2.72')],
117 > [('cooking', 'raw')],
110 > [('cooking', 'raw')],
118 > '42')
111 > '42')
119 > bundler.addpart(part)
120 > if opts['unknown']:
112 > if opts['unknown']:
121 > part = bundle2.bundlepart('test:UNKNOWN',
113 > bundler.newpart('test:UNKNOWN', data='some random content')
122 > data='some random content')
123 > bundler.addpart(part)
124 > if opts['parts']:
114 > if opts['parts']:
125 > part = bundle2.bundlepart('test:ping')
115 > bundler.newpart('test:ping')
126 > bundler.addpart(part)
127 >
116 >
128 > if path is None:
117 > if path is None:
129 > file = sys.stdout
118 > file = sys.stdout
@@ -938,14 +927,12 b' Setting up'
938 > reason = pushop.ui.config('failpush', 'reason', None)
927 > reason = pushop.ui.config('failpush', 'reason', None)
939 > part = None
928 > part = None
940 > if reason == 'abort':
929 > if reason == 'abort':
941 > part = bundle2.bundlepart('test:abort')
930 > bundler.newpart('test:abort')
942 > if reason == 'unknown':
931 > if reason == 'unknown':
943 > part = bundle2.bundlepart('TEST:UNKNOWN')
932 > bundler.newpart('TEST:UNKNOWN')
944 > if reason == 'race':
933 > if reason == 'race':
945 > # 20 Bytes of crap
934 > # 20 Bytes of crap
946 > part = bundle2.bundlepart('b2x:check:heads', data='01234567890123456789')
935 > bundler.newpart('b2x:check:heads', data='01234567890123456789')
947 > if part is not None:
948 > bundler.addpart(part)
949 > return extradata
936 > return extradata
950 >
937 >
951 > @bundle2.parthandler("test:abort")
938 > @bundle2.parthandler("test:abort")
General Comments 0
You need to be logged in to leave comments. Login now