comparison mercurial/cmdutil.py @ 10058:c829563b3118

cmdutil: extract file copies closure into templatekw
author Patrick Mezard <pmezard@gmail.com>
date Sun, 13 Dec 2009 18:06:24 +0100
parents babc00a82c5e
children f780b1098efc
comparison
equal deleted inserted replaced
10057:babc00a82c5e 10058:c829563b3118
784 def _show(self, ctx, copies, props): 784 def _show(self, ctx, copies, props):
785 '''show a single changeset or file revision''' 785 '''show a single changeset or file revision'''
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
812 808
813 tmplmodes = [ 809 tmplmodes = [