##// END OF EJS Templates
cmdutil: extract file changes closures into templatekw
Patrick Mezard -
r10056:1a114aca default
parent child Browse files
Show More
@@ -820,19 +820,6 b' class changeset_templater(changeset_prin'
820 def showcopies(repo, 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
824 files = []
825 def getfiles():
826 if not files:
827 files[:] = self.repo.status(ctx.parents()[0].node(),
828 ctx.node())[:3]
829 return files
830 def showmods(repo, ctx, templ, **args):
831 return showlist(templ, 'file_mod', getfiles()[0], **args)
832 def showadds(repo, ctx, templ, **args):
833 return showlist(templ, 'file_add', getfiles()[1], **args)
834 def showdels(repo, ctx, templ, **args):
835 return showlist(templ, 'file_del', getfiles()[2], **args)
836
823
837 def showlatesttag(repo, ctx, templ, **args):
824 def showlatesttag(repo, ctx, templ, **args):
838 return self._latesttaginfo(ctx.rev())[2]
825 return self._latesttaginfo(ctx.rev())[2]
@@ -840,9 +827,6 b' class changeset_templater(changeset_prin'
840 return self._latesttaginfo(ctx.rev())[1]
827 return self._latesttaginfo(ctx.rev())[1]
841
828
842 defprops = {
829 defprops = {
843 'file_adds': showadds,
844 'file_dels': showdels,
845 'file_mods': showmods,
846 'file_copies': showcopies,
830 'file_copies': showcopies,
847 'parents': showparents,
831 'parents': showparents,
848 'latesttag': showlatesttag,
832 'latesttag': showlatesttag,
@@ -854,6 +838,7 b' class changeset_templater(changeset_prin'
854 props['templ'] = self.t
838 props['templ'] = self.t
855 props['ctx'] = ctx
839 props['ctx'] = ctx
856 props['repo'] = self.repo
840 props['repo'] = self.repo
841 props['revcache'] = {}
857
842
858 # find correct templates for current mode
843 # find correct templates for current mode
859
844
@@ -69,6 +69,12 b' def showlist(templ, name, values, plural'
69 if endname in templ:
69 if endname in templ:
70 yield templ(endname, **args)
70 yield templ(endname, **args)
71
71
72 def getfiles(repo, ctx, revcache):
73 if 'files' not in revcache:
74 revcache['files'] = repo.status(ctx.parents()[0].node(),
75 ctx.node())[:3]
76 return revcache['files']
77
72 def showauthor(repo, ctx, templ, **args):
78 def showauthor(repo, ctx, templ, **args):
73 return ctx.user()
79 return ctx.user()
74
80
@@ -99,6 +105,15 b' def showextras(repo, ctx, templ, **args)'
99 args.update(dict(key=key, value=value))
105 args.update(dict(key=key, value=value))
100 yield templ('extra', **args)
106 yield templ('extra', **args)
101
107
108 def showfileadds(repo, ctx, templ, revcache, **args):
109 return showlist(templ, 'file_add', getfiles(repo, ctx, revcache)[1], **args)
110
111 def showfiledels(repo, ctx, templ, revcache, **args):
112 return showlist(templ, 'file_del', getfiles(repo, ctx, revcache)[2], **args)
113
114 def showfilemods(repo, ctx, templ, revcache, **args):
115 return showlist(templ, 'file_mod', getfiles(repo, ctx, revcache)[0], **args)
116
102 def showfiles(repo, ctx, templ, **args):
117 def showfiles(repo, ctx, templ, **args):
103 return showlist(templ, 'file', ctx.files(), **args)
118 return showlist(templ, 'file', ctx.files(), **args)
104
119
@@ -124,6 +139,9 b' keywords = {'
124 'desc': showdescription,
139 'desc': showdescription,
125 'diffstat': showdiffstat,
140 'diffstat': showdiffstat,
126 'extras': showextras,
141 'extras': showextras,
142 'file_adds': showfileadds,
143 'file_dels': showfiledels,
144 'file_mods': showfilemods,
127 'files': showfiles,
145 'files': showfiles,
128 'manifest': showmanifest,
146 'manifest': showmanifest,
129 'node': shownode,
147 'node': shownode,
@@ -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', 'repo'):
14 if k in ('templ', 'ctx', 'repo', 'revcache'):
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