Patchwork [5,of,5] revset: replace revset.predicate by registrar.revsetpredicate

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Jan. 5, 2016, 11:48 a.m.
Message ID <3da57c06c6d10564043a.1451994518@feefifofum>
Download mbox | patch
Permalink /patch/12530/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Katsunori FUJIWARA - Jan. 5, 2016, 11:48 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1451994204 -32400
#      Tue Jan 05 20:43:24 2016 +0900
# Node ID 3da57c06c6d10564043a6ce4202dc27024500e9a
# Parent  604903e68756b80dd147f37cc642c019b8d5e50b
revset: replace revset.predicate by registrar.revsetpredicate

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.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -479,36 +479,7 @@  symbols = {}
 # 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
@@ -3678,5 +3649,8 @@  def loadpredicate(ui, extname, predicate
         if func._safe:
             safesymbols.add(name)
 
+# load built-in predicates
+loadpredicate(None, None, predicate)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()