comparison tests/test-revset.t @ 33336:4672db164c98

revset: make repo.anyrevs accept customized alias override (API) Previously repo.anyrevs only expand aliases in [revsetalias] config. This patch makes it more flexible to accept a customized dict defining aliases without having to couple with ui. revsetlang.expandaliases now has the signature (tree, aliases, warn=None) which is more consistent with templater.expandaliases. revsetlang.py is now free from "ui", which seems to be a good thing.
author Jun Wu <quark@fb.com>
date Sat, 24 Jun 2017 15:29:42 -0700
parents 2428e8ec0793
children 5d63e5f40bea
comparison
equal deleted inserted replaced
33335:72f051f9a7d8 33336:4672db164c98
4257 $ hg debugrevspec "custom1()" 4257 $ hg debugrevspec "custom1()"
4258 *** failed to import extension custompredicate from $TESTTMP/custompredicate.py: intentional failure of loading extension 4258 *** failed to import extension custompredicate from $TESTTMP/custompredicate.py: intentional failure of loading extension
4259 hg: parse error: unknown identifier: custom1 4259 hg: parse error: unknown identifier: custom1
4260 [255] 4260 [255]
4261 4261
4262 Test repo.anyrevs with customized revset overrides
4263
4264 $ cat > $TESTTMP/printprevset.py <<EOF
4265 > from mercurial import encoding
4266 > def reposetup(ui, repo):
4267 > alias = {}
4268 > p = encoding.environ.get('P')
4269 > if p:
4270 > alias['P'] = p
4271 > revs = repo.anyrevs(['P'], user=True, localalias=alias)
4272 > ui.write('P=%r' % list(revs))
4273 > EOF
4274
4275 $ cat >> .hg/hgrc <<EOF
4276 > custompredicate = !
4277 > printprevset = $TESTTMP/printprevset.py
4278 > EOF
4279
4280 $ hg --config revsetalias.P=1 log -r . -T '\n'
4281 P=[1]
4282 $ P=3 hg --config revsetalias.P=2 log -r . -T '\n'
4283 P=[3]
4284
4262 $ cd .. 4285 $ cd ..