extensions: add fileset support to exthelper
This will be tested by using it in lfs.
--- 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