##// END OF EJS Templates
templater: add '{envvars}' to access environment variables...
Matt Harbison -
r30833:bd5e9647 default
parent child Browse files
Show More
@@ -1448,6 +1448,7 b' class changeset_templater(changeset_prin'
1448 'parent': '{rev}:{node|formatnode} ',
1448 'parent': '{rev}:{node|formatnode} ',
1449 'manifest': '{rev}:{node|formatnode}',
1449 'manifest': '{rev}:{node|formatnode}',
1450 'file_copy': '{name} ({source})',
1450 'file_copy': '{name} ({source})',
1451 'envvar': '{key}={value}',
1451 'extra': '{key}={value|stringescape}'
1452 'extra': '{key}={value|stringescape}'
1452 }
1453 }
1453 # filecopy is preserved for compatibility reasons
1454 # filecopy is preserved for compatibility reasons
@@ -303,6 +303,18 b' def showdiffstat(repo, ctx, templ, **arg'
303 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
303 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
304 return '%s: +%s/-%s' % (len(stats), adds, removes)
304 return '%s: +%s/-%s' % (len(stats), adds, removes)
305
305
306 @templatekeyword('envvars')
307 def showenvvars(repo, **args):
308 """A dictionary of environment variables. (EXPERIMENTAL)"""
309
310 env = repo.ui.exportableenviron()
311 env = util.sortdict((k, env[k]) for k in sorted(env))
312 makemap = lambda k: {'key': k, 'value': env[k]}
313 c = [makemap(k) for k in env]
314 f = _showlist('envvar', c, plural='envvars', **args)
315 return _hybrid(f, env, makemap,
316 lambda x: '%s=%s' % (x['key'], x['value']))
317
306 @templatekeyword('extras')
318 @templatekeyword('extras')
307 def showextras(**args):
319 def showextras(**args):
308 """List of dicts with key, value entries of the 'extras'
320 """List of dicts with key, value entries of the 'extras'
@@ -68,3 +68,14 b' Test working directory'
68 $ echo b-wdir > b
68 $ echo b-wdir > b
69 $ hg cat -r 'wdir()' b
69 $ hg cat -r 'wdir()' b
70 b-wdir
70 b-wdir
71
72 Environment variables are not visible by default
73
74 $ PATTERN='t4' hg log -r '.' -T "{ifcontains('PATTERN', envvars, 'yes', 'no')}\n"
75 no
76
77 Environment variable visibility can be explicit
78
79 $ PATTERN='t4' hg log -r '.' -T "{envvars % '{key} -> {value}\n'}" \
80 > --config "experimental.exportableenviron=PATTERN"
81 PATTERN -> t4
General Comments 0
You need to be logged in to leave comments. Login now