Patchwork [4,of,4] fileset: replace predicate by filesetpredicate of registrar

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 9, 2016, 2:29 p.m.
Message ID <90fd6269f7d68d84b1c6.1457533750@feefifofum>
Download mbox | patch
Permalink /patch/13720/
State Changes Requested
Delegated to: Sean Farley
Headers show

Comments

Katsunori FUJIWARA - March 9, 2016, 2:29 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1457533235 -32400
#      Wed Mar 09 23:20:35 2016 +0900
# Node ID 90fd6269f7d68d84b1c6bb7c456159db89e30f4f
# Parent  94c9f8cd6931758a98ff8113b30ec9a4bf770f76
fileset: replace predicate by filesetpredicate 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.

Patch

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -14,6 +14,7 @@  from . import (
     error,
     merge,
     parser,
+    registrar,
     util,
 )
 
@@ -144,34 +145,7 @@  symbols = {}
 # filesets using matchctx.existing()
 _existingcallers = set()
 
-def predicate(decl, callstatus=False, callexisting=False):
-    """Return a decorator for fileset predicate function
-
-    'decl' argument is the declaration (including argument list like
-    'adds(pattern)') or the name (for internal use only) of predicate.
-
-    Optional 'callstatus' argument indicates whether predicate implies
-    'matchctx.status()' at runtime or not (False, by default).
-
-    Optional 'callexisting' argument indicates whether predicate
-    implies 'matchctx.existing()' at runtime or not (False, by
-    default).
-    """
-    def decorator(func):
-        i = decl.find('(')
-        if i > 0:
-            name = decl[:i]
-        else:
-            name = decl
-        symbols[name] = func
-        if callstatus:
-            _statuscallers.add(name)
-        if callexisting:
-            _existingcallers.add(name)
-        if func.__doc__:
-            func.__doc__ = "``%s``\n    %s" % (decl, func.__doc__.strip())
-        return func
-    return decorator
+predicate = registrar.filesetpredicate()
 
 @predicate('modified()', callstatus=True)
 def modified(mctx, x):
@@ -570,5 +544,8 @@  def loadpredicate(ui, extname, registrar
         if func._callexisting:
             _existingcallers.add(name)
 
+# load built-in predicates explicitly to setup _statuscallers/_existingcallers
+loadpredicate(None, None, predicate)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()