Mercurial > hg
view doc/docchecker @ 29089:222b8170d69e stable
progress: stop excessive clearing (issue4801)
The progress bar was being cleared on every write(), regardless of
whether it was currently displayed. This could foul up the display of
any writes that didn't include a linebreak.
In particular, the win32 mode of the color extension was turning
single prompt string writes into two writes, and the resulting
clear/write/clear/write pattern was making the prompt invisible.
We fix this by insisting that we have shown a progress bar and haven't
just cleared it (setting lastprint to 0).
Conveniently, the test suite already had instances of duplicate
clears.. that are now cleared up.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 06 May 2016 17:53:06 -0500 |
parents | 1a623585a658 |
children | 8f2805ce93d9 |
line wrap: on
line source
#!/usr/bin/env python # # docchecker - look for problematic markup # # Copyright 2016 timeless <timeless@mozdev.org> and others # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. import sys import re leadingline = re.compile(r'(^\s*)(\S.*)$') checks = [ (r""":hg:`[^`]*'[^`]*`""", """warning: please avoid nesting ' in :hg:`...`"""), (r'\w:hg:`', 'warning: please have a space before :hg:'), (r"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""", '''warning: please use " instead of ' for hg ... "..."'''), ] def check(line): messages = [] for match, msg in checks: if re.search(match, line): messages.append(msg) if messages: print(line) for msg in messages: print(msg) def work(file): (llead, lline) = ('', '') for line in file: # this section unwraps lines match = leadingline.match(line) if not match: check(lline) (llead, lline) = ('', '') continue lead, line = match.group(1), match.group(2) if (lead == llead): if (lline != ''): lline += ' ' + line else: lline = line else: check(lline) (llead, lline) = (lead, line) check(lline) def main(): for f in sys.argv[1:]: try: with open(f) as file: work(file) except BaseException as e: print("failed to process %s: %s" % (f, e)) main()