Patchwork [5,of,5] templatekw: add {path} keyword to host documentation

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 30, 2018, 1:09 p.m.
Message ID <28b0bc2ae464037066cb.1535634590@mimosa>
Download mbox | patch
Permalink /patch/34194/
State New
Headers show

Comments

Yuya Nishihara - Aug. 30, 2018, 1:09 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1533454410 -32400
#      Sun Aug 05 16:33:30 2018 +0900
# Node ID 28b0bc2ae464037066cb2c329e1f61648d9669d2
# Parent  ac97d9eb599ae018b73338cbfa2cd2062221b20d
templatekw: add {path} keyword to host documentation

It's hidden since I'm not sure if filectx templates can be a thing. The plan
is to add {status}, {size}, etc., which are usable within {files % ...}
context.
via Mercurial-devel - Aug. 30, 2018, 3:49 p.m.
On Thu, Aug 30, 2018 at 6:10 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1533454410 -32400
> #      Sun Aug 05 16:33:30 2018 +0900
> # Node ID 28b0bc2ae464037066cb2c329e1f61648d9669d2
> # Parent  ac97d9eb599ae018b73338cbfa2cd2062221b20d
> templatekw: add {path} keyword to host documentation
>

Queuing this, thanks!

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -543,6 +543,12 @@  def showobsolete(context, mapping):
         return 'obsolete'
     return ''
 
+@templatekeyword('path', requires={'fctx'})
+def showpath(context, mapping):
+    """String. Repository-absolute path of the current file. (EXPERIMENTAL)"""
+    fctx = context.resource(mapping, 'fctx')
+    return fctx.path()
+
 @templatekeyword('peerurls', requires={'repo'})
 def showpeerurls(context, mapping):
     """A dictionary of repository locations defined in the [paths] section