# HG changeset patch # User Steve Losh # Date 1475578159 0 # Node ID 4d7402d28abf29f3e7600e6d77cae557f6a16c64 # Parent 804a341f819be5ed0e7d31227d94fe88aeecf60d# Parent 8dd04e954ca9578f2485f9c95397c9ff0205b933 Merge. diff -r 8dd04e954ca9 -r 4d7402d28abf .hgignore --- a/.hgignore Mon Oct 03 11:46:47 2016 +0000 +++ b/.hgignore Tue Oct 04 10:49:19 2016 +0000 @@ -2,5 +2,7 @@ .DS_Store *.pyc +.idea/ docs/.html docs/.tmp + diff -r 8dd04e954ca9 -r 4d7402d28abf prompt.py --- a/prompt.py Mon Oct 03 11:46:47 2016 +0000 +++ b/prompt.py Tue Oct 04 10:49:19 2016 +0000 @@ -14,8 +14,10 @@ import os import subprocess from datetime import datetime, timedelta +from contextlib import closing from os import path from mercurial import extensions, commands, cmdutil, help +from mercurial.i18n import _ from mercurial.node import hex, short cmdtable = {} @@ -33,6 +35,7 @@ FILTER_ARG = re.compile(r'\|.+\((.*)\)') + def _cache_remote(repo, kind): cache = path.join(repo.root, CACHE_PATH, kind) c_tmp = cache + '.temp' @@ -58,6 +61,7 @@ os.rename(c_tmp, cache) return + def _with_groups(groups, out): out_groups = [groups[0]] + [groups[-1]] @@ -298,10 +302,12 @@ if cache_exists: with open(cache) as c: count = len(c.readlines()) - if g[1]: - return _with_groups(g, str(count)) if count else '' + if g[1] and count > 0: + return _with_groups(g, str(count)) + elif g[2]: + return _with_groups(g, '0') if not count else '' else: - return _with_groups(g, '') if count else '' + return _with_groups(g, '') else: return '' return _r @@ -441,8 +447,14 @@ ')*': _tip, 'update': _update, - 'incoming(\|count)?': _remote('incoming'), - 'outgoing(\|count)?': _remote('outgoing'), + 'incoming(?:' + '(\|count)' + '|(\|zero)' + ')*': _remote('incoming'), + 'outgoing(?:' + '(\|count)' + '|(\|zero)' + ')*': _remote('outgoing') } if opts.get("cache_incoming"): @@ -480,8 +492,8 @@ pass help.helptable += ( - (['prompt-keywords', 'prompt-keywords'], ('Keywords supported by hg-prompt'), - (r'''hg-prompt currently supports a number of keywords. + (['prompt-keywords'], _('Keywords supported by hg-prompt'), + lambda _: r'''hg-prompt currently supports a number of keywords. Some keywords support filters. Filters can be chained when it makes sense to do so. When in doubt, try it! @@ -521,6 +533,8 @@ |count Display the number of incoming changesets (if greater than 0). + |zero + Display 0 if there are no incoming changesets. node Display the (full) changeset hash of the current parent. @@ -544,6 +558,8 @@ |count Display the number of outgoing changesets (if greater than 0). + |zero + Display 0 if there are no incoming changesets. patch Display the topmost currently-applied patch (requires the mq @@ -660,5 +676,5 @@ Display `^` if the current parent is not the tip of the current branch, otherwise nothing. In effect, this lets you see if running `hg update` would do something. -''')), +'''), )