comparison mercurial/registrar.py @ 27584:fc7c8cac6a4b

revset: use decorator to register a function as revset predicate Using decorator can localize changes for adding (or removing) a revset predicate function in source code. It is also useful to pick predicates up for specific purpose. For example, subsequent patch marks predicates as "safe" by decorator. This patch defines 'parsefuncdecl()' in 'funcregistrar' class, because this implementation can be uesd by other decorator class for fileset predicate and template function.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 29 Dec 2015 23:58:30 +0900
parents 37d50250b696
children 60bf90eb8bf8
comparison
equal deleted inserted replaced
27583:37d50250b696 27584:fc7c8cac6a4b
68 Derived class should override this, if it allows more 68 Derived class should override this, if it allows more
69 descriptive 'decl' string than just a name. 69 descriptive 'decl' string than just a name.
70 """ 70 """
71 return self.decl 71 return self.decl
72 72
73 def parsefuncdecl(self):
74 """Parse function declaration and return the name of function in it
75 """
76 i = self.decl.find('(')
77 if i > 0:
78 return self.decl[:i]
79 else:
80 return self.decl
81
73 def formatdoc(self, doc): 82 def formatdoc(self, doc):
74 """Return formatted document of the registered function for help 83 """Return formatted document of the registered function for help
75 84
76 'doc' is '__doc__.strip()' of the registered function. 85 'doc' is '__doc__.strip()' of the registered function.
77 86