Show More
@@ -812,12 +812,12 b' class changeset_templater(changeset_prin' | |||
|
812 | 812 | |
|
813 | 813 | showlist = templatekw.showlist |
|
814 | 814 | |
|
815 | def showparents(ctx, templ, **args): | |
|
815 | def showparents(repo, ctx, templ, **args): | |
|
816 | 816 | parents = [[('rev', p.rev()), ('node', p.hex())] |
|
817 | 817 | for p in self._meaningful_parentrevs(ctx)] |
|
818 | 818 | return showlist(templ, 'parent', parents, **args) |
|
819 | 819 | |
|
820 | def showcopies(ctx, templ, **args): | |
|
820 | def showcopies(repo, ctx, templ, **args): | |
|
821 | 821 | c = [{'name': x[0], 'source': x[1]} for x in copies] |
|
822 | 822 | return showlist(templ, 'file_copy', c, plural='file_copies', **args) |
|
823 | 823 | |
@@ -827,30 +827,16 b' class changeset_templater(changeset_prin' | |||
|
827 | 827 | files[:] = self.repo.status(ctx.parents()[0].node(), |
|
828 | 828 | ctx.node())[:3] |
|
829 | 829 | return files |
|
830 | def showmods(ctx, templ, **args): | |
|
830 | def showmods(repo, ctx, templ, **args): | |
|
831 | 831 | return showlist(templ, 'file_mod', getfiles()[0], **args) |
|
832 | def showadds(ctx, templ, **args): | |
|
832 | def showadds(repo, ctx, templ, **args): | |
|
833 | 833 | return showlist(templ, 'file_add', getfiles()[1], **args) |
|
834 | def showdels(ctx, templ, **args): | |
|
834 | def showdels(repo, ctx, templ, **args): | |
|
835 | 835 | return showlist(templ, 'file_del', getfiles()[2], **args) |
|
836 | def showmanifest(ctx, templ, **args): | |
|
837 | args = args.copy() | |
|
838 | args.update(dict(rev=self.repo.manifest.rev(ctx.changeset()[0]), | |
|
839 | node=hex(ctx.changeset()[0]))) | |
|
840 | return templ('manifest', **args) | |
|
841 | 836 | |
|
842 |
def show |
|
|
843 | diff = patch.diff(self.repo, ctx.parents()[0].node(), ctx.node()) | |
|
844 | files, adds, removes = 0, 0, 0 | |
|
845 | for i in patch.diffstatdata(util.iterlines(diff)): | |
|
846 | files += 1 | |
|
847 | adds += i[1] | |
|
848 | removes += i[2] | |
|
849 | return '%s: +%s/-%s' % (files, adds, removes) | |
|
850 | ||
|
851 | def showlatesttag(ctx, templ, **args): | |
|
837 | def showlatesttag(repo, ctx, templ, **args): | |
|
852 | 838 | return self._latesttaginfo(ctx.rev())[2] |
|
853 | def showlatesttagdistance(ctx, templ, **args): | |
|
839 | def showlatesttagdistance(repo, ctx, templ, **args): | |
|
854 | 840 | return self._latesttaginfo(ctx.rev())[1] |
|
855 | 841 | |
|
856 | 842 | defprops = { |
@@ -858,9 +844,7 b' class changeset_templater(changeset_prin' | |||
|
858 | 844 | 'file_dels': showdels, |
|
859 | 845 | 'file_mods': showmods, |
|
860 | 846 | 'file_copies': showcopies, |
|
861 | 'manifest': showmanifest, | |
|
862 | 847 | 'parents': showparents, |
|
863 | 'diffstat': showdiffstat, | |
|
864 | 848 | 'latesttag': showlatesttag, |
|
865 | 849 | 'latesttagdistance': showlatesttagdistance, |
|
866 | 850 | } |
@@ -869,6 +853,7 b' class changeset_templater(changeset_prin' | |||
|
869 | 853 | props.update(defprops) |
|
870 | 854 | props['templ'] = self.t |
|
871 | 855 | props['ctx'] = ctx |
|
856 | props['repo'] = self.repo | |
|
872 | 857 | |
|
873 | 858 | # find correct templates for current mode |
|
874 | 859 |
@@ -5,7 +5,8 b'' | |||
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2, incorporated herein by reference. |
|
7 | 7 | |
|
8 | import encoding | |
|
8 | from node import hex | |
|
9 | import encoding, patch, util | |
|
9 | 10 | |
|
10 | 11 | def showlist(templ, name, values, plural=None, **args): |
|
11 | 12 | '''expand set of values. |
@@ -68,37 +69,52 b' def showlist(templ, name, values, plural' | |||
|
68 | 69 | if endname in templ: |
|
69 | 70 | yield templ(endname, **args) |
|
70 | 71 | |
|
71 | def showauthor(ctx, templ, **args): | |
|
72 | def showauthor(repo, ctx, templ, **args): | |
|
72 | 73 | return ctx.user() |
|
73 | 74 | |
|
74 | def showbranches(ctx, templ, **args): | |
|
75 | def showbranches(repo, ctx, templ, **args): | |
|
75 | 76 | branch = ctx.branch() |
|
76 | 77 | if branch != 'default': |
|
77 | 78 | branch = encoding.tolocal(branch) |
|
78 | 79 | return showlist(templ, 'branch', [branch], plural='branches', **args) |
|
79 | 80 | |
|
80 | def showdate(ctx, templ, **args): | |
|
81 | def showdate(repo, ctx, templ, **args): | |
|
81 | 82 | return ctx.date() |
|
82 | 83 | |
|
83 | def showdescription(ctx, templ, **args): | |
|
84 | def showdescription(repo, ctx, templ, **args): | |
|
84 | 85 | return ctx.description().strip() |
|
85 | 86 | |
|
86 |
def show |
|
|
87 | def showdiffstat(repo, ctx, templ, **args): | |
|
88 | diff = patch.diff(repo, ctx.parents()[0].node(), ctx.node()) | |
|
89 | files, adds, removes = 0, 0, 0 | |
|
90 | for i in patch.diffstatdata(util.iterlines(diff)): | |
|
91 | files += 1 | |
|
92 | adds += i[1] | |
|
93 | removes += i[2] | |
|
94 | return '%s: +%s/-%s' % (files, adds, removes) | |
|
95 | ||
|
96 | def showextras(repo, ctx, templ, **args): | |
|
87 | 97 | for key, value in sorted(ctx.extra().items()): |
|
88 | 98 | args = args.copy() |
|
89 | 99 | args.update(dict(key=key, value=value)) |
|
90 | 100 | yield templ('extra', **args) |
|
91 | 101 | |
|
92 | def showfiles(ctx, templ, **args): | |
|
102 | def showfiles(repo, ctx, templ, **args): | |
|
93 | 103 | return showlist(templ, 'file', ctx.files(), **args) |
|
94 | 104 | |
|
95 |
def show |
|
|
105 | def showmanifest(repo, ctx, templ, **args): | |
|
106 | args = args.copy() | |
|
107 | args.update(dict(rev=repo.manifest.rev(ctx.changeset()[0]), | |
|
108 | node=hex(ctx.changeset()[0]))) | |
|
109 | return templ('manifest', **args) | |
|
110 | ||
|
111 | def shownode(repo, ctx, templ, **args): | |
|
96 | 112 | return ctx.hex() |
|
97 | 113 | |
|
98 | def showrev(ctx, templ, **args): | |
|
114 | def showrev(repo, ctx, templ, **args): | |
|
99 | 115 | return ctx.rev() |
|
100 | 116 | |
|
101 | def showtags(ctx, templ, **args): | |
|
117 | def showtags(repo, ctx, templ, **args): | |
|
102 | 118 | return showlist(templ, 'tag', ctx.tags(), **args) |
|
103 | 119 | |
|
104 | 120 | keywords = { |
@@ -106,8 +122,10 b' keywords = {' | |||
|
106 | 122 | 'branches': showbranches, |
|
107 | 123 | 'date': showdate, |
|
108 | 124 | 'desc': showdescription, |
|
125 | 'diffstat': showdiffstat, | |
|
109 | 126 | 'extras': showextras, |
|
110 | 127 | 'files': showfiles, |
|
128 | 'manifest': showmanifest, | |
|
111 | 129 | 'node': shownode, |
|
112 | 130 | 'rev': showrev, |
|
113 | 131 | 'tags': showtags, |
General Comments 0
You need to be logged in to leave comments.
Login now