Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/registrar.py Tue Dec 29 23:58:30 2015 +0900 +++ b/mercurial/registrar.py Tue Dec 29 23:58:30 2015 +0900 @@ -70,6 +70,15 @@ """ return self.decl + def parsefuncdecl(self): + """Parse function declaration and return the name of function in it + """ + i = self.decl.find('(') + if i > 0: + return self.decl[:i] + else: + return self.decl + def formatdoc(self, doc): """Return formatted document of the registered function for help