Show More
@@ -2161,10 +2161,10 b' def debugrevspec(ui, repo, expr):' | |||||
2161 | """ |
|
2161 | """ | |
2162 | if ui.verbose: |
|
2162 | if ui.verbose: | |
2163 | tree = revset.parse(expr)[0] |
|
2163 | tree = revset.parse(expr)[0] | |
2164 | ui.note(tree, "\n") |
|
2164 | ui.note(revset.prettyformat(tree), "\n") | |
2165 | newtree = revset.findaliases(ui, tree) |
|
2165 | newtree = revset.findaliases(ui, tree) | |
2166 | if newtree != tree: |
|
2166 | if newtree != tree: | |
2167 | ui.note(newtree, "\n") |
|
2167 | ui.note(revset.prettyformat(newtree), "\n") | |
2168 | func = revset.match(ui, expr) |
|
2168 | func = revset.match(ui, expr) | |
2169 | for c in func(repo, range(len(repo))): |
|
2169 | for c in func(repo, range(len(repo))): | |
2170 | ui.write("%s\n" % c) |
|
2170 | ui.write("%s\n" % c) |
@@ -1319,5 +1319,20 b' def formatspec(expr, *args):' | |||||
1319 |
|
1319 | |||
1320 | return ret |
|
1320 | return ret | |
1321 |
|
1321 | |||
|
1322 | def prettyformat(tree): | |||
|
1323 | def _prettyformat(tree, level, lines): | |||
|
1324 | if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'): | |||
|
1325 | lines.append((level, str(tree))) | |||
|
1326 | else: | |||
|
1327 | lines.append((level, '(%s' % tree[0])) | |||
|
1328 | for s in tree[1:]: | |||
|
1329 | _prettyformat(s, level + 1, lines) | |||
|
1330 | lines[-1:] = [(lines[-1][0], lines[-1][1] + ')')] | |||
|
1331 | ||||
|
1332 | lines = [] | |||
|
1333 | _prettyformat(tree, 0, lines) | |||
|
1334 | output = '\n'.join((' '*l + s) for l, s in lines) | |||
|
1335 | return output | |||
|
1336 | ||||
1322 | # tell hggettext to extract docstrings from these functions: |
|
1337 | # tell hggettext to extract docstrings from these functions: | |
1323 | i18nfunctions = symbols.values() |
|
1338 | i18nfunctions = symbols.values() |
@@ -13,11 +13,17 b'' | |||||
13 | $ cd repo |
|
13 | $ cd repo | |
14 |
|
14 | |||
15 | $ try 'p1()' |
|
15 | $ try 'p1()' | |
16 | ('func', ('symbol', 'p1'), None) |
|
16 | (func | |
|
17 | ('symbol', 'p1') | |||
|
18 | None) | |||
17 | $ try 'p2()' |
|
19 | $ try 'p2()' | |
18 | ('func', ('symbol', 'p2'), None) |
|
20 | (func | |
|
21 | ('symbol', 'p2') | |||
|
22 | None) | |||
19 | $ try 'parents()' |
|
23 | $ try 'parents()' | |
20 | ('func', ('symbol', 'parents'), None) |
|
24 | (func | |
|
25 | ('symbol', 'parents') | |||
|
26 | None) | |||
21 |
|
27 | |||
22 | null revision |
|
28 | null revision | |
23 | $ log 'p1()' |
|
29 | $ log 'p1()' |
@@ -94,19 +94,25 b' names that should work without quoting' | |||||
94 | ('symbol', 'a') |
|
94 | ('symbol', 'a') | |
95 | 0 |
|
95 | 0 | |
96 | $ try b-a |
|
96 | $ try b-a | |
97 | ('minus', ('symbol', 'b'), ('symbol', 'a')) |
|
97 | (minus | |
|
98 | ('symbol', 'b') | |||
|
99 | ('symbol', 'a')) | |||
98 | 1 |
|
100 | 1 | |
99 | $ try _a_b_c_ |
|
101 | $ try _a_b_c_ | |
100 | ('symbol', '_a_b_c_') |
|
102 | ('symbol', '_a_b_c_') | |
101 | 6 |
|
103 | 6 | |
102 | $ try _a_b_c_-a |
|
104 | $ try _a_b_c_-a | |
103 | ('minus', ('symbol', '_a_b_c_'), ('symbol', 'a')) |
|
105 | (minus | |
|
106 | ('symbol', '_a_b_c_') | |||
|
107 | ('symbol', 'a')) | |||
104 | 6 |
|
108 | 6 | |
105 | $ try .a.b.c. |
|
109 | $ try .a.b.c. | |
106 | ('symbol', '.a.b.c.') |
|
110 | ('symbol', '.a.b.c.') | |
107 | 7 |
|
111 | 7 | |
108 | $ try .a.b.c.-a |
|
112 | $ try .a.b.c.-a | |
109 | ('minus', ('symbol', '.a.b.c.'), ('symbol', 'a')) |
|
113 | (minus | |
|
114 | ('symbol', '.a.b.c.') | |||
|
115 | ('symbol', 'a')) | |||
110 | 7 |
|
116 | 7 | |
111 | $ try -- '-a-b-c-' # complains |
|
117 | $ try -- '-a-b-c-' # complains | |
112 | hg: parse error at 7: not a prefix: end |
|
118 | hg: parse error at 7: not a prefix: end | |
@@ -114,7 +120,15 b' names that should work without quoting' | |||||
114 | $ log -a-b-c- # succeeds with fallback |
|
120 | $ log -a-b-c- # succeeds with fallback | |
115 | 4 |
|
121 | 4 | |
116 | $ try -- -a-b-c--a # complains |
|
122 | $ try -- -a-b-c--a # complains | |
117 | ('minus', ('minus', ('minus', ('negate', ('symbol', 'a')), ('symbol', 'b')), ('symbol', 'c')), ('negate', ('symbol', 'a'))) |
|
123 | (minus | |
|
124 | (minus | |||
|
125 | (minus | |||
|
126 | (negate | |||
|
127 | ('symbol', 'a')) | |||
|
128 | ('symbol', 'b')) | |||
|
129 | ('symbol', 'c')) | |||
|
130 | (negate | |||
|
131 | ('symbol', 'a'))) | |||
118 | abort: unknown revision '-a'! |
|
132 | abort: unknown revision '-a'! | |
119 | [255] |
|
133 | [255] | |
120 | $ try Γ© |
|
134 | $ try Γ© | |
@@ -124,7 +138,9 b' names that should work without quoting' | |||||
124 | quoting needed |
|
138 | quoting needed | |
125 |
|
139 | |||
126 | $ try '"-a-b-c-"-a' |
|
140 | $ try '"-a-b-c-"-a' | |
127 | ('minus', ('string', '-a-b-c-'), ('symbol', 'a')) |
|
141 | (minus | |
|
142 | ('string', '-a-b-c-') | |||
|
143 | ('symbol', 'a')) | |||
128 | 4 |
|
144 | 4 | |
129 |
|
145 | |||
130 | $ log '1 or 2' |
|
146 | $ log '1 or 2' | |
@@ -136,15 +152,32 b' quoting needed' | |||||
136 | $ log '1 and 2' |
|
152 | $ log '1 and 2' | |
137 | $ log '1&2' |
|
153 | $ log '1&2' | |
138 | $ try '1&2|3' # precedence - and is higher |
|
154 | $ try '1&2|3' # precedence - and is higher | |
139 | ('or', ('and', ('symbol', '1'), ('symbol', '2')), ('symbol', '3')) |
|
155 | (or | |
|
156 | (and | |||
|
157 | ('symbol', '1') | |||
|
158 | ('symbol', '2')) | |||
|
159 | ('symbol', '3')) | |||
140 | 3 |
|
160 | 3 | |
141 | $ try '1|2&3' |
|
161 | $ try '1|2&3' | |
142 | ('or', ('symbol', '1'), ('and', ('symbol', '2'), ('symbol', '3'))) |
|
162 | (or | |
|
163 | ('symbol', '1') | |||
|
164 | (and | |||
|
165 | ('symbol', '2') | |||
|
166 | ('symbol', '3'))) | |||
143 | 1 |
|
167 | 1 | |
144 | $ try '1&2&3' # associativity |
|
168 | $ try '1&2&3' # associativity | |
145 | ('and', ('and', ('symbol', '1'), ('symbol', '2')), ('symbol', '3')) |
|
169 | (and | |
|
170 | (and | |||
|
171 | ('symbol', '1') | |||
|
172 | ('symbol', '2')) | |||
|
173 | ('symbol', '3')) | |||
146 | $ try '1|(2|3)' |
|
174 | $ try '1|(2|3)' | |
147 | ('or', ('symbol', '1'), ('group', ('or', ('symbol', '2'), ('symbol', '3')))) |
|
175 | (or | |
|
176 | ('symbol', '1') | |||
|
177 | (group | |||
|
178 | (or | |||
|
179 | ('symbol', '2') | |||
|
180 | ('symbol', '3')))) | |||
148 | 1 |
|
181 | 1 | |
149 | 2 |
|
182 | 2 | |
150 | 3 |
|
183 | 3 | |
@@ -226,13 +259,19 b' quoting needed' | |||||
226 | $ log 'grep("issue\d+")' |
|
259 | $ log 'grep("issue\d+")' | |
227 | 6 |
|
260 | 6 | |
228 | $ try 'grep("(")' # invalid regular expression |
|
261 | $ try 'grep("(")' # invalid regular expression | |
229 | ('func', ('symbol', 'grep'), ('string', '(')) |
|
262 | (func | |
|
263 | ('symbol', 'grep') | |||
|
264 | ('string', '(')) | |||
230 | hg: parse error: invalid match pattern: unbalanced parenthesis |
|
265 | hg: parse error: invalid match pattern: unbalanced parenthesis | |
231 | [255] |
|
266 | [255] | |
232 | $ try 'grep("\bissue\d+")' |
|
267 | $ try 'grep("\bissue\d+")' | |
233 | ('func', ('symbol', 'grep'), ('string', '\x08issue\\d+')) |
|
268 | (func | |
|
269 | ('symbol', 'grep') | |||
|
270 | ('string', '\x08issue\\d+')) | |||
234 | $ try 'grep(r"\bissue\d+")' |
|
271 | $ try 'grep(r"\bissue\d+")' | |
235 | ('func', ('symbol', 'grep'), ('string', '\\bissue\\d+')) |
|
272 | (func | |
|
273 | ('symbol', 'grep') | |||
|
274 | ('string', '\\bissue\\d+')) | |||
236 | 6 |
|
275 | 6 | |
237 | $ try 'grep(r"\")' |
|
276 | $ try 'grep(r"\")' | |
238 | hg: parse error at 7: unterminated string |
|
277 | hg: parse error at 7: unterminated string | |
@@ -437,14 +476,20 b' aliases:' | |||||
437 |
|
476 | |||
438 | $ try m |
|
477 | $ try m | |
439 | ('symbol', 'm') |
|
478 | ('symbol', 'm') | |
440 | ('func', ('symbol', 'merge'), None) |
|
479 | (func | |
|
480 | ('symbol', 'merge') | |||
|
481 | None) | |||
441 | 6 |
|
482 | 6 | |
442 |
|
483 | |||
443 | test alias recursion |
|
484 | test alias recursion | |
444 |
|
485 | |||
445 | $ try sincem |
|
486 | $ try sincem | |
446 | ('symbol', 'sincem') |
|
487 | ('symbol', 'sincem') | |
447 | ('func', ('symbol', 'descendants'), ('func', ('symbol', 'merge'), None)) |
|
488 | (func | |
|
489 | ('symbol', 'descendants') | |||
|
490 | (func | |||
|
491 | ('symbol', 'merge') | |||
|
492 | None)) | |||
448 | 6 |
|
493 | 6 | |
449 | 7 |
|
494 | 7 | |
450 |
|
495 | |||
@@ -463,8 +508,16 b' test nesting and variable passing' | |||||
463 | $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc |
|
508 | $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc | |
464 | $ echo 'nested3($1) = max($1)' >> .hg/hgrc |
|
509 | $ echo 'nested3($1) = max($1)' >> .hg/hgrc | |
465 | $ try 'nested(2:5)' |
|
510 | $ try 'nested(2:5)' | |
466 | ('func', ('symbol', 'nested'), ('range', ('symbol', '2'), ('symbol', '5'))) |
|
511 | (func | |
467 | ('func', ('symbol', 'max'), ('range', ('symbol', '2'), ('symbol', '5'))) |
|
512 | ('symbol', 'nested') | |
|
513 | (range | |||
|
514 | ('symbol', '2') | |||
|
515 | ('symbol', '5'))) | |||
|
516 | (func | |||
|
517 | ('symbol', 'max') | |||
|
518 | (range | |||
|
519 | ('symbol', '2') | |||
|
520 | ('symbol', '5'))) | |||
468 | 5 |
|
521 | 5 | |
469 |
|
522 | |||
470 | test variable isolation, variable placeholders are rewritten as string |
|
523 | test variable isolation, variable placeholders are rewritten as string | |
@@ -474,38 +527,100 b' far away.' | |||||
474 | $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc |
|
527 | $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc | |
475 | $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc |
|
528 | $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc | |
476 | $ try 'callinjection(2:5)' |
|
529 | $ try 'callinjection(2:5)' | |
477 | ('func', ('symbol', 'callinjection'), ('range', ('symbol', '2'), ('symbol', '5'))) |
|
530 | (func | |
478 | ('func', ('symbol', 'descendants'), ('func', ('symbol', 'max'), ('string', '$1'))) |
|
531 | ('symbol', 'callinjection') | |
|
532 | (range | |||
|
533 | ('symbol', '2') | |||
|
534 | ('symbol', '5'))) | |||
|
535 | (func | |||
|
536 | ('symbol', 'descendants') | |||
|
537 | (func | |||
|
538 | ('symbol', 'max') | |||
|
539 | ('string', '$1'))) | |||
479 | abort: unknown revision '$1'! |
|
540 | abort: unknown revision '$1'! | |
480 | [255] |
|
541 | [255] | |
481 |
|
542 | |||
482 | $ try 'd(2:5)' |
|
543 | $ try 'd(2:5)' | |
483 | ('func', ('symbol', 'd'), ('range', ('symbol', '2'), ('symbol', '5'))) |
|
544 | (func | |
484 | ('func', ('symbol', 'reverse'), ('func', ('symbol', 'sort'), ('list', ('range', ('symbol', '2'), ('symbol', '5')), ('symbol', 'date')))) |
|
545 | ('symbol', 'd') | |
|
546 | (range | |||
|
547 | ('symbol', '2') | |||
|
548 | ('symbol', '5'))) | |||
|
549 | (func | |||
|
550 | ('symbol', 'reverse') | |||
|
551 | (func | |||
|
552 | ('symbol', 'sort') | |||
|
553 | (list | |||
|
554 | (range | |||
|
555 | ('symbol', '2') | |||
|
556 | ('symbol', '5')) | |||
|
557 | ('symbol', 'date')))) | |||
485 | 4 |
|
558 | 4 | |
486 | 5 |
|
559 | 5 | |
487 | 3 |
|
560 | 3 | |
488 | 2 |
|
561 | 2 | |
489 | $ try 'rs(2 or 3, date)' |
|
562 | $ try 'rs(2 or 3, date)' | |
490 | ('func', ('symbol', 'rs'), ('list', ('or', ('symbol', '2'), ('symbol', '3')), ('symbol', 'date'))) |
|
563 | (func | |
491 | ('func', ('symbol', 'reverse'), ('func', ('symbol', 'sort'), ('list', ('or', ('symbol', '2'), ('symbol', '3')), ('symbol', 'date')))) |
|
564 | ('symbol', 'rs') | |
|
565 | (list | |||
|
566 | (or | |||
|
567 | ('symbol', '2') | |||
|
568 | ('symbol', '3')) | |||
|
569 | ('symbol', 'date'))) | |||
|
570 | (func | |||
|
571 | ('symbol', 'reverse') | |||
|
572 | (func | |||
|
573 | ('symbol', 'sort') | |||
|
574 | (list | |||
|
575 | (or | |||
|
576 | ('symbol', '2') | |||
|
577 | ('symbol', '3')) | |||
|
578 | ('symbol', 'date')))) | |||
492 | 3 |
|
579 | 3 | |
493 | 2 |
|
580 | 2 | |
494 | $ try 'rs()' |
|
581 | $ try 'rs()' | |
495 | ('func', ('symbol', 'rs'), None) |
|
582 | (func | |
|
583 | ('symbol', 'rs') | |||
|
584 | None) | |||
496 | hg: parse error: invalid number of arguments: 0 |
|
585 | hg: parse error: invalid number of arguments: 0 | |
497 | [255] |
|
586 | [255] | |
498 | $ try 'rs(2)' |
|
587 | $ try 'rs(2)' | |
499 | ('func', ('symbol', 'rs'), ('symbol', '2')) |
|
588 | (func | |
|
589 | ('symbol', 'rs') | |||
|
590 | ('symbol', '2')) | |||
500 | hg: parse error: invalid number of arguments: 1 |
|
591 | hg: parse error: invalid number of arguments: 1 | |
501 | [255] |
|
592 | [255] | |
502 | $ try 'rs(2, data, 7)' |
|
593 | $ try 'rs(2, data, 7)' | |
503 | ('func', ('symbol', 'rs'), ('list', ('list', ('symbol', '2'), ('symbol', 'data')), ('symbol', '7'))) |
|
594 | (func | |
|
595 | ('symbol', 'rs') | |||
|
596 | (list | |||
|
597 | (list | |||
|
598 | ('symbol', '2') | |||
|
599 | ('symbol', 'data')) | |||
|
600 | ('symbol', '7'))) | |||
504 | hg: parse error: invalid number of arguments: 3 |
|
601 | hg: parse error: invalid number of arguments: 3 | |
505 | [255] |
|
602 | [255] | |
506 | $ try 'rs4(2 or 3, x, x, date)' |
|
603 | $ try 'rs4(2 or 3, x, x, date)' | |
507 | ('func', ('symbol', 'rs4'), ('list', ('list', ('list', ('or', ('symbol', '2'), ('symbol', '3')), ('symbol', 'x')), ('symbol', 'x')), ('symbol', 'date'))) |
|
604 | (func | |
508 | ('func', ('symbol', 'reverse'), ('func', ('symbol', 'sort'), ('list', ('or', ('symbol', '2'), ('symbol', '3')), ('symbol', 'date')))) |
|
605 | ('symbol', 'rs4') | |
|
606 | (list | |||
|
607 | (list | |||
|
608 | (list | |||
|
609 | (or | |||
|
610 | ('symbol', '2') | |||
|
611 | ('symbol', '3')) | |||
|
612 | ('symbol', 'x')) | |||
|
613 | ('symbol', 'x')) | |||
|
614 | ('symbol', 'date'))) | |||
|
615 | (func | |||
|
616 | ('symbol', 'reverse') | |||
|
617 | (func | |||
|
618 | ('symbol', 'sort') | |||
|
619 | (list | |||
|
620 | (or | |||
|
621 | ('symbol', '2') | |||
|
622 | ('symbol', '3')) | |||
|
623 | ('symbol', 'date')))) | |||
509 | 3 |
|
624 | 3 | |
510 | 2 |
|
625 | 2 | |
511 |
|
626 |
General Comments 0
You need to be logged in to leave comments.
Login now