# HG changeset patch # User Matt Harbison # Date 1543633839 18000 # Node ID 5c707b54f8b1b1426af428fbd7c5bbb626a1aec1 # Parent 12e3f24f794beb22f2baa18d84db46cbd7da2376 extensions: add fileset support to exthelper This will be tested by using it in lfs. diff -r 12e3f24f794b -r 5c707b54f8b1 hgext3rd/evolve/exthelper.py --- a/hgext3rd/evolve/exthelper.py Sun Dec 02 16:48:05 2018 +0100 +++ b/hgext3rd/evolve/exthelper.py Fri Nov 30 22:10:39 2018 -0500 @@ -13,6 +13,7 @@ commands, configitems, extensions, + fileset, registrar, revset, templatekw, @@ -33,6 +34,7 @@ self._extcallables = [] self._repocallables = [] self._revsetsymbols = [] + self._filesetsymbols = [] self._templatekws = [] self._commandwrappers = [] self._extcommandwrappers = [] @@ -63,6 +65,7 @@ self._extcallables.extend(other._extcallables) self._repocallables.extend(other._repocallables) self._revsetsymbols.extend(other._revsetsymbols) + self._filesetsymbols.extend(other._filesetsymbols) self._templatekws.extend(other._templatekws) self._commandwrappers.extend(other._commandwrappers) self._extcommandwrappers.extend(other._extcommandwrappers) @@ -135,6 +138,12 @@ revsetpredicate(name)(symbol) revset.loadpredicate(ui, 'evolve', revsetpredicate) + filesetpredicate = registrar.filesetpredicate() + for name, symbol in self._filesetsymbols: + filesetpredicate(name)(symbol) + # TODO: Figure out the calling extension name + fileset.loadpredicate(ui, 'exthelper', filesetpredicate) + templatekeyword = registrar.templatekeyword() for name, kw, requires in self._templatekws: if requires is not None: @@ -238,6 +247,23 @@ return symbol return dec + def fileset(self, symbolname): + """Decorated function is a fileset symbol + + The name of the symbol must be given as the decorator argument. + The symbol is added during `extsetup`. + + example:: + + @eh.fileset('lfs()') + def filesetbabar(mctx, x): + return mctx.predicate(...) + """ + def dec(symbol): + self._filesetsymbols.append((symbolname, symbol)) + return symbol + return dec + def templatekw(self, keywordname, requires=None): """Decorated function is a template keyword