##// END OF EJS Templates
push: rework the bundle2partsgenerators logic...
Pierre-Yves David -
r22017:7986e99b default
parent child Browse files
Show More
@@ -243,6 +243,31 def _pushcheckoutgoing(pushop):
243 newbm)
243 newbm)
244 return True
244 return True
245
245
246 # List of names of steps to perform for an outgoing bundle2, order matters.
247 b2partsgenorder = []
248
249 # Mapping between step name and function
250 #
251 # This exists to help extensions wrap steps if necessary
252 b2partsgenmapping = {}
253
254 def b2partsgenerator(stepname):
255 """decorator for function generating bundle2 part
256
257 The function is added to the step -> function mapping and appended to the
258 list of steps. Beware that decorated functions will be added in order
259 (this may matter).
260
261 You can only use this decorator for new steps, if you want to wrap a step
262 from an extension, attack the b2partsgenmapping dictionary directly."""
263 def dec(func):
264 assert stepname not in b2partsgenmapping
265 b2partsgenmapping[stepname] = func
266 b2partsgenorder.append(stepname)
267 return func
268 return dec
269
270 @b2partsgenerator('changeset')
246 def _pushb2ctx(pushop, bundler):
271 def _pushb2ctx(pushop, bundler):
247 """handle changegroup push through bundle2
272 """handle changegroup push through bundle2
248
273
@@ -269,8 +294,6 def _pushb2ctx(pushop, bundler):
269 pushop.ret = cgreplies['changegroup'][0]['return']
294 pushop.ret = cgreplies['changegroup'][0]['return']
270 return handlereply
295 return handlereply
271
296
272 # list of function that may decide to add parts to an outgoing bundle2
273 bundle2partsgenerators = [_pushb2ctx]
274
297
275 def _pushbundle2(pushop):
298 def _pushbundle2(pushop):
276 """push data to the remote using bundle2
299 """push data to the remote using bundle2
@@ -282,7 +305,8 def _pushbundle2(pushop):
282 capsblob = bundle2.encodecaps(pushop.repo.bundle2caps)
305 capsblob = bundle2.encodecaps(pushop.repo.bundle2caps)
283 bundler.newpart('b2x:replycaps', data=capsblob)
306 bundler.newpart('b2x:replycaps', data=capsblob)
284 replyhandlers = []
307 replyhandlers = []
285 for partgen in bundle2partsgenerators:
308 for partgenname in b2partsgenorder:
309 partgen = b2partsgenmapping[partgenname]
286 ret = partgen(pushop, bundler)
310 ret = partgen(pushop, bundler)
287 if callable(ret):
311 if callable(ret):
288 replyhandlers.append(ret)
312 replyhandlers.append(ret)
@@ -964,7 +964,8 Setting up
964 > raise util.Abort('Abandon ship!', hint="don't panic")
964 > raise util.Abort('Abandon ship!', hint="don't panic")
965 >
965 >
966 > def uisetup(ui):
966 > def uisetup(ui):
967 > exchange.bundle2partsgenerators.insert(0, _pushbundle2failpart)
967 > exchange.b2partsgenmapping['failpart'] = _pushbundle2failpart
968 > exchange.b2partsgenorder.insert(0, 'failpart')
968 >
969 >
969 > EOF
970 > EOF
970
971
General Comments 0
You need to be logged in to leave comments. Login now