exthelper: simplify the ability to register filesets
authorMatt Harbison <matt_harbison@yahoo.com>
Thu, 27 Dec 2018 23:46:35 -0500
changeset 4330 9d2d0ebc6456
parent 4329 798298fda3be
child 4331 594495e1e47e
exthelper: simplify the ability to register filesets Same mechanism as revsets earlier in this series.
hgext3rd/evolve/exthelper.py
--- a/hgext3rd/evolve/exthelper.py	Thu Dec 27 21:55:22 2018 -0500
+++ b/hgext3rd/evolve/exthelper.py	Thu Dec 27 23:46:35 2018 -0500
@@ -13,7 +13,6 @@
     commands,
     error,
     extensions,
-    fileset as filesetmod,
     registrar,
 )
 
@@ -31,7 +30,6 @@
         self._uicallables = []
         self._extcallables = []
         self._repocallables = []
-        self._filesetsymbols = []
         self._commandwrappers = []
         self._extcommandwrappers = []
         self._functionwrappers = []
@@ -49,6 +47,7 @@
 
         self.configtable = {}
         self.configitem = registrar.configitem(self.configtable)
+        self.filesetpredicate = registrar.filesetpredicate()
         self.revsetpredicate = registrar.revsetpredicate()
         self.templatekeyword = registrar.templatekeyword()
 
@@ -57,8 +56,8 @@
         self._uipopulatecallables.extend(other._uipopulatecallables)
         self._extcallables.extend(other._extcallables)
         self._repocallables.extend(other._repocallables)
+        self.filesetpredicate._table.update(other.filesetpredicate._table)
         self.revsetpredicate._table.update(other.revsetpredicate._table)
-        self._filesetsymbols.extend(other._filesetsymbols)
         self.templatekeyword._table.update(other.templatekeyword._table)
         self._commandwrappers.extend(other._commandwrappers)
         self._extcommandwrappers.extend(other._extcommandwrappers)
@@ -125,12 +124,6 @@
         """
         knownexts = {}
 
-        filesetpredicate = registrar.filesetpredicate()
-        for name, symbol in self._filesetsymbols:
-            filesetpredicate(name)(symbol)
-        # TODO: Figure out the calling extension name
-        filesetmod.loadpredicate(ui, 'exthelper', filesetpredicate)
-
         for ext, command, wrapper, opts in self._extcommandwrappers:
             if ext not in knownexts:
                 try:
@@ -208,23 +201,6 @@
         self._repocallables.append(call)
         return call
 
-    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 wrapcommand(self, command, extension=None, opts=None):
         """Decorated function is a command wrapper