##// END OF EJS Templates
debugrevspec: add option to print parsed tree at given stages...
Yuya Nishihara -
r29913:9cb95027 default
parent child Browse files
Show More
@@ -3511,13 +3511,16 b' def debugrevlog(ui, repo, file_=None, **'
3511 numdeltas))
3511 numdeltas))
3512
3512
3513 @command('debugrevspec',
3513 @command('debugrevspec',
3514 [('', 'optimize', None, _('print parsed tree after optimizing'))],
3514 [('', 'optimize', None, _('print parsed tree after optimizing')),
3515 ('p', 'show-stage', [],
3516 _('print parsed tree at the given stage'), _('NAME')),
3517 ],
3515 ('REVSPEC'))
3518 ('REVSPEC'))
3516 def debugrevspec(ui, repo, expr, **opts):
3519 def debugrevspec(ui, repo, expr, **opts):
3517 """parse and apply a revision specification
3520 """parse and apply a revision specification
3518
3521
3519 Use --verbose to print the parsed tree before and after aliases
3522 Use -p/--show-stage option to print the parsed tree at the given stages.
3520 expansion.
3523 Use -p all to print tree at every stage.
3521 """
3524 """
3522 stages = [
3525 stages = [
3523 ('parsed', lambda tree: tree),
3526 ('parsed', lambda tree: tree),
@@ -3526,20 +3529,34 b' def debugrevspec(ui, repo, expr, **opts)'
3526 ('analyzed', revset.analyze),
3529 ('analyzed', revset.analyze),
3527 ('optimized', revset.optimize),
3530 ('optimized', revset.optimize),
3528 ]
3531 ]
3529
3532 stagenames = set(n for n, f in stages)
3530 showalways = set(['parsed'])
3533
3531 showchanged = set(['expanded', 'concatenated'])
3534 showalways = set()
3532 if opts['optimize']:
3535 showchanged = set()
3533 showalways.add('optimized')
3536 if ui.verbose and not opts['show_stage']:
3537 # show parsed tree by --verbose (deprecated)
3538 showalways.add('parsed')
3539 showchanged.update(['expanded', 'concatenated'])
3540 if opts['optimize']:
3541 showalways.add('optimized')
3542 if opts['show_stage'] and opts['optimize']:
3543 raise error.Abort(_('cannot use --optimize with --show-stage'))
3544 if opts['show_stage'] == ['all']:
3545 showalways.update(stagenames)
3546 else:
3547 for n in opts['show_stage']:
3548 if n not in stagenames:
3549 raise error.Abort(_('invalid stage name: %s') % n)
3550 showalways.update(opts['show_stage'])
3534
3551
3535 printedtree = None
3552 printedtree = None
3536 tree = revset.parse(expr, lookup=repo.__contains__)
3553 tree = revset.parse(expr, lookup=repo.__contains__)
3537 for n, f in stages:
3554 for n, f in stages:
3538 tree = f(tree)
3555 tree = f(tree)
3539 if n in showalways or (n in showchanged and tree != printedtree):
3556 if n in showalways or (n in showchanged and tree != printedtree):
3540 if n != 'parsed':
3557 if opts['show_stage'] or n != 'parsed':
3541 ui.note(("* %s:\n") % n)
3558 ui.write(("* %s:\n") % n)
3542 ui.note(revset.prettyformat(tree), "\n")
3559 ui.write(revset.prettyformat(tree), "\n")
3543 printedtree = tree
3560 printedtree = tree
3544
3561
3545 func = revset.match(ui, expr, repo)
3562 func = revset.match(ui, expr, repo)
@@ -269,7 +269,7 b' Show all commands + options'
269 debugrebuildfncache:
269 debugrebuildfncache:
270 debugrename: rev
270 debugrename: rev
271 debugrevlog: changelog, manifest, dir, dump
271 debugrevlog: changelog, manifest, dir, dump
272 debugrevspec: optimize
272 debugrevspec: optimize, show-stage
273 debugsetparents:
273 debugsetparents:
274 debugsub: rev
274 debugsub: rev
275 debugsuccessorssets:
275 debugsuccessorssets:
@@ -489,6 +489,56 b' keyword arguments'
489 hg: parse error: can't use a key-value pair in this context
489 hg: parse error: can't use a key-value pair in this context
490 [255]
490 [255]
491
491
492 parsed tree at stages:
493
494 $ hg debugrevspec -p all '()'
495 * parsed:
496 (group
497 None)
498 * expanded:
499 (group
500 None)
501 * concatenated:
502 (group
503 None)
504 * analyzed:
505 None
506 * optimized:
507 None
508 hg: parse error: missing argument
509 [255]
510
511 $ hg debugrevspec -p parsed -p analyzed -p optimized '(0|1)-1'
512 * parsed:
513 (minus
514 (group
515 (or
516 ('symbol', '0')
517 ('symbol', '1')))
518 ('symbol', '1'))
519 * analyzed:
520 (and
521 (or
522 ('symbol', '0')
523 ('symbol', '1'))
524 (not
525 ('symbol', '1')))
526 * optimized:
527 (difference
528 (func
529 ('symbol', '_list')
530 ('string', '0\x001'))
531 ('symbol', '1'))
532 0
533
534 $ hg debugrevspec -p unknown '0'
535 abort: invalid stage name: unknown
536 [255]
537
538 $ hg debugrevspec -p all --optimize '0'
539 abort: cannot use --optimize with --show-stage
540 [255]
541
492 Test that symbols only get parsed as functions if there's an opening
542 Test that symbols only get parsed as functions if there's an opening
493 parenthesis.
543 parenthesis.
494
544
General Comments 0
You need to be logged in to leave comments. Login now