Mercurial > hg
changeset 16146:267cebac84c3
test-glog.t: use printrevset extension to trace rewritten revsets
Using "hg log -G --print-revset" prints the revset generated by graphlog and
exits. This helps debugging and writing shorter tests.
It has been suggested to handle these tests with doctests. I think the
extension approach is better because:
- It tests the actual parameter set passed to graphlog.revset(), not what we
expect it to be. 'branch' and 'only-branch' are currently distinct options
but nothing prevents fancyopts to grow a notion of option aliasing one day,
where both options would be merged before reaching the command.
- It can be used as debug output interleaved with real log calls.
v2:
- Use a test extension instead of a global deprecated new option
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Wed, 22 Feb 2012 12:30:14 +0100 |
parents | 7ee1d0dd7ca3 |
children | 5607d829bf17 |
files | tests/test-glog.t |
diffstat | 1 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-glog.t Wed Feb 22 15:22:12 2012 -0600 +++ b/tests/test-glog.t Wed Feb 22 12:30:14 2012 +0100 @@ -83,8 +83,26 @@ > hg commit -Aqd "$rev 0" -m "($rev) $msg" > } + $ cat > printrevset.py <<EOF + > from mercurial import extensions, revset, commands + > from hgext import graphlog + > + > def uisetup(ui): + > def printrevset(orig, ui, repo, *pats, **opts): + > if opts.get('print_revset'): + > expr = graphlog.revset(pats, opts) + > tree = revset.parse(expr)[0] + > ui.write(tree, "\n") + > return 0 + > return orig(ui, repo, *pats, **opts) + > entry = extensions.wrapcommand(commands.table, 'log', printrevset) + > entry[1].append(('', 'print-revset', False, + > 'print generated revset and exit (DEPRECATED)')) + > EOF + $ echo "[extensions]" >> $HGRCPATH $ echo "graphlog=" >> $HGRCPATH + $ echo "printrevset=`pwd`/printrevset.py" >> $HGRCPATH $ hg init repo $ cd repo @@ -1400,7 +1418,8 @@ $ hg log -G -b 'something nice' abort: unknown revision 'something nice'! [255] - $ hg log -G -k 'something nice' + $ hg log -G --print-revset -k 'something' -k 'nice' + ('group', ('and', ('func', ('symbol', 'keyword'), ('string', 'something')), ('func', ('symbol', 'keyword'), ('string', 'nice')))) $ hg log -G --only-branch 'something nice' abort: unknown revision 'something nice'! [255]