[PATCH 2 of 2] bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Apr 14 19:06:37 UTC 2015
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1429037977 14400
# Tue Apr 14 14:59:37 2015 -0400
# Node ID c1a731ed65a77904df26631756884d3dd17b5035
# Parent 2ec934ad3f7fdcdf389f99cceeac2bf59a80f705
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
@@ -1133,11 +1133,11 @@ getbundle2partsorder = []
# Mapping between step name and function
#
# 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
list of steps. Beware that decorated functions will be added in order
(this may matter).
@@ -1145,11 +1145,14 @@ def getbundle2partsgenerator(stepname):
You can only use this decorator for new steps, if you want to wrap a step
from an extension, attack the getbundle2partsmapping dictionary directly."""
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
def getbundle(repo, source, heads=None, common=None, bundlecaps=None,
**kwargs):
More information about the Mercurial-devel
mailing list