Show More
@@ -48,10 +48,10 b' class _hybrid(object):' | |||
|
48 | 48 | return self._defaultgen() |
|
49 | 49 | def _defaultgen(self): |
|
50 | 50 | """Generator to stringify this as {join(self, ' ')}""" |
|
51 |
for i, |
|
|
51 | for i, x in enumerate(self._values): | |
|
52 | 52 | if i > 0: |
|
53 | 53 | yield ' ' |
|
54 |
yield self.joinfmt( |
|
|
54 | yield self.joinfmt(x) | |
|
55 | 55 | def itermaps(self): |
|
56 | 56 | makemap = self._makemap |
|
57 | 57 | for x in self._values: |
@@ -73,11 +73,11 b' class _hybrid(object):' | |||
|
73 | 73 | def hybriddict(data, key='key', value='value', fmt='%s=%s', gen=None): |
|
74 | 74 | """Wrap data to support both dict-like and string-like operations""" |
|
75 | 75 | return _hybrid(gen, data, lambda k: {key: k, value: data[k]}, |
|
76 |
lambda |
|
|
76 | lambda k: fmt % (k, data[k])) | |
|
77 | 77 | |
|
78 | 78 | def hybridlist(data, name, fmt='%s', gen=None): |
|
79 | 79 | """Wrap data to support both list-like and string-like operations""" |
|
80 |
return _hybrid(gen, data, lambda x: {name: x}, lambda |
|
|
80 | return _hybrid(gen, data, lambda x: {name: x}, lambda x: fmt % x) | |
|
81 | 81 | |
|
82 | 82 | def unwraphybrid(thing): |
|
83 | 83 | """Return an object which can be stringified possibly by using a legacy |
@@ -315,7 +315,7 b' def showbookmarks(**args):' | |||
|
315 | 315 | active = repo._activebookmark |
|
316 | 316 | makemap = lambda v: {'bookmark': v, 'active': active, 'current': active} |
|
317 | 317 | f = _showlist('bookmark', bookmarks, args) |
|
318 |
return _hybrid(f, bookmarks, makemap, |
|
|
318 | return _hybrid(f, bookmarks, makemap, pycompat.identity) | |
|
319 | 319 | |
|
320 | 320 | @templatekeyword('children') |
|
321 | 321 | def showchildren(**args): |
@@ -384,7 +384,7 b' def showextras(**args):' | |||
|
384 | 384 | c = [makemap(k) for k in extras] |
|
385 | 385 | f = _showlist('extra', c, args, plural='extras') |
|
386 | 386 | return _hybrid(f, extras, makemap, |
|
387 |
lambda |
|
|
387 | lambda k: '%s=%s' % (k, util.escapestr(extras[k]))) | |
|
388 | 388 | |
|
389 | 389 | @templatekeyword('file_adds') |
|
390 | 390 | def showfileadds(**args): |
@@ -510,7 +510,7 b' def showlatesttags(pattern, **args):' | |||
|
510 | 510 | |
|
511 | 511 | tags = latesttags[2] |
|
512 | 512 | f = _showlist('latesttag', tags, args, separator=':') |
|
513 |
return _hybrid(f, tags, makemap, |
|
|
513 | return _hybrid(f, tags, makemap, pycompat.identity) | |
|
514 | 514 | |
|
515 | 515 | @templatekeyword('latesttagdistance') |
|
516 | 516 | def showlatesttagdistance(repo, ctx, templ, cache, **args): |
@@ -584,7 +584,7 b' def shownamespaces(**args):' | |||
|
584 | 584 | 'colorname': colornames[ns], |
|
585 | 585 | } |
|
586 | 586 | |
|
587 |
return _hybrid(f, namespaces, makemap, |
|
|
587 | return _hybrid(f, namespaces, makemap, pycompat.identity) | |
|
588 | 588 | |
|
589 | 589 | @templatekeyword('node') |
|
590 | 590 | def shownode(repo, ctx, templ, **args): |
@@ -618,7 +618,7 b' def showpeerpaths(repo, **args):' | |||
|
618 | 618 | # no hybriddict() since d['path'] can't be formatted as a string. perhaps |
|
619 | 619 | # hybriddict() should call templatefilters.stringify(d[value]). |
|
620 | 620 | return _hybrid(None, paths, lambda k: {'name': k, 'path': paths[k]}, |
|
621 |
lambda |
|
|
621 | lambda k: '%s=%s' % (k, paths[k]['url'])) | |
|
622 | 622 | |
|
623 | 623 | @templatekeyword("predecessors") |
|
624 | 624 | def showpredecessors(repo, ctx, **args): |
@@ -629,7 +629,7 b' def showpredecessors(repo, ctx, **args):' | |||
|
629 | 629 | |
|
630 | 630 | return _hybrid(None, predecessors, |
|
631 | 631 | lambda x: {'ctx': repo[x], 'revcache': {}}, |
|
632 |
lambda |
|
|
632 | lambda x: scmutil.formatchangeid(repo[x])) | |
|
633 | 633 | |
|
634 | 634 | @templatekeyword("successorssets") |
|
635 | 635 | def showsuccessorssets(repo, ctx, **args): |
@@ -647,7 +647,7 b' def showsuccessorssets(repo, ctx, **args' | |||
|
647 | 647 | data = [] |
|
648 | 648 | for ss in ssets: |
|
649 | 649 | h = _hybrid(None, ss, lambda x: {'ctx': repo[x], 'revcache': {}}, |
|
650 |
lambda |
|
|
650 | lambda x: scmutil.formatchangeid(repo[x])) | |
|
651 | 651 | data.append(h) |
|
652 | 652 | |
|
653 | 653 | # Format the successorssets |
@@ -661,7 +661,7 b' def showsuccessorssets(repo, ctx, **args' | |||
|
661 | 661 | yield "; ".join(render(d) for d in data) |
|
662 | 662 | |
|
663 | 663 | return _hybrid(gen(data), data, lambda x: {'successorset': x}, |
|
664 | lambda d: d["successorset"]) | |
|
664 | pycompat.identity) | |
|
665 | 665 | |
|
666 | 666 | @templatekeyword("succsandmarkers") |
|
667 | 667 | def showsuccsandmarkers(repo, ctx, **args): |
@@ -687,7 +687,7 b' def showsuccsandmarkers(repo, ctx, **arg' | |||
|
687 | 687 | successors = [hex(n) for n in successors] |
|
688 | 688 | successors = _hybrid(None, successors, |
|
689 | 689 | lambda x: {'ctx': repo[x], 'revcache': {}}, |
|
690 |
lambda |
|
|
690 | lambda x: scmutil.formatchangeid(repo[x])) | |
|
691 | 691 | |
|
692 | 692 | # Format markers |
|
693 | 693 | finalmarkers = [] |
@@ -703,7 +703,7 b' def showsuccsandmarkers(repo, ctx, **arg' | |||
|
703 | 703 | data.append({'successors': successors, 'markers': finalmarkers}) |
|
704 | 704 | |
|
705 | 705 | f = _showlist('succsandmarkers', data, args) |
|
706 |
return _hybrid(f, data, lambda x: x, |
|
|
706 | return _hybrid(f, data, lambda x: x, pycompat.identity) | |
|
707 | 707 | |
|
708 | 708 | @templatekeyword('p1rev') |
|
709 | 709 | def showp1rev(repo, ctx, templ, **args): |
@@ -748,7 +748,7 b' def showparents(**args):' | |||
|
748 | 748 | for p in pctxs] |
|
749 | 749 | f = _showlist('parent', parents, args) |
|
750 | 750 | return _hybrid(f, prevs, lambda x: {'ctx': repo[int(x)], 'revcache': {}}, |
|
751 |
lambda |
|
|
751 | lambda x: scmutil.formatchangeid(repo[int(x)])) | |
|
752 | 752 | |
|
753 | 753 | @templatekeyword('phase') |
|
754 | 754 | def showphase(repo, ctx, templ, **args): |
@@ -775,7 +775,7 b' def showrevslist(name, revs, **args):' | |||
|
775 | 775 | f = _showlist(name, revs, args) |
|
776 | 776 | return _hybrid(f, revs, |
|
777 | 777 | lambda x: {name: x, 'ctx': repo[int(x)], 'revcache': {}}, |
|
778 |
|
|
|
778 | pycompat.identity) | |
|
779 | 779 | |
|
780 | 780 | @templatekeyword('subrepos') |
|
781 | 781 | def showsubrepos(**args): |
@@ -768,10 +768,7 b' def join(context, mapping, args):' | |||
|
768 | 768 | # TODO: perhaps this should be evalfuncarg(), but it can't because hgweb |
|
769 | 769 | # abuses generator as a keyword that returns a list of dicts. |
|
770 | 770 | joinset = evalrawexp(context, mapping, args[0]) |
|
771 | if util.safehasattr(joinset, 'itermaps'): | |
|
772 | jf = joinset.joinfmt | |
|
773 | joinset = [jf(x) for x in joinset.itermaps()] | |
|
774 | ||
|
771 | joinfmt = getattr(joinset, 'joinfmt', pycompat.identity) | |
|
775 | 772 | joiner = " " |
|
776 | 773 | if len(args) > 1: |
|
777 | 774 | joiner = evalstring(context, mapping, args[1]) |
@@ -782,7 +779,7 b' def join(context, mapping, args):' | |||
|
782 | 779 | first = False |
|
783 | 780 | else: |
|
784 | 781 | yield joiner |
|
785 | yield x | |
|
782 | yield joinfmt(x) | |
|
786 | 783 | |
|
787 | 784 | @templatefunc('label(label, expr)') |
|
788 | 785 | def label(context, mapping, args): |
General Comments 0
You need to be logged in to leave comments.
Login now