formatter: provide hint of referenced field names
authorYuya Nishihara <yuya@tcha.org>
Thu, 03 May 2018 11:56:49 +0900
changeset 38356 8221df643176
parent 38355 d4fae9a0ab1f
child 38357 31ed65f9c5ad
formatter: provide hint of referenced field names I don't like the function name, but I call it datahint() for consistency with another function I'll add later, fm.contexthint().
mercurial/formatter.py
--- a/mercurial/formatter.py	Thu May 03 11:53:56 2018 +0900
+++ b/mercurial/formatter.py	Thu May 03 11:56:49 2018 +0900
@@ -198,6 +198,9 @@
         assert all(k in {'ctx', 'fctx'} for k in ctxs)
         if self._converter.storecontext:
             self._item.update(ctxs)
+    def datahint(self):
+        '''set of field names to be referenced'''
+        return set()
     def data(self, **data):
         '''insert data into item that's not shown in default output'''
         data = pycompat.byteskwargs(data)
@@ -411,6 +414,14 @@
         ref = self._parts[part]
         self._out.write(self._t.render(ref, item))
 
+    @util.propertycache
+    def _symbolsused(self):
+        return self._t.symbolsuseddefault()
+
+    def datahint(self):
+        '''set of field names to be referenced from the template'''
+        return self._symbolsused[0]
+
     def end(self):
         baseformatter.end(self)
         self._renderitem('docfooter', {})