Patchwork [5,of,6] templatekw: add {reporoot} keyword

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 15, 2018, 1:18 p.m.
Message ID <e7f4a2b09c484d4313aa.1518700723@mimosa>
Download mbox | patch
Permalink /patch/27972/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 15, 2018, 1:18 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1515377466 -32400
#      Mon Jan 08 11:11:06 2018 +0900
# Node ID e7f4a2b09c484d4313aa6624470d92aef3ad5a10
# Parent  dd83fddddb7ec9991355495a72c15b718561780b
templatekw: add {reporoot} keyword

The "%b" in filename format string will be replaced with "{reporoot|basename}".

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -726,6 +726,11 @@  def showpredecessors(repo, ctx, **args):
                    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
diff --git a/tests/test-basic.t b/tests/test-basic.t
--- a/tests/test-basic.t
+++ b/tests/test-basic.t
@@ -87,6 +87,13 @@  Verify should succeed:
   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 ..