comparison mercurial/exchange.py @ 24731:88a36edefea5

bundle2: add an 'idx' argument to the 'b2partsgenerator' This argument let extensions control in what order bundle2 part are generated client side during a push. This is useful to ensure the transaction is in a proper state before some actions or hooks happens.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 14 Apr 2015 14:07:35 -0400
parents 52ff737c63d2
children 8f70b529cb0c
comparison
equal deleted inserted replaced
24730:aa8e5c6d953b 24731:88a36edefea5
425 # Mapping between step name and function 425 # Mapping between step name and function
426 # 426 #
427 # This exists to help extensions wrap steps if necessary 427 # This exists to help extensions wrap steps if necessary
428 b2partsgenmapping = {} 428 b2partsgenmapping = {}
429 429
430 def b2partsgenerator(stepname): 430 def b2partsgenerator(stepname, idx=None):
431 """decorator for function generating bundle2 part 431 """decorator for function generating bundle2 part
432 432
433 The function is added to the step -> function mapping and appended to the 433 The function is added to the step -> function mapping and appended to the
434 list of steps. Beware that decorated functions will be added in order 434 list of steps. Beware that decorated functions will be added in order
435 (this may matter). 435 (this may matter).
437 You can only use this decorator for new steps, if you want to wrap a step 437 You can only use this decorator for new steps, if you want to wrap a step
438 from an extension, attack the b2partsgenmapping dictionary directly.""" 438 from an extension, attack the b2partsgenmapping dictionary directly."""
439 def dec(func): 439 def dec(func):
440 assert stepname not in b2partsgenmapping 440 assert stepname not in b2partsgenmapping
441 b2partsgenmapping[stepname] = func 441 b2partsgenmapping[stepname] = func
442 b2partsgenorder.append(stepname) 442 if idx is None:
443 b2partsgenorder.append(stepname)
444 else:
445 b2partsgenorder.insert(idx, stepname)
443 return func 446 return func
444 return dec 447 return dec
445 448
446 @b2partsgenerator('changeset') 449 @b2partsgenerator('changeset')
447 def _pushb2ctx(pushop, bundler): 450 def _pushb2ctx(pushop, bundler):