changeset 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 aa8e5c6d953b
children 8f70b529cb0c
files mercurial/exchange.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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