# HG changeset patch # User Patrick Mezard # Date 2009-12-13 17:06:24 # Node ID c829563b3118d1cecc767918056de7ba921914e3 # Parent babc00a82c5ea612571c1799d5a91173c551da5e cmdutil: extract file copies closure into templatekw diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -786,26 +786,22 @@ class changeset_templater(changeset_prin showlist = templatekw.showlist + # showparents() behaviour depends on ui trace level which + # causes unexpected behaviours at templating level and makes + # it harder to extract it in a standalone function. Its + # behaviour cannot be changed so leave it here for now. def showparents(repo, ctx, templ, **args): parents = [[('rev', p.rev()), ('node', p.hex())] for p in self._meaningful_parentrevs(ctx)] return showlist(templ, 'parent', parents, **args) - def showcopies(repo, ctx, templ, **args): - c = [{'name': x[0], 'source': x[1]} for x in copies] - return showlist(templ, 'file_copy', c, plural='file_copies', **args) - - defprops = { - 'file_copies': showcopies, - 'parents': showparents, - } props = props.copy() props.update(templatekw.keywords) - props.update(defprops) + props['parents'] = showparents props['templ'] = self.t props['ctx'] = ctx props['repo'] = self.repo - props['revcache'] = {} + props['revcache'] = {'copies': copies} props['cache'] = self.cache # find correct templates for current mode diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -141,6 +141,10 @@ def showextras(repo, ctx, templ, **args) def showfileadds(repo, ctx, templ, revcache, **args): return showlist(templ, 'file_add', getfiles(repo, ctx, revcache)[1], **args) +def showfilecopies(repo, ctx, templ, revcache, **args): + c = [{'name': x[0], 'source': x[1]} for x in revcache['copies']] + return showlist(templ, 'file_copy', c, plural='file_copies', **args) + def showfiledels(repo, ctx, templ, revcache, **args): return showlist(templ, 'file_del', getfiles(repo, ctx, revcache)[2], **args) @@ -179,6 +183,7 @@ keywords = { 'diffstat': showdiffstat, 'extras': showextras, 'file_adds': showfileadds, + 'file_copies': showfilecopies, 'file_dels': showfiledels, 'file_mods': showfilemods, 'files': showfiles,