On Wed, 18 Jan 2017 08:44:55 -0500, Yuya Nishihara <y...@tcha.org> wrote:

On Tue, 17 Jan 2017 23:50:47 -0500, Matt Harbison wrote:
# HG changeset patch
# User Matt Harbison <matt_harbi...@yahoo.com>
# Date 1484712774 18000
#      Tue Jan 17 23:12:54 2017 -0500
# Node ID fce42f9dba7bab71463c0bcec44e6d87fdf275b2
# Parent  5a03e25ec0c0417e915b2014995bd83443ef97ec
templater: add '{envvars}' to access environment variables

Since the option for ui.exportableenviron is experimental, so is this template
until the underlying API is sorted out.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1448,7 +1448,8 @@
             'parent': '{rev}:{node|formatnode} ',
             'manifest': '{rev}:{node|formatnode}',
             'file_copy': '{name} ({source})',
-            'extra': '{key}={value|stringescape}'
+            'extra': '{key}={value|stringescape}',
+            'envvar': '{key}={value|stringescape}'

Dropped '|stringescape' since {envvar} should be readable text in general.

The only reason I thought it was necessary is because MSYS is apparently putting a couple '\n' in $PS1.

$ ../hg log -r . -T "{get(envvars, 'PS1')}" --config "experimental.exportableenviron=*"
\[\033]0;$MSYSTEM:\w\007
\033[32m\]\u@\h \[\033[33m\w\033[0m\]

vs

$ echo $PS1
\[\033]0;$MSYSTEM:\w\007 \033[32m\]\u@\h \[\033[33m\w\033[0m\] $

Maybe that's too much of a corner case to care. Dropping the escaping also prevents the Windows paths from showing as 'C:\\Windows\\..', so maybe that's a good thing.


--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -303,6 +303,18 @@
     maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
     return '%s: +%s/-%s' % (len(stats), adds, removes)

+@templatekeyword('envvars')
+def showenviron(repo, **args):

s/showenviron/showenvvars/
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to