@@ 98,6 98,13 @@ def prompt(ui, repo, fs='', **opts):
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 @@ def prompt(ui, repo, fs='', **opts):
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)
@@ 8,16 8,16 @@ from util import *
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'