# HG changeset patch # User Yuya Nishihara # Date 1426498613 -32400 # Node ID 7d87f672d0690761302a4c8530d7719d5e0135dd # Parent c5022f3579b900c8bee1aef1e233b8900f0bf8a0 debugrevspec: show nesting structure of smartsets if verbose This shows how smartsets are constructed from the query. It will be somewhat useful to track problems such as stack overflow. diff -r c5022f3579b9 -r 7d87f672d069 mercurial/commands.py --- a/mercurial/commands.py Mon Mar 16 18:15:06 2015 +0900 +++ b/mercurial/commands.py Mon Mar 16 18:36:53 2015 +0900 @@ -2929,7 +2929,10 @@ weight, optimizedtree = revset.optimize(newtree, True) ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n") func = revset.match(ui, expr) - for c in func(repo): + revs = func(repo) + if ui.verbose: + ui.note("* set:\n", revset.prettyformatset(revs), "\n") + for c in revs: ui.write("%s\n" % c) @command('debugsetparents', [], _('REV1 [REV2]')) diff -r c5022f3579b9 -r 7d87f672d069 mercurial/revset.py --- a/mercurial/revset.py Mon Mar 16 18:15:06 2015 +0900 +++ b/mercurial/revset.py Mon Mar 16 18:36:53 2015 +0900 @@ -3419,5 +3419,19 @@ other.sort(reverse=self.isdescending()) return other +def prettyformatset(revs): + lines = [] + rs = repr(revs) + p = 0 + while p < len(rs): + q = rs.find('<', p + 1) + if q < 0: + q = len(rs) + l = rs.count('<', 0, p) - rs.count('>', 0, p) + assert l >= 0 + lines.append((l, rs[p:q].rstrip())) + p = q + return '\n'.join(' ' * l + s for l, s in lines) + # tell hggettext to extract docstrings from these functions: i18nfunctions = symbols.values() diff -r c5022f3579b9 -r 7d87f672d069 tests/test-revset-dirstate-parents.t --- a/tests/test-revset-dirstate-parents.t Mon Mar 16 18:15:06 2015 +0900 +++ b/tests/test-revset-dirstate-parents.t Mon Mar 16 18:36:53 2015 +0900 @@ -16,14 +16,20 @@ (func ('symbol', 'p1') None) + * set: + $ try 'p2()' (func ('symbol', 'p2') None) + * set: + $ try 'parents()' (func ('symbol', 'parents') None) + * set: + null revision $ log 'p1()' diff -r c5022f3579b9 -r 7d87f672d069 tests/test-revset.t --- a/tests/test-revset.t Mon Mar 16 18:15:06 2015 +0900 +++ b/tests/test-revset.t Mon Mar 16 18:36:53 2015 +0900 @@ -93,31 +93,83 @@ $ echo "[paths]" >> .hg/hgrc $ echo "default = ../remote1" >> .hg/hgrc +trivial + + $ try 0:1 + (range + ('symbol', '0') + ('symbol', '1')) + * set: + > + 0 + 1 + $ try 3::6 + (dagrange + ('symbol', '3') + ('symbol', '6')) + * set: + > + 3 + 5 + 6 + $ try '0|1|2' + (or + (or + ('symbol', '0') + ('symbol', '1')) + ('symbol', '2')) + * set: + , + >, + > + 0 + 1 + 2 + names that should work without quoting $ try a ('symbol', 'a') + * set: + 0 $ try b-a (minus ('symbol', 'b') ('symbol', 'a')) + * set: + > 1 $ try _a_b_c_ ('symbol', '_a_b_c_') + * set: + 6 $ try _a_b_c_-a (minus ('symbol', '_a_b_c_') ('symbol', 'a')) + * set: + > 6 $ try .a.b.c. ('symbol', '.a.b.c.') + * set: + 7 $ try .a.b.c.-a (minus ('symbol', '.a.b.c.') ('symbol', 'a')) + * set: + > 7 $ try -- '-a-b-c-' # complains hg: parse error at 7: not a prefix: end @@ -139,6 +191,8 @@ [255] $ try é ('symbol', '\xc3\xa9') + * set: + 9 no quoting needed @@ -154,6 +208,9 @@ (minus ('string', '-a-b-c-') ('symbol', 'a')) + * set: + > 4 $ log '1 or 2' @@ -170,6 +227,10 @@ ('symbol', '1') ('symbol', '2')) ('symbol', '3')) + * set: + , + > 3 $ try '1|2&3' (or @@ -177,6 +238,10 @@ (and ('symbol', '2') ('symbol', '3'))) + * set: + , + > 1 $ try '1&2&3' # associativity (and @@ -184,6 +249,8 @@ ('symbol', '1') ('symbol', '2')) ('symbol', '3')) + * set: + $ try '1|(2|3)' (or ('symbol', '1') @@ -191,6 +258,12 @@ (or ('symbol', '2') ('symbol', '3')))) + * set: + , + , + >> 1 2 3 @@ -325,10 +398,16 @@ (func ('symbol', 'grep') ('string', '\x08issue\\d+')) + * set: + > $ try 'grep(r"\bissue\d+")' (func ('symbol', 'grep') ('string', '\\bissue\\d+')) + * set: + > 6 $ try 'grep(r"\")' hg: parse error at 7: unterminated string @@ -691,6 +770,8 @@ (list ('symbol', '3') ('symbol', '1'))) + * set: + 3 $ try --optimize 'ancestors(1) - ancestors(3)' (minus @@ -706,6 +787,8 @@ (list ('symbol', '1') ('symbol', '3'))) + * set: + $ try --optimize 'not ::2 and ::6' (and (not @@ -719,6 +802,8 @@ (list ('symbol', '6') ('symbol', '2'))) + * set: + 3 4 5 @@ -738,6 +823,8 @@ (list ('symbol', '6') ('symbol', '4'))) + * set: + 3 5 6 @@ -974,6 +1061,9 @@ (func ('symbol', 'merge') None) + * set: + > 6 test alias recursion @@ -985,6 +1075,11 @@ (func ('symbol', 'merge') None)) + * set: + >, + > 6 7 @@ -1014,6 +1109,12 @@ (or ('symbol', '1') ('symbol', '2'))) + * set: + , + , + >> 3 1 2 @@ -1034,6 +1135,8 @@ (range ('symbol', '2') ('symbol', '5'))) + * set: + 5 test variable isolation, variable placeholders are rewritten as string @@ -1070,17 +1173,23 @@ ('symbol', 'tip') warning: failed to parse the definition of revset alias "anotherbadone": at 7: not a prefix: end warning: failed to parse the definition of revset alias "injectparamasstring2": unknown identifier: _aliasarg + * set: + 9 >>> data = file('.hg/hgrc', 'rb').read() >>> file('.hg/hgrc', 'wb').write(data.replace('_aliasarg', '')) $ try 'tip' ('symbol', 'tip') + * set: + 9 $ hg debugrevspec --debug --config revsetalias.'bad name'='tip' "tip" ('symbol', 'tip') warning: failed to parse the declaration of revset alias "bad name": at 4: invalid token + * set: + 9 $ echo 'strictreplacing($1, $10) = $10 or desc("$1")' >> .hg/hgrc $ try 'strictreplacing("foo", tip)' @@ -1094,6 +1203,12 @@ (func ('symbol', 'desc') ('string', '$1'))) + * set: + , + >>> 9 $ try 'd(2:5)' @@ -1111,6 +1226,8 @@ ('symbol', '2') ('symbol', '5')) ('symbol', 'date')))) + * set: + 4 5 3 @@ -1132,6 +1249,8 @@ ('symbol', '2') ('symbol', '3')) ('symbol', 'date')))) + * set: + 3 2 $ try 'rs()' @@ -1177,6 +1296,8 @@ ('symbol', '2') ('symbol', '3')) ('symbol', 'date')))) + * set: + 3 2 @@ -1317,6 +1438,8 @@ ('symbol', '1ee')) ('string', 'ce5')) ('string', '2785f51eece5') + * set: + 0 $ echo 'cat4($1, $2, $3, $4) = $1 ## $2 ## $3 ## $4' >> .hg/hgrc @@ -1338,6 +1461,8 @@ ('symbol', '1ee')) ('string', 'ce5')) ('string', '2785f51eece5') + * set: + 0 (check concatenation in alias nesting)