mercurial/parser.py
changeset 28870 475dad3432fd
parent 28720 639e0f1e8ffa
child 28871 6d6201fc5aae
equal deleted inserted replaced
28869:f8182ab688a5 28870:475dad3432fd
   226     """
   226     """
   227     if len(inst.args) > 1:
   227     if len(inst.args) > 1:
   228         return _('at %s: %s') % (inst.args[1], inst.args[0])
   228         return _('at %s: %s') % (inst.args[1], inst.args[0])
   229     else:
   229     else:
   230         return inst.args[0]
   230         return inst.args[0]
       
   231 
       
   232 class basealiasrules(object):
       
   233     """Parsing and expansion rule set of aliases
       
   234 
       
   235     This is a helper for fileset/revset/template aliases. A concrete rule set
       
   236     should be made by sub-classing this and implementing class/static methods.
       
   237 
       
   238     It supports alias expansion of symbol and funciton-call styles::
       
   239 
       
   240         # decl = defn
       
   241         h = heads(default)
       
   242         b($1) = ancestors($1) - ancestors(default)
       
   243     """
       
   244     # typically a config section, which will be included in error messages
       
   245     _section = None
       
   246     # tags of symbol and function nodes
       
   247     _symbolnode = 'symbol'
       
   248     _funcnode = 'func'
       
   249 
       
   250     def __new__(cls):
       
   251         raise TypeError("'%s' is not instantiatable" % cls.__name__)
       
   252 
       
   253     @staticmethod
       
   254     def _parsedecl(spec):
       
   255         """Parse an alias name and arguments"""
       
   256         raise NotImplementedError
       
   257 
       
   258     @staticmethod
       
   259     def _parsedefn(spec):
       
   260         """Parse an alias definition"""
       
   261         raise NotImplementedError
       
   262 
       
   263     @staticmethod
       
   264     def _getlist(tree):
       
   265         """Extract a list of arguments from parsed tree"""
       
   266         raise NotImplementedError