mercurial/templatekw.py
changeset 30833 bd5e9647f646
parent 30811 cf1e15f91c90
child 31171 1ec89cf0ea49
--- a/mercurial/templatekw.py	Tue Jan 17 23:05:12 2017 -0500
+++ b/mercurial/templatekw.py	Tue Jan 17 23:12:54 2017 -0500
@@ -303,6 +303,18 @@
     maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
     return '%s: +%s/-%s' % (len(stats), adds, removes)
 
+@templatekeyword('envvars')
+def showenvvars(repo, **args):
+    """A dictionary of environment variables. (EXPERIMENTAL)"""
+
+    env = repo.ui.exportableenviron()
+    env = util.sortdict((k, env[k]) for k in sorted(env))
+    makemap = lambda k: {'key': k, 'value': env[k]}
+    c = [makemap(k) for k in env]
+    f = _showlist('envvar', c, plural='envvars', **args)
+    return _hybrid(f, env, makemap,
+                   lambda x: '%s=%s' % (x['key'], x['value']))
+
 @templatekeyword('extras')
 def showextras(**args):
     """List of dicts with key, value entries of the 'extras'