Show More
@@ -302,6 +302,11 b' def tokenize(program, lookup=None, symin' | |||||
302 |
|
302 | |||
303 | # helpers |
|
303 | # helpers | |
304 |
|
304 | |||
|
305 | def getsymbol(x): | |||
|
306 | if x and x[0] == 'symbol': | |||
|
307 | return x[1] | |||
|
308 | raise error.ParseError(_('not a symbol')) | |||
|
309 | ||||
305 | def getstring(x, err): |
|
310 | def getstring(x, err): | |
306 | if x and (x[0] == 'string' or x[0] == 'symbol'): |
|
311 | if x and (x[0] == 'string' or x[0] == 'symbol'): | |
307 | return x[1] |
|
312 | return x[1] | |
@@ -414,13 +419,14 b' def keyvaluepair(repo, subset, k, v):' | |||||
414 | raise error.ParseError(_("can't use a key-value pair in this context")) |
|
419 | raise error.ParseError(_("can't use a key-value pair in this context")) | |
415 |
|
420 | |||
416 | def func(repo, subset, a, b): |
|
421 | def func(repo, subset, a, b): | |
417 | if a[0] == 'symbol' and a[1] in symbols: |
|
422 | f = getsymbol(a) | |
418 | return symbols[a[1]](repo, subset, b) |
|
423 | if f in symbols: | |
|
424 | return symbols[f](repo, subset, b) | |||
419 |
|
425 | |||
420 | keep = lambda fn: getattr(fn, '__doc__', None) is not None |
|
426 | keep = lambda fn: getattr(fn, '__doc__', None) is not None | |
421 |
|
427 | |||
422 | syms = [s for (s, fn) in symbols.items() if keep(fn)] |
|
428 | syms = [s for (s, fn) in symbols.items() if keep(fn)] | |
423 |
raise error.UnknownIdentifier( |
|
429 | raise error.UnknownIdentifier(f, syms) | |
424 |
|
430 | |||
425 | # functions |
|
431 | # functions | |
426 |
|
432 | |||
@@ -2304,11 +2310,11 b' def _matchonly(revs, bases):' | |||||
2304 | """ |
|
2310 | """ | |
2305 | if (revs is not None |
|
2311 | if (revs is not None | |
2306 | and revs[0] == 'func' |
|
2312 | and revs[0] == 'func' | |
2307 |
and gets |
|
2313 | and getsymbol(revs[1]) == 'ancestors' | |
2308 | and bases is not None |
|
2314 | and bases is not None | |
2309 | and bases[0] == 'not' |
|
2315 | and bases[0] == 'not' | |
2310 | and bases[1][0] == 'func' |
|
2316 | and bases[1][0] == 'func' | |
2311 |
and gets |
|
2317 | and getsymbol(bases[1][1]) == 'ancestors'): | |
2312 | return ('list', revs[2], bases[1][2]) |
|
2318 | return ('list', revs[2], bases[1][2]) | |
2313 |
|
2319 | |||
2314 | def _optimize(x, small): |
|
2320 | def _optimize(x, small): | |
@@ -2419,7 +2425,7 b' def _optimize(x, small):' | |||||
2419 | ws, ts = zip(*(_optimize(y, small) for y in x[1:])) |
|
2425 | ws, ts = zip(*(_optimize(y, small) for y in x[1:])) | |
2420 | return sum(ws), (op,) + ts |
|
2426 | return sum(ws), (op,) + ts | |
2421 | elif op == 'func': |
|
2427 | elif op == 'func': | |
2422 |
f = gets |
|
2428 | f = getsymbol(x[1]) | |
2423 | wa, ta = _optimize(x[2], small) |
|
2429 | wa, ta = _optimize(x[2], small) | |
2424 | if f in ("author branch closed date desc file grep keyword " |
|
2430 | if f in ("author branch closed date desc file grep keyword " | |
2425 | "outgoing user"): |
|
2431 | "outgoing user"): |
@@ -434,6 +434,12 b' quoting needed' | |||||
434 | 4 |
|
434 | 4 | |
435 | $ hg book -d date |
|
435 | $ hg book -d date | |
436 |
|
436 | |||
|
437 | function name should be a symbol | |||
|
438 | ||||
|
439 | $ log '"date"(2005)' | |||
|
440 | hg: parse error: not a symbol | |||
|
441 | [255] | |||
|
442 | ||||
437 | keyword arguments |
|
443 | keyword arguments | |
438 |
|
444 | |||
439 | $ log 'extra(branch, value=a)' |
|
445 | $ log 'extra(branch, value=a)' | |
@@ -2033,6 +2039,16 b' no crash by empty group "()" while optim' | |||||
2033 | hg: parse error: missing argument |
|
2039 | hg: parse error: missing argument | |
2034 | [255] |
|
2040 | [255] | |
2035 |
|
2041 | |||
|
2042 | invalid function call should not be optimized to only() | |||
|
2043 | ||||
|
2044 | $ log '"ancestors"(6) and not ancestors(4)' | |||
|
2045 | hg: parse error: not a symbol | |||
|
2046 | [255] | |||
|
2047 | ||||
|
2048 | $ log 'ancestors(6) and not "ancestors"(4)' | |||
|
2049 | hg: parse error: not a symbol | |||
|
2050 | [255] | |||
|
2051 | ||||
2036 | we can use patterns when searching for tags |
|
2052 | we can use patterns when searching for tags | |
2037 |
|
2053 | |||
2038 | $ log 'tag("1..*")' |
|
2054 | $ log 'tag("1..*")' |
General Comments 0
You need to be logged in to leave comments.
Login now