# HG changeset patch # User Steve Losh # Date 1475700749 0 # Node ID 5334581e231a5167d03689ff47b3a6fdf082011c # Parent 4d7402d28abf29f3e7600e6d77cae557f6a16c64# Parent 064a8c1d11beba9b42062e7586f0c4f0e7c0d786 Merge. diff -r 4d7402d28abf -r 5334581e231a prompt.py --- a/prompt.py Tue Oct 04 10:49:19 2016 +0000 +++ b/prompt.py Wed Oct 05 20:52:29 2016 +0000 @@ -124,6 +124,13 @@ currently at my-bookmark See 'hg help prompt-keywords' for a list of available keywords. + + The format string may also be defined in an hgrc file:: + + [prompt] + template = {currently at {bookmark}} + + This is used when no format string is passed on the command line. ''' def _basename(m): @@ -392,7 +399,6 @@ return _with_groups(m.groups(), '^') if current_rev.children() else '' - if opts.get("angle_brackets"): tag_start = r'\<([^><]*?\<)?' tag_end = r'(\>[^><]*?)?>' @@ -463,6 +469,9 @@ if opts.get("cache_outgoing"): _cache_remote(repo, 'outgoing') + if not fs: + fs = repo.ui.config("prompt", "template", "") + for tag, repl in patterns.items(): fs = re.sub(tag_start + tag + tag_end, repl, fs) ui.status(fs) diff -r 4d7402d28abf -r 5334581e231a tests/test_hgrc.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_hgrc.py Wed Oct 05 20:52:29 2016 +0000 @@ -0,0 +1,23 @@ +'''Test evaluation of prompt template in HGRC.''' + +from nose import * +from util import * + + +@with_setup(setup_sandbox, teardown_sandbox) +def test_hgrc(): + + with open(os.path.join(sandbox_path, '.hg', 'hgrc'), 'w') as fp: + fp.write('[prompt]\ntemplate = foo\n') + + output = prompt(fs='') + assert output == 'foo' + + output = prompt(fs='bar') + assert output == 'bar' # command line overwrites hgrc + + with open(os.path.join(sandbox_path, '.hg', 'hgrc'), 'w') as fp: + fp.write('[prompt]\ntemplate = { at node {node}}\n') + + output = prompt(fs='') + assert output == ' at node 0000000000000000000000000000000000000000'