Mercurial > evolve
changeset 4328:392f1a6a0763
exthelper: simplify the ability to register revsets
I think this is what Yuya and Boris agreed on.[1] This happens *after* the
extsetup phase now (and after the _aftercallback notifications). But this is
trivial, mergeable between exthelper instances, and doesn't need to have the
extension name supplied when registering.
[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2018-December/125888.html
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 27 Dec 2018 21:26:17 -0500 |
parents | 9521698a9894 |
children | 798298fda3be |
files | hgext3rd/evolve/__init__.py hgext3rd/evolve/compat.py hgext3rd/evolve/exthelper.py |
diffstat | 3 files changed, 12 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py Sun Dec 23 21:54:56 2018 -0500 +++ b/hgext3rd/evolve/__init__.py Thu Dec 27 21:26:17 2018 -0500 @@ -369,6 +369,7 @@ reposetup = eh.finalreposetup cmdtable = eh.cmdtable configtable = eh.configtable +revsetpredicate = eh.revsetpredicate # Configuration eh.configitem('experimental', 'evolutioncommands', []) @@ -512,7 +513,7 @@ ### Troubled revset symbol -@eh.revset('troubled()') +@eh.revsetpredicate('troubled()') def revsettroubled(repo, subset, x): """Changesets with troubles. """ @@ -620,7 +621,7 @@ ### XXX I'm not sure this revset is useful -@eh.revset('suspended()') +@eh.revsetpredicate('suspended()') def revsetsuspended(repo, subset, x): """Obsolete changesets with non-obsolete descendants. """ @@ -630,7 +631,7 @@ return subset & suspended -@eh.revset('precursors(set)') +@eh.revsetpredicate('precursors(set)') def revsetprecursors(repo, subset, x): """Immediate precursors of changesets in set. """ @@ -640,7 +641,7 @@ return subset & s -@eh.revset('allprecursors(set)') +@eh.revsetpredicate('allprecursors(set)') def revsetallprecursors(repo, subset, x): """Transitive precursors of changesets in set. """ @@ -650,7 +651,7 @@ return subset & s -@eh.revset('successors(set)') +@eh.revsetpredicate('successors(set)') def revsetsuccessors(repo, subset, x): """Immediate successors of changesets in set. """ @@ -659,7 +660,7 @@ s.sort() return subset & s -@eh.revset('allsuccessors(set)') +@eh.revsetpredicate('allsuccessors(set)') def revsetallsuccessors(repo, subset, x): """Transitive successors of changesets in set. """
--- a/hgext3rd/evolve/compat.py Sun Dec 23 21:54:56 2018 -0500 +++ b/hgext3rd/evolve/compat.py Thu Dec 27 21:26:17 2018 -0500 @@ -77,17 +77,17 @@ context.basectx.isunstable = context.basectx.troubled if not util.safehasattr(revset, 'orphan'): - @eh.revset('orphan') + @eh.revsetpredicate('orphan') def oprhanrevset(*args, **kwargs): return revset.unstable(*args, **kwargs) if not util.safehasattr(revset, 'contentdivergent'): - @eh.revset('contentdivergent') + @eh.revsetpredicate('contentdivergent') def contentdivergentrevset(*args, **kwargs): return revset.divergent(*args, **kwargs) if not util.safehasattr(revset, 'phasedivergent'): - @eh.revset('phasedivergent') + @eh.revsetpredicate('phasedivergent') def phasedivergentrevset(*args, **kwargs): return revset.bumped(*args, **kwargs)
--- a/hgext3rd/evolve/exthelper.py Sun Dec 23 21:54:56 2018 -0500 +++ b/hgext3rd/evolve/exthelper.py Thu Dec 27 21:26:17 2018 -0500 @@ -15,7 +15,6 @@ extensions, fileset as filesetmod, registrar, - revset as revsetmod, templatekw as templatekwmod, ) @@ -33,7 +32,6 @@ self._uicallables = [] self._extcallables = [] self._repocallables = [] - self._revsetsymbols = [] self._filesetsymbols = [] self._templatekws = [] self._commandwrappers = [] @@ -53,13 +51,14 @@ self.configtable = {} self.configitem = registrar.configitem(self.configtable) + self.revsetpredicate = registrar.revsetpredicate() def merge(self, other): self._uicallables.extend(other._uicallables) self._uipopulatecallables.extend(other._uipopulatecallables) self._extcallables.extend(other._extcallables) self._repocallables.extend(other._repocallables) - self._revsetsymbols.extend(other._revsetsymbols) + self.revsetpredicate._table.update(other.revsetpredicate._table) self._filesetsymbols.extend(other._filesetsymbols) self._templatekws.extend(other._templatekws) self._commandwrappers.extend(other._commandwrappers) @@ -124,15 +123,9 @@ - Changes depending on the status of other extensions. (if extensions.find('mq')) - Add a global option to all commands - - Register revset functions """ knownexts = {} - revsetpredicate = registrar.revsetpredicate() - for name, symbol in self._revsetsymbols: - revsetpredicate(name)(symbol) - revsetmod.loadpredicate(ui, 'evolve', revsetpredicate) - filesetpredicate = registrar.filesetpredicate() for name, symbol in self._filesetsymbols: filesetpredicate(name)(symbol) @@ -224,24 +217,6 @@ self._repocallables.append(call) return call - def revset(self, symbolname): - """Decorated function is a revset symbol - - The name of the symbol must be given as the decorator argument. - The symbol is added during `extsetup`. - - example:: - - @eh.revset('hidden') - def revsetbabar(repo, subset, x): - args = revset.getargs(x, 0, 0, 'babar accept no argument') - return [r for r in subset if 'babar' in repo[r].description()] - """ - def dec(symbol): - self._revsetsymbols.append((symbolname, symbol)) - return symbol - return dec - def fileset(self, symbolname): """Decorated function is a fileset symbol