Mercurial > repos > other > linux
diff prompt.py @ 156:8bf9fc90ce51
Streamline HG Prompt with `inout` command
This avoids a second Mercurial invocation, which takes a couple
of seconds on a Raspberry Pi.
Also exported PS1 variants to make it easier to enable/disable
the VCS checks but keep the rest of the formatting
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 23 Aug 2023 20:26:28 +0100 |
parents | 1c3ec0b529c4 |
children | 03886f17beef |
line wrap: on
line diff
--- a/prompt.py Tue May 30 18:49:56 2023 +0100 +++ b/prompt.py Wed Aug 23 20:26:28 2023 +0100 @@ -270,6 +270,20 @@ return _with_groups(g, out) if out else b'' + def _inout(m): + g = m.groups() + class FakeMatch: + def __init__(self, groups): + self.__groups = groups + def groups(self): + return self.__groups + incoming = _remote(b'incoming')(FakeMatch([b"-{", b"|count", b"}"])) + outgoing = _remote(b'outgoing')(FakeMatch([b"+{", b"|count", b"}"])) + if not incoming and not outgoing: + return _with_groups(g, b'=') + else: + return _with_groups(g, incoming + outgoing) + def _remote(kind): def _r(m): g = m.groups() @@ -435,6 +449,7 @@ b'incoming(\|count)?': _remote(b'incoming'), b'outgoing(\|count)?': _remote(b'outgoing'), + b'inout': _inout, } if opts.get("cache_incoming"):