changeset 36247:48a6b1a22ccf

templatekw: add {reporoot} keyword The "%b" in filename format string will be replaced with "{reporoot|basename}".
author Yuya Nishihara <yuya@tcha.org>
date Mon, 08 Jan 2018 11:11:06 +0900
parents 9ee10b3284da
children 0ef50a5e3ae1
files mercurial/templatekw.py tests/test-basic.t
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Sun Jan 07 12:09:33 2018 +0900
+++ b/mercurial/templatekw.py	Mon Jan 08 11:11:06 2018 +0900
@@ -726,6 +726,11 @@
                    lambda x: {'ctx': repo[x], 'revcache': {}},
                    lambda x: scmutil.formatchangeid(repo[x]))
 
+@templatekeyword('reporoot')
+def showreporoot(repo, **args):
+    """String. The root directory of the current repository."""
+    return repo.root
+
 @templatekeyword("successorssets")
 def showsuccessorssets(repo, ctx, **args):
     """Returns a string of sets of successors for a changectx. Format used
--- a/tests/test-basic.t	Sun Jan 07 12:09:33 2018 +0900
+++ b/tests/test-basic.t	Mon Jan 08 11:11:06 2018 +0900
@@ -87,6 +87,13 @@
   checking files
   1 files, 1 changesets, 1 total revisions
 
+Repository root:
+
+  $ hg root
+  $TESTTMP/t
+  $ hg log -l1 -T '{reporoot}\n'
+  $TESTTMP/t
+
 At the end...
 
   $ cd ..