Show More
@@ -489,16 +489,14 b' def templatelabel(context, mapping, args' | |||
|
489 | 489 | # etc. don't need to be quoted |
|
490 | 490 | mapping.update(dict([(k, k) for k in _effects])) |
|
491 | 491 | |
|
492 |
thing = |
|
|
493 | thing = templater.stringify(thing) | |
|
492 | thing = templater.evalstring(context, mapping, args[1]) | |
|
494 | 493 | |
|
495 | 494 | # apparently, repo could be a string that is the favicon? |
|
496 | 495 | repo = mapping.get('repo', '') |
|
497 | 496 | if isinstance(repo, str): |
|
498 | 497 | return thing |
|
499 | 498 | |
|
500 |
label = |
|
|
501 | label = templater.stringify(label) | |
|
499 | label = templater.evalstring(context, mapping, args[0]) | |
|
502 | 500 | |
|
503 | 501 | return repo.ui.label(thing, label) |
|
504 | 502 |
@@ -227,6 +227,10 b' def evalinteger(context, mapping, arg, e' | |||
|
227 | 227 | except (TypeError, ValueError): |
|
228 | 228 | raise error.ParseError(err) |
|
229 | 229 | |
|
230 | def evalstring(context, mapping, arg): | |
|
231 | func, data = arg | |
|
232 | return stringify(func(context, mapping, data)) | |
|
233 | ||
|
230 | 234 | def runinteger(context, mapping, data): |
|
231 | 235 | return int(data) |
|
232 | 236 | |
@@ -339,7 +343,7 b' def date(context, mapping, args):' | |||
|
339 | 343 | date = evalfuncarg(context, mapping, args[0]) |
|
340 | 344 | fmt = None |
|
341 | 345 | if len(args) == 2: |
|
342 |
fmt = string |
|
|
346 | fmt = evalstring(context, mapping, args[1]) | |
|
343 | 347 | try: |
|
344 | 348 | if fmt is None: |
|
345 | 349 | return util.datestr(date) |
@@ -358,7 +362,7 b' def diff(context, mapping, args):' | |||
|
358 | 362 | |
|
359 | 363 | def getpatterns(i): |
|
360 | 364 | if i < len(args): |
|
361 |
s = string |
|
|
365 | s = evalstring(context, mapping, args[i]).strip() | |
|
362 | 366 | if s: |
|
363 | 367 | return [s] |
|
364 | 368 | return [] |
@@ -375,7 +379,7 b' def fill(context, mapping, args):' | |||
|
375 | 379 | # i18n: "fill" is a keyword |
|
376 | 380 | raise error.ParseError(_("fill expects one to four arguments")) |
|
377 | 381 | |
|
378 |
text = string |
|
|
382 | text = evalstring(context, mapping, args[0]) | |
|
379 | 383 | width = 76 |
|
380 | 384 | initindent = '' |
|
381 | 385 | hangindent = '' |
@@ -384,8 +388,8 b' def fill(context, mapping, args):' | |||
|
384 | 388 | # i18n: "fill" is a keyword |
|
385 | 389 | _("fill expects an integer width")) |
|
386 | 390 | try: |
|
387 |
initindent = string |
|
|
388 |
hangindent = string |
|
|
391 | initindent = evalstring(context, mapping, args[2]) | |
|
392 | hangindent = evalstring(context, mapping, args[3]) | |
|
389 | 393 | except IndexError: |
|
390 | 394 | pass |
|
391 | 395 | |
@@ -402,12 +406,12 b' def pad(context, mapping, args):' | |||
|
402 | 406 | # i18n: "pad" is a keyword |
|
403 | 407 | _("pad() expects an integer width")) |
|
404 | 408 | |
|
405 |
text = string |
|
|
409 | text = evalstring(context, mapping, args[0]) | |
|
406 | 410 | |
|
407 | 411 | right = False |
|
408 | 412 | fillchar = ' ' |
|
409 | 413 | if len(args) > 2: |
|
410 |
fillchar = string |
|
|
414 | fillchar = evalstring(context, mapping, args[2]) | |
|
411 | 415 | if len(args) > 3: |
|
412 | 416 | right = util.parsebool(args[3][1]) |
|
413 | 417 | |
@@ -425,11 +429,11 b' def indent(context, mapping, args):' | |||
|
425 | 429 | # i18n: "indent" is a keyword |
|
426 | 430 | raise error.ParseError(_("indent() expects two or three arguments")) |
|
427 | 431 | |
|
428 |
text = string |
|
|
429 |
indent = string |
|
|
432 | text = evalstring(context, mapping, args[0]) | |
|
433 | indent = evalstring(context, mapping, args[1]) | |
|
430 | 434 | |
|
431 | 435 | if len(args) == 3: |
|
432 |
firstline = string |
|
|
436 | firstline = evalstring(context, mapping, args[2]) | |
|
433 | 437 | else: |
|
434 | 438 | firstline = indent |
|
435 | 439 | |
@@ -459,7 +463,7 b' def if_(context, mapping, args):' | |||
|
459 | 463 | # i18n: "if" is a keyword |
|
460 | 464 | raise error.ParseError(_("if expects two or three arguments")) |
|
461 | 465 | |
|
462 |
test = string |
|
|
466 | test = evalstring(context, mapping, args[0]) | |
|
463 | 467 | if test: |
|
464 | 468 | yield args[1][0](context, mapping, args[1][1]) |
|
465 | 469 | elif len(args) == 3: |
@@ -472,7 +476,7 b' def ifcontains(context, mapping, args):' | |||
|
472 | 476 | # i18n: "ifcontains" is a keyword |
|
473 | 477 | raise error.ParseError(_("ifcontains expects three or four arguments")) |
|
474 | 478 | |
|
475 |
item = string |
|
|
479 | item = evalstring(context, mapping, args[0]) | |
|
476 | 480 | items = evalfuncarg(context, mapping, args[1]) |
|
477 | 481 | |
|
478 | 482 | if item in items: |
@@ -487,8 +491,8 b' def ifeq(context, mapping, args):' | |||
|
487 | 491 | # i18n: "ifeq" is a keyword |
|
488 | 492 | raise error.ParseError(_("ifeq expects three or four arguments")) |
|
489 | 493 | |
|
490 |
test = string |
|
|
491 |
match = string |
|
|
494 | test = evalstring(context, mapping, args[0]) | |
|
495 | match = evalstring(context, mapping, args[1]) | |
|
492 | 496 | if test == match: |
|
493 | 497 | yield args[2][0](context, mapping, args[2][1]) |
|
494 | 498 | elif len(args) == 4: |
@@ -507,7 +511,7 b' def join(context, mapping, args):' | |||
|
507 | 511 | |
|
508 | 512 | joiner = " " |
|
509 | 513 | if len(args) > 1: |
|
510 |
joiner = string |
|
|
514 | joiner = evalstring(context, mapping, args[1]) | |
|
511 | 515 | |
|
512 | 516 | first = True |
|
513 | 517 | for x in joinset: |
@@ -537,7 +541,7 b' def latesttag(context, mapping, args):' | |||
|
537 | 541 | |
|
538 | 542 | pattern = None |
|
539 | 543 | if len(args) == 1: |
|
540 |
pattern = string |
|
|
544 | pattern = evalstring(context, mapping, args[0]) | |
|
541 | 545 | |
|
542 | 546 | return templatekw.showlatesttags(pattern, **mapping) |
|
543 | 547 | |
@@ -576,7 +580,7 b' def revset(context, mapping, args):' | |||
|
576 | 580 | # i18n: "revset" is a keyword |
|
577 | 581 | raise error.ParseError(_("revset expects one or more arguments")) |
|
578 | 582 | |
|
579 |
raw = string |
|
|
583 | raw = evalstring(context, mapping, args[0]) | |
|
580 | 584 | ctx = mapping['ctx'] |
|
581 | 585 | repo = ctx.repo() |
|
582 | 586 | |
@@ -605,8 +609,8 b' def rstdoc(context, mapping, args):' | |||
|
605 | 609 | # i18n: "rstdoc" is a keyword |
|
606 | 610 | raise error.ParseError(_("rstdoc expects two arguments")) |
|
607 | 611 | |
|
608 |
text = string |
|
|
609 |
style = string |
|
|
612 | text = evalstring(context, mapping, args[0]) | |
|
613 | style = evalstring(context, mapping, args[1]) | |
|
610 | 614 | |
|
611 | 615 | return minirst.format(text, style=style, keep=['verbose']) |
|
612 | 616 | |
@@ -617,7 +621,7 b' def shortest(context, mapping, args):' | |||
|
617 | 621 | # i18n: "shortest" is a keyword |
|
618 | 622 | raise error.ParseError(_("shortest() expects one or two arguments")) |
|
619 | 623 | |
|
620 |
node = string |
|
|
624 | node = evalstring(context, mapping, args[0]) | |
|
621 | 625 | |
|
622 | 626 | minlength = 4 |
|
623 | 627 | if len(args) > 1: |
@@ -671,9 +675,9 b' def strip(context, mapping, args):' | |||
|
671 | 675 | # i18n: "strip" is a keyword |
|
672 | 676 | raise error.ParseError(_("strip expects one or two arguments")) |
|
673 | 677 | |
|
674 |
text = string |
|
|
678 | text = evalstring(context, mapping, args[0]) | |
|
675 | 679 | if len(args) == 2: |
|
676 |
chars = string |
|
|
680 | chars = evalstring(context, mapping, args[1]) | |
|
677 | 681 | return text.strip(chars) |
|
678 | 682 | return text.strip() |
|
679 | 683 | |
@@ -684,9 +688,9 b' def sub(context, mapping, args):' | |||
|
684 | 688 | # i18n: "sub" is a keyword |
|
685 | 689 | raise error.ParseError(_("sub expects three arguments")) |
|
686 | 690 | |
|
687 |
pat = string |
|
|
688 |
rpl = string |
|
|
689 |
src = string |
|
|
691 | pat = evalstring(context, mapping, args[0]) | |
|
692 | rpl = evalstring(context, mapping, args[1]) | |
|
693 | src = evalstring(context, mapping, args[2]) | |
|
690 | 694 | try: |
|
691 | 695 | patre = re.compile(pat) |
|
692 | 696 | except re.error: |
@@ -705,8 +709,8 b' def startswith(context, mapping, args):' | |||
|
705 | 709 | # i18n: "startswith" is a keyword |
|
706 | 710 | raise error.ParseError(_("startswith expects two arguments")) |
|
707 | 711 | |
|
708 |
patn = string |
|
|
709 |
text = string |
|
|
712 | patn = evalstring(context, mapping, args[0]) | |
|
713 | text = evalstring(context, mapping, args[1]) | |
|
710 | 714 | if text.startswith(patn): |
|
711 | 715 | return text |
|
712 | 716 | return '' |
@@ -722,9 +726,9 b' def word(context, mapping, args):' | |||
|
722 | 726 | num = evalinteger(context, mapping, args[0], |
|
723 | 727 | # i18n: "word" is a keyword |
|
724 | 728 | _("word expects an integer index")) |
|
725 |
text = string |
|
|
729 | text = evalstring(context, mapping, args[1]) | |
|
726 | 730 | if len(args) == 3: |
|
727 |
splitter = string |
|
|
731 | splitter = evalstring(context, mapping, args[2]) | |
|
728 | 732 | else: |
|
729 | 733 | splitter = None |
|
730 | 734 |
General Comments 0
You need to be logged in to leave comments.
Login now