Show More
@@ -251,13 +251,8 b' class basealiasrules(object):' | |||||
251 | raise TypeError("'%s' is not instantiatable" % cls.__name__) |
|
251 | raise TypeError("'%s' is not instantiatable" % cls.__name__) | |
252 |
|
252 | |||
253 | @staticmethod |
|
253 | @staticmethod | |
254 |
def _parse |
|
254 | def _parse(spec): | |
255 |
"""Parse an alias name |
|
255 | """Parse an alias name, arguments and definition""" | |
256 | raise NotImplementedError |
|
|||
257 |
|
||||
258 | @staticmethod |
|
|||
259 | def _parsedefn(spec): |
|
|||
260 | """Parse an alias definition""" |
|
|||
261 | raise NotImplementedError |
|
256 | raise NotImplementedError | |
262 |
|
257 | |||
263 | @staticmethod |
|
258 | @staticmethod | |
@@ -270,7 +265,7 b' class basealiasrules(object):' | |||||
270 | """Parse an alias declaration into ``(name, tree, args, errorstr)`` |
|
265 | """Parse an alias declaration into ``(name, tree, args, errorstr)`` | |
271 |
|
266 | |||
272 | This function analyzes the parsed tree. The parsing rule is provided |
|
267 | This function analyzes the parsed tree. The parsing rule is provided | |
273 |
by ``_parse |
|
268 | by ``_parse()``. | |
274 |
|
269 | |||
275 | - ``name``: of declared alias (may be ``decl`` itself at error) |
|
270 | - ``name``: of declared alias (may be ``decl`` itself at error) | |
276 | - ``tree``: parse result (or ``None`` at error) |
|
271 | - ``tree``: parse result (or ``None`` at error) | |
@@ -311,7 +306,7 b' class basealiasrules(object):' | |||||
311 | ... return list(tree[1:]) |
|
306 | ... return list(tree[1:]) | |
312 | ... return [tree] |
|
307 | ... return [tree] | |
313 | >>> class aliasrules(basealiasrules): |
|
308 | >>> class aliasrules(basealiasrules): | |
314 |
... _parse |
|
309 | ... _parse = staticmethod(parse) | |
315 | ... _getlist = staticmethod(getlist) |
|
310 | ... _getlist = staticmethod(getlist) | |
316 | >>> builddecl = aliasrules._builddecl |
|
311 | >>> builddecl = aliasrules._builddecl | |
317 | >>> builddecl('foo') |
|
312 | >>> builddecl('foo') | |
@@ -342,7 +337,7 b' class basealiasrules(object):' | |||||
342 | ('foo', None, None, 'argument names collide with each other') |
|
337 | ('foo', None, None, 'argument names collide with each other') | |
343 | """ |
|
338 | """ | |
344 | try: |
|
339 | try: | |
345 |
tree = cls._parse |
|
340 | tree = cls._parse(decl) | |
346 | except error.ParseError as inst: |
|
341 | except error.ParseError as inst: | |
347 | return (decl, None, None, parseerrordetail(inst)) |
|
342 | return (decl, None, None, parseerrordetail(inst)) | |
348 |
|
343 | |||
@@ -392,7 +387,7 b' class basealiasrules(object):' | |||||
392 | """Parse an alias definition into a tree and marks substitutions |
|
387 | """Parse an alias definition into a tree and marks substitutions | |
393 |
|
388 | |||
394 | This function marks alias argument references as ``_aliasarg``. The |
|
389 | This function marks alias argument references as ``_aliasarg``. The | |
395 |
parsing rule is provided by ``_parse |
|
390 | parsing rule is provided by ``_parse()``. | |
396 |
|
391 | |||
397 | ``args`` is a list of alias argument names, or None if the alias |
|
392 | ``args`` is a list of alias argument names, or None if the alias | |
398 | is declared as a symbol. |
|
393 | is declared as a symbol. | |
@@ -404,7 +399,7 b' class basealiasrules(object):' | |||||
404 | ... '"$1" or "foo"': ('or', ('string', '$1'), ('string', 'foo')), |
|
399 | ... '"$1" or "foo"': ('or', ('string', '$1'), ('string', 'foo')), | |
405 | ... } |
|
400 | ... } | |
406 | >>> class aliasrules(basealiasrules): |
|
401 | >>> class aliasrules(basealiasrules): | |
407 |
... _parse |
|
402 | ... _parse = staticmethod(parsemap.__getitem__) | |
408 | ... _getlist = staticmethod(lambda x: []) |
|
403 | ... _getlist = staticmethod(lambda x: []) | |
409 | >>> builddefn = aliasrules._builddefn |
|
404 | >>> builddefn = aliasrules._builddefn | |
410 | >>> def pprint(tree): |
|
405 | >>> def pprint(tree): | |
@@ -429,7 +424,7 b' class basealiasrules(object):' | |||||
429 | ('string', '$1') |
|
424 | ('string', '$1') | |
430 | ('string', 'foo')) |
|
425 | ('string', 'foo')) | |
431 | """ |
|
426 | """ | |
432 |
tree = cls._parse |
|
427 | tree = cls._parse(defn) | |
433 | if args: |
|
428 | if args: | |
434 | args = set(args) |
|
429 | args = set(args) | |
435 | else: |
|
430 | else: |
@@ -2253,8 +2253,7 b' def _parsealias(spec):' | |||||
2253 | class _aliasrules(parser.basealiasrules): |
|
2253 | class _aliasrules(parser.basealiasrules): | |
2254 | """Parsing and expansion rule set of revset aliases""" |
|
2254 | """Parsing and expansion rule set of revset aliases""" | |
2255 | _section = _('revset alias') |
|
2255 | _section = _('revset alias') | |
2256 |
_parse |
|
2256 | _parse = staticmethod(_parsealias) | |
2257 | _parsedefn = staticmethod(_parsealias) |
|
|||
2258 | _getlist = staticmethod(getlist) |
|
2257 | _getlist = staticmethod(getlist) | |
2259 |
|
2258 | |||
2260 | class revsetalias(object): |
|
2259 | class revsetalias(object): |
General Comments 0
You need to be logged in to leave comments.
Login now