Patchwork [5,of,9] log: do not invoke templatekw.showobsfate() as a function

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 27, 2018, 2:57 p.m.
Message ID <c5d3987504112f372d4d.1519743478@mimosa>
Download mbox | patch
Permalink /patch/28469/
State New
Headers show

Comments

Yuya Nishihara - Feb. 27, 2018, 2:57 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1519537338 -32400
#      Sun Feb 25 14:42:18 2018 +0900
# Node ID c5d3987504112f372d4d25dfa7e6dec1eb58d1af
# Parent  6b3af7c365816188dea95c2a10b0ddcb50f818b8
log: do not invoke templatekw.showobsfate() as a function

Prepares for switching to the (context, mapping) API. I tried, but it appeared
not an one-off change to extract a non-template function from showobsfate(),
which deeply depends on the templater internals.

Patch

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -278,7 +278,12 @@  class changesetprinter(object):
         self._showpatch(ctx)
 
     def _showobsfate(self, ctx):
-        obsfate = templatekw.showobsfate(repo=self.repo, ctx=ctx, ui=self.ui)
+        # TODO: do not depend on templater
+        tres = formatter.templateresources(self.repo.ui, self.repo)
+        t = formatter.maketemplater(self.repo.ui, '{join(obsfate, "\n")}',
+                                    defaults=templatekw.keywords,
+                                    resources=tres)
+        obsfate = t.render({'ctx': ctx, 'revcache': {}}).splitlines()
 
         if obsfate:
             for obsfateline in obsfate: