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.
--- a/mercurial/exchange.py Tue Apr 14 23:51:02 2015 -0400
+++ b/mercurial/exchange.py Tue Apr 14 14:07:35 2015 -0400
@@ -427,7 +427,7 @@
# This exists to help extensions wrap steps if necessary
b2partsgenmapping = {}
-def b2partsgenerator(stepname):
+def b2partsgenerator(stepname, idx=None):
"""decorator for function generating bundle2 part
The function is added to the step -> function mapping and appended to the
@@ -439,7 +439,10 @@
def dec(func):
assert stepname not in b2partsgenmapping
b2partsgenmapping[stepname] = func
- b2partsgenorder.append(stepname)
+ if idx is None:
+ b2partsgenorder.append(stepname)
+ else:
+ b2partsgenorder.insert(idx, stepname)
return func
return dec