Patchwork [8,of,8] formatter: document lookuptemplate()

login
register
mail settings
Submitter Yuya Nishihara
Date June 14, 2017, 1:40 p.m.
Message ID <14130673e730fa675a72.1497447639@mimosa>
Download mbox | patch
Permalink /patch/21378/
State Accepted
Headers show

Comments

Yuya Nishihara - June 14, 2017, 1:40 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1494055461 -32400
#      Sat May 06 16:24:21 2017 +0900
# Node ID 14130673e730fa675a722369e2ca6d5ca1bce486
# Parent  1eebb6b06eb09504ee66daa8f02f3e6caa459b54
formatter: document lookuptemplate()
Augie Fackler - June 15, 2017, 1:46 a.m.
On Wed, Jun 14, 2017 at 10:40:39PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1494055461 -32400
> #      Sat May 06 16:24:21 2017 +0900
> # Node ID 14130673e730fa675a722369e2ca6d5ca1bce486
> # Parent  1eebb6b06eb09504ee66daa8f02f3e6caa459b54
> formatter: document lookuptemplate()

queued, thanks

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1647,8 +1647,9 @@  class changeset_templater(changeset_prin
                     self.t(self._parts['footer'], **props))
 
 def _lookuplogtemplate(ui, tmpl, style):
-    """
-    Find the template matching the given template spec or style.
+    """Find the template matching the given template spec or style
+
+    See formatter.lookuptemplate() for details.
     """
 
     # ui settings
diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -374,6 +374,21 @@  class templateformatter(baseformatter):
         self._out.write(templater.stringify(g))
 
 def lookuptemplate(ui, topic, tmpl):
+    """Find the template matching the given -T/--template spec 'tmpl'
+
+    'tmpl' can be any of the following:
+
+     - a literal template (e.g. '{rev}')
+     - a map-file name or path (e.g. 'changelog')
+     - a reference to [templates] in config file
+     - a path to raw template file
+
+    A map file defines a stand-alone template environment. If a map file
+    selected, all templates defined in the file will be loaded, and the
+    template matching the given topic will be rendered. No aliases will be
+    loaded from user config.
+    """
+
     # looks like a literal template?
     if '{' in tmpl:
         return tmpl, None