Patchwork [3,of,5] templater: add public interface returning a set of resource keys

login
register
mail settings
Submitter Yuya Nishihara
Date April 7, 2018, 9:05 a.m.
Message ID <a5029147b12caa69c76c.1523091942@mimosa>
Download mbox | patch
Permalink /patch/30537/
State Accepted
Headers show

Comments

Yuya Nishihara - April 7, 2018, 9:05 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521115777 -32400
#      Thu Mar 15 21:09:37 2018 +0900
# Node ID a5029147b12caa69c76c5a4f9522e6b2c43ee5ae
# Parent  8a79a82137c6a5af4d88e32ec6646db6539e6d60
templater: add public interface returning a set of resource keys

The next patch depends on knownresourcekeys(), and there's no reason to
keep availableresourcekeys() private.

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -644,6 +644,14 @@  class engine(object):
             v = self._defaults.get(key)
         return v
 
+    def availableresourcekeys(self, mapping):
+        """Return a set of available resource keys based on the given mapping"""
+        return self._resources.availablekeys(self, mapping)
+
+    def knownresourcekeys(self):
+        """Return a set of supported resource keys"""
+        return self._resources.knownkeys()
+
     def resource(self, mapping, key):
         """Return internal data (e.g. cache) used for keyword/function
         evaluation"""