mercurial/registrar.py
changeset 34280 b0790bebfcf8
parent 33725 50c44dee741a
child 34382 4735c1caf6b3
equal deleted inserted replaced
34279:53fb09c73ba8 34280:b0790bebfcf8
   164     DoS attack (False by default).
   164     DoS attack (False by default).
   165 
   165 
   166     Optional argument 'takeorder' indicates whether a predicate function
   166     Optional argument 'takeorder' indicates whether a predicate function
   167     takes ordering policy as the last argument.
   167     takes ordering policy as the last argument.
   168 
   168 
       
   169     Optional argument 'weight' indicates the estimated run-time cost, useful
       
   170     for static optimization, default is 1. Higher weight means more expensive.
       
   171     Usually, revsets that are fast and return only one revision has a weight of
       
   172     0.5 (ex. a symbol); revsets with O(changelog) complexity and read only the
       
   173     changelog have weight 10 (ex. author); revsets reading manifest deltas have
       
   174     weight 30 (ex. adds); revset reading manifest contents have weight 100
       
   175     (ex. contains). Note: those values are flexible. If the revset has a
       
   176     same big-O time complexity as 'contains', but with a smaller constant, it
       
   177     might have a weight of 90.
       
   178 
   169     'revsetpredicate' instance in example above can be used to
   179     'revsetpredicate' instance in example above can be used to
   170     decorate multiple functions.
   180     decorate multiple functions.
   171 
   181 
   172     Decorated functions are registered automatically at loading
   182     Decorated functions are registered automatically at loading
   173     extension, if an instance named as 'revsetpredicate' is used for
   183     extension, if an instance named as 'revsetpredicate' is used for
   176     Otherwise, explicit 'revset.loadpredicate()' is needed.
   186     Otherwise, explicit 'revset.loadpredicate()' is needed.
   177     """
   187     """
   178     _getname = _funcregistrarbase._parsefuncdecl
   188     _getname = _funcregistrarbase._parsefuncdecl
   179     _docformat = "``%s``\n    %s"
   189     _docformat = "``%s``\n    %s"
   180 
   190 
   181     def _extrasetup(self, name, func, safe=False, takeorder=False):
   191     def _extrasetup(self, name, func, safe=False, takeorder=False, weight=1):
   182         func._safe = safe
   192         func._safe = safe
   183         func._takeorder = takeorder
   193         func._takeorder = takeorder
       
   194         func._weight = weight
   184 
   195 
   185 class filesetpredicate(_funcregistrarbase):
   196 class filesetpredicate(_funcregistrarbase):
   186     """Decorator to register fileset predicate
   197     """Decorator to register fileset predicate
   187 
   198 
   188     Usage::
   199     Usage::