[PATCH 6 of 6] cmdutil: extract file copies closure into templatekw

Patrick Mezard pmezard at gmail.com
Mon Nov 30 16:34:46 CST 2009


# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1259616498 -3600
# Node ID 1abd1f8f497f68834af8d18a1bdc4b358f1c05b8
# Parent  c892c6cc06cbdab1354e0af2312d74eb7061ab52
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
@@ -784,21 +784,13 @@
                        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['cache'] = {}
+        props['cache'] = {'copies': copies}
 
         # 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 showfileadds(repo, ctx, templ, cache, **args):
     return showlist(templ, 'file_add', getfiles(repo, ctx, cache)[1], **args)
 
+def showfilecopies(repo, ctx, templ, cache, **args):
+    c = [{'name': x[0], 'source': x[1]} for x in cache['copies']]
+    return showlist(templ, 'file_copy', c, plural='file_copies', **args)
+
 def showfiledels(repo, ctx, templ, cache, **args):
     return showlist(templ, 'file_del', getfiles(repo, ctx, cache)[2], **args)
 
@@ -179,6 +183,7 @@
     'diffstat': showdiffstat,
     'extras': showextras,
     'file_adds': showfileadds,
+    'file_copies': showfilecopies,
     'file_dels': showfiledels,
     'file_mods': showfilemods,
     'files': showfiles,


More information about the Mercurial-devel mailing list