# HG changeset patch # User Oben Sonne # Date 1475657122 -7200 # Node ID 003e92ae20da6855b50ffd4d0edf703f664969e9 # Parent 2e292ca8d7688a965488da61e0f7b8f55af1fbb9 Command line overwrites format string from HGRC Also extends help to mention hgrc setting. diff -r 2e292ca8d768 -r 003e92ae20da prompt.py --- a/prompt.py Thu Feb 27 14:39:40 2014 +0100 +++ b/prompt.py Wed Oct 05 10:45:22 2016 +0200 @@ -98,6 +98,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): @@ -426,9 +433,8 @@ if opts.get("cache_outgoing"): _cache_remote(repo, 'outgoing') - hgrc_fs = repo.ui.config("prompt", "template") - if hgrc_fs is not None: - fs = hgrc_fs + 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) diff -r 2e292ca8d768 -r 003e92ae20da tests/test_hgrc.py --- a/tests/test_hgrc.py Thu Feb 27 14:39:40 2014 +0100 +++ b/tests/test_hgrc.py Wed Oct 05 10:45:22 2016 +0200 @@ -8,16 +8,16 @@ def test_hgrc(): with open(os.path.join(sandbox_path, '.hg', 'hgrc'), 'w') as fp: - fp.write('[prompt]\ntemplate =\n') + fp.write('[prompt]\ntemplate = foo\n') - output = prompt(fs='{node}') - assert output == '' + 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='{node}') - assert output == ' at node 0000000000000000000000000000000000000000' - output = prompt(fs='') assert output == ' at node 0000000000000000000000000000000000000000'