changeset 28395:0383f7a5e86c

revset: replace predicate by revsetpredicate of registrar To make all built-in predicates be known to hggettext, loading built-in predicates by loadpredicate() should be placed before fixing i18nfunctions but after all of predicate decorating.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 08 Mar 2016 23:04:53 +0900
parents dcb4209bd30d
children 5490b04e6132
files mercurial/revset.py
diffstat 1 files changed, 4 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Tue Mar 08 23:04:53 2016 +0900
+++ b/mercurial/revset.py	Tue Mar 08 23:04:53 2016 +0900
@@ -482,36 +482,7 @@
 # functions that just return a lot of changesets (like all) don't count here
 safesymbols = set()
 
-class predicate(registrar.funcregistrar):
-    """Decorator to register revset predicate
-
-    Usage::
-
-        @predicate('mypredicate(arg1, arg2[, arg3])')
-        def mypredicatefunc(repo, subset, x):
-            '''Explanation of this revset predicate ....
-            '''
-            pass
-
-    The first string argument of the constructor is used also in
-    online help.
-
-    Use 'extpredicate' instead of this to register revset predicate in
-    extensions.
-    """
-    table = symbols
-    formatdoc = "``%s``\n    %s"
-    getname = registrar.funcregistrar.parsefuncdecl
-
-    def __init__(self, decl, safe=False):
-        """'safe' indicates whether a predicate is safe for DoS attack
-        """
-        super(predicate, self).__init__(decl)
-        self.safe = safe
-
-    def extraaction(self, name, func):
-        if self.safe:
-            safesymbols.add(name)
+predicate = registrar.revsetpredicate()
 
 class extpredicate(registrar.delayregistrar):
     """Decorator to register revset predicate in extensions
@@ -3636,5 +3607,8 @@
         if func._safe:
             safesymbols.add(name)
 
+# load built-in predicates explicitly to setup safesymbols
+loadpredicate(None, None, predicate)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()