# HG changeset patch # User Patrick Mezard # Date 1329910214 -3600 # Node ID 267cebac84c3f8dd8f746fee3e5ac0c620dd2e0c # Parent 7ee1d0dd7ca30306355ee705e915080882be2a06 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 diff -r 7ee1d0dd7ca3 -r 267cebac84c3 tests/test-glog.t --- 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 < 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]