bundle2: add an 'idx' argument to the 'b2partsgenerator'
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 14 Apr 2015 14:07:35 -0400
changeset 24731 88a36edefea5
parent 24730 aa8e5c6d953b
child 24732 8f70b529cb0c
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.
mercurial/exchange.py
--- 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