Mercurial > repos > other > linux
comparison 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 |
comparison
equal
deleted
inserted
replaced
155:1c3ec0b529c4 | 156:8bf9fc90ce51 |
---|---|
267 out = b'' | 267 out = b'' |
268 elif out.startswith(b'patches-'): | 268 elif out.startswith(b'patches-'): |
269 out = out[8:] | 269 out = out[8:] |
270 | 270 |
271 return _with_groups(g, out) if out else b'' | 271 return _with_groups(g, out) if out else b'' |
272 | |
273 def _inout(m): | |
274 g = m.groups() | |
275 class FakeMatch: | |
276 def __init__(self, groups): | |
277 self.__groups = groups | |
278 def groups(self): | |
279 return self.__groups | |
280 incoming = _remote(b'incoming')(FakeMatch([b"-{", b"|count", b"}"])) | |
281 outgoing = _remote(b'outgoing')(FakeMatch([b"+{", b"|count", b"}"])) | |
282 if not incoming and not outgoing: | |
283 return _with_groups(g, b'=') | |
284 else: | |
285 return _with_groups(g, incoming + outgoing) | |
272 | 286 |
273 def _remote(kind): | 287 def _remote(kind): |
274 def _r(m): | 288 def _r(m): |
275 g = m.groups() | 289 g = m.groups() |
276 | 290 |
433 b')*': _tip, | 447 b')*': _tip, |
434 b'update': _update, | 448 b'update': _update, |
435 | 449 |
436 b'incoming(\|count)?': _remote(b'incoming'), | 450 b'incoming(\|count)?': _remote(b'incoming'), |
437 b'outgoing(\|count)?': _remote(b'outgoing'), | 451 b'outgoing(\|count)?': _remote(b'outgoing'), |
452 b'inout': _inout, | |
438 } | 453 } |
439 | 454 |
440 if opts.get("cache_incoming"): | 455 if opts.get("cache_incoming"): |
441 _cache_remote(repo, b'incoming') | 456 _cache_remote(repo, b'incoming') |
442 | 457 |