mercurial/revsetlang.py
changeset 45886 18489e26d9a0
parent 45776 0fc8b066928a
child 45942 89a2afe31e82
equal deleted inserted replaced
45885:600aec73f309 45886:18489e26d9a0
   556 def _parsewith(spec, lookup=None, syminitletters=None):
   556 def _parsewith(spec, lookup=None, syminitletters=None):
   557     """Generate a parse tree of given spec with given tokenizing options
   557     """Generate a parse tree of given spec with given tokenizing options
   558 
   558 
   559     >>> _parsewith(b'foo($1)', syminitletters=_aliassyminitletters)
   559     >>> _parsewith(b'foo($1)', syminitletters=_aliassyminitletters)
   560     ('func', ('symbol', 'foo'), ('symbol', '$1'))
   560     ('func', ('symbol', 'foo'), ('symbol', '$1'))
   561     >>> _parsewith(b'$1')
   561     >>> from . import error
   562     Traceback (most recent call last):
   562     >>> from . import pycompat
   563       ...
   563     >>> try:
   564     ParseError: ("syntax error in revset '$1'", 0)
   564     ...   _parsewith(b'$1')
   565     >>> _parsewith(b'foo bar')
   565     ... except error.ParseError as e:
   566     Traceback (most recent call last):
   566     ...   pycompat.sysstr(e.message)
   567       ...
   567     ...   e.location
   568     ParseError: ('invalid token', 4)
   568     "syntax error in revset '$1'"
       
   569     0
       
   570     >>> try:
       
   571     ...   _parsewith(b'foo bar')
       
   572     ... except error.ParseError as e:
       
   573     ...   pycompat.sysstr(e.message)
       
   574     ...   e.location
       
   575     'invalid token'
       
   576     4
   569     """
   577     """
   570     if lookup and spec.startswith(b'revset(') and spec.endswith(b')'):
   578     if lookup and spec.startswith(b'revset(') and spec.endswith(b')'):
   571         lookup = None
   579         lookup = None
   572     p = parser.parser(elements)
   580     p = parser.parser(elements)
   573     tree, pos = p.parse(
   581     tree, pos = p.parse(