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