# HG changeset patch # User Pierre-Yves David # Date 2015-04-14 18:59:37 # Node ID 8f70b529cb0c06d67e5ee4e5486e18ceb696abf4 # Parent 88a36edefea5a0a3cd9ba14f5f5e03557c938288 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. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -1135,7 +1135,7 @@ getbundle2partsorder = [] # 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 getbundle2partsgenerator(stepname): 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