changeset 24732:8f70b529cb0c

bundle2: add an 'idx' argument to the 'getbundle2partsgenerator' This argument let extensions control in what order bundle2 part are generated server side during a pull. 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:59:37 -0400
parents 88a36edefea5
children c00e4338fa4b
files mercurial/exchange.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Tue Apr 14 14:07:35 2015 -0400
+++ b/mercurial/exchange.py	Tue Apr 14 14:59:37 2015 -0400
@@ -1135,7 +1135,7 @@
 # This exists to help extensions wrap steps if necessary
 getbundle2partsmapping = {}
 
-def getbundle2partsgenerator(stepname):
+def getbundle2partsgenerator(stepname, idx=None):
     """decorator for function generating bundle2 part for getbundle
 
     The function is added to the step -> function mapping and appended to the
@@ -1147,7 +1147,10 @@
     def dec(func):
         assert stepname not in getbundle2partsmapping
         getbundle2partsmapping[stepname] = func
-        getbundle2partsorder.append(stepname)
+        if idx is None:
+            getbundle2partsorder.append(stepname)
+        else:
+            getbundle2partsorder.insert(idx, stepname)
         return func
     return dec