mercurial/registrar.py
changeset 38829 7e7e2b2ff284
parent 38690 5d9749c598f0
child 38830 bfd5def3fe02
--- a/mercurial/registrar.py	Sat Jul 21 16:16:44 2018 +0900
+++ b/mercurial/registrar.py	Sat Jul 21 15:52:26 2018 +0900
@@ -247,6 +247,9 @@
      implies 'matchctx.status()' at runtime or not (False, by
      default).
 
+    Optional argument 'weight' indicates the estimated run-time cost, useful
+    for static optimization, default is 1. Higher weight means more expensive.
+
     'filesetpredicate' instance in example above can be used to
     decorate multiple functions.
 
@@ -259,8 +262,9 @@
     _getname = _funcregistrarbase._parsefuncdecl
     _docformat = "``%s``\n    %s"
 
-    def _extrasetup(self, name, func, callstatus=False):
+    def _extrasetup(self, name, func, callstatus=False, weight=1):
         func._callstatus = callstatus
+        func._weight = weight
 
 class _templateregistrarbase(_funcregistrarbase):
     """Base of decorator to register functions as template specific one