comparison tests/test-revset.t @ 16771:2f3317d53d51 stable

revset: explicitely tag alias arguments for expansion The current revset alias expansion code works like: 1- Get the replacement tree 2- Substitute the variables in the replacement tree 3- Expand the replacement tree It makes it easy to substitute alias arguments because the placeholders are always replaced before the updated replacement tree is expanded again. Unfortunately, to fix other alias expansion issues, we need to reorder the sequence and delay the argument substitution. To solve this, a new "virtual" construct called _aliasarg() is introduced and injected when parsing the aliases definitions. Only _aliasarg() will be substituted in the argument expansion phase instead of all regular matching string. We also check user inputs do not contain unexpected _aliasarg() instances to avoid argument injections.
author Patrick Mezard <patrick@mezard.eu>
date Sat, 19 May 2012 17:18:29 +0200
parents 592e0beee8b0
children 30e46d7138de
comparison
equal deleted inserted replaced
16768:23a125545c3d 16771:2f3317d53d51
555 (func 555 (func
556 ('symbol', 'max') 556 ('symbol', 'max')
557 ('string', '$1'))) 557 ('string', '$1')))
558 abort: unknown revision '$1'! 558 abort: unknown revision '$1'!
559 [255] 559 [255]
560
561 $ echo 'injectparamasstring2 = max(_aliasarg("$1"))' >> .hg/hgrc
562 $ echo 'callinjection2($1) = descendants(injectparamasstring2)' >> .hg/hgrc
563 $ try 'callinjection2(2:5)'
564 (func
565 ('symbol', 'callinjection2')
566 (range
567 ('symbol', '2')
568 ('symbol', '5')))
569 hg: parse error: not a function: _aliasarg
570 [255]
571 >>> data = file('.hg/hgrc', 'rb').read()
572 >>> file('.hg/hgrc', 'wb').write(data.replace('_aliasarg', ''))
560 573
561 $ try 'd(2:5)' 574 $ try 'd(2:5)'
562 (func 575 (func
563 ('symbol', 'd') 576 ('symbol', 'd')
564 (range 577 (range