Submitter | Pierre-Yves David |
---|---|
Date | April 14, 2015, 7:06 p.m. |
Message ID | <c1a731ed65a77904df26.1429038397@marginatus.alto.octopoid.net> |
Download | mbox | patch |
Permalink | /patch/8665/ |
State | Accepted |
Headers | show |
Comments
These seem reasonable to me. I'll push them to the clowncopter. On Tue, Apr 14, 2015 at 12:12 PM Pierre-Yves David < pierre-yves.david@ens-lyon.org> wrote: > # HG changeset patch > # User Pierre-Yves David <pierre-yves.david@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): > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel >
Patch
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):