Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 10056:1a114aca93fa
cmdutil: extract file changes closures into templatekw
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sun, 13 Dec 2009 18:06:24 +0100 |
parents | e400a511e63a |
children | babc00a82c5e |
comparison
equal
deleted
inserted
replaced
10055:e400a511e63a | 10056:1a114aca93fa |
---|---|
818 return showlist(templ, 'parent', parents, **args) | 818 return showlist(templ, 'parent', parents, **args) |
819 | 819 |
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] |
839 def showlatesttagdistance(repo, ctx, templ, **args): | 826 def showlatesttagdistance(repo, ctx, templ, **args): |
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, |
849 'latesttagdistance': showlatesttagdistance, | 833 'latesttagdistance': showlatesttagdistance, |
850 } | 834 } |
852 props.update(templatekw.keywords) | 836 props.update(templatekw.keywords) |
853 props.update(defprops) | 837 props.update(defprops) |
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 |
860 tmplmodes = [ | 845 tmplmodes = [ |
861 (True, None), | 846 (True, None), |