# HG changeset patch # User Steve Losh # Date 1245453166 14400 # Node ID 048db3b4a2a4246fae35a4b3bc507dcbd9d0f51b # Parent e1ea36d1bf0fbfc73c971bdcaca3a7cb4a8407d4 Add two tags. diff -r e1ea36d1bf0f -r 048db3b4a2a4 prompt.py --- a/prompt.py Fri Jun 19 18:12:33 2009 -0400 +++ b/prompt.py Fri Jun 19 19:12:46 2009 -0400 @@ -7,11 +7,24 @@ a bash prompt. ''' -from mercurial import hg +import re + def prompt(ui, repo, fs): """Take a format string, parse any variables, and output the result.""" - ui.write(fs) + + def _status(m): + stat = repo.status()[:4] + return '!' if any(stat[:3]) else '?' if stat[-1] else '' + + patterns = { + r'\{branch\}': lambda m: repo[-1].branch(), + r'\{status\}': _status, + } + + for pattern, repl in patterns.items(): + fs = re.sub(pattern, repl, fs) + print fs cmdtable = { # "command-name": (function-call, options-list, help-string)