##// END OF EJS Templates
cmdutil: extract file copies closure into templatekw
Patrick Mezard -
r10058:c829563b default
parent child Browse files
Show More
@@ -786,26 +786,22 b' class changeset_templater(changeset_prin'
786
786
787 showlist = templatekw.showlist
787 showlist = templatekw.showlist
788
788
789 # showparents() behaviour depends on ui trace level which
790 # causes unexpected behaviours at templating level and makes
791 # it harder to extract it in a standalone function. Its
792 # behaviour cannot be changed so leave it here for now.
789 def showparents(repo, ctx, templ, **args):
793 def showparents(repo, ctx, templ, **args):
790 parents = [[('rev', p.rev()), ('node', p.hex())]
794 parents = [[('rev', p.rev()), ('node', p.hex())]
791 for p in self._meaningful_parentrevs(ctx)]
795 for p in self._meaningful_parentrevs(ctx)]
792 return showlist(templ, 'parent', parents, **args)
796 return showlist(templ, 'parent', parents, **args)
793
797
794 def showcopies(repo, ctx, templ, **args):
795 c = [{'name': x[0], 'source': x[1]} for x in copies]
796 return showlist(templ, 'file_copy', c, plural='file_copies', **args)
797
798 defprops = {
799 'file_copies': showcopies,
800 'parents': showparents,
801 }
802 props = props.copy()
798 props = props.copy()
803 props.update(templatekw.keywords)
799 props.update(templatekw.keywords)
804 props.update(defprops)
800 props['parents'] = showparents
805 props['templ'] = self.t
801 props['templ'] = self.t
806 props['ctx'] = ctx
802 props['ctx'] = ctx
807 props['repo'] = self.repo
803 props['repo'] = self.repo
808 props['revcache'] = {}
804 props['revcache'] = {'copies': copies}
809 props['cache'] = self.cache
805 props['cache'] = self.cache
810
806
811 # find correct templates for current mode
807 # find correct templates for current mode
@@ -141,6 +141,10 b' def showextras(repo, ctx, templ, **args)'
141 def showfileadds(repo, ctx, templ, revcache, **args):
141 def showfileadds(repo, ctx, templ, revcache, **args):
142 return showlist(templ, 'file_add', getfiles(repo, ctx, revcache)[1], **args)
142 return showlist(templ, 'file_add', getfiles(repo, ctx, revcache)[1], **args)
143
143
144 def showfilecopies(repo, ctx, templ, revcache, **args):
145 c = [{'name': x[0], 'source': x[1]} for x in revcache['copies']]
146 return showlist(templ, 'file_copy', c, plural='file_copies', **args)
147
144 def showfiledels(repo, ctx, templ, revcache, **args):
148 def showfiledels(repo, ctx, templ, revcache, **args):
145 return showlist(templ, 'file_del', getfiles(repo, ctx, revcache)[2], **args)
149 return showlist(templ, 'file_del', getfiles(repo, ctx, revcache)[2], **args)
146
150
@@ -179,6 +183,7 b' keywords = {'
179 'diffstat': showdiffstat,
183 'diffstat': showdiffstat,
180 'extras': showextras,
184 'extras': showextras,
181 'file_adds': showfileadds,
185 'file_adds': showfileadds,
186 'file_copies': showfilecopies,
182 'file_dels': showfiledels,
187 'file_dels': showfiledels,
183 'file_mods': showfilemods,
188 'file_mods': showfilemods,
184 'files': showfiles,
189 'files': showfiles,
General Comments 0
You need to be logged in to leave comments. Login now