Mercurial > hg
diff hgext/progress.py @ 21859:be4270d27a7e
progress: use 'encoding.trim' to trim output line correctly
Before this patch, 'progress' extension trims output line by directly
slicing byte sequence, but it may split at intermediate multi-byte
sequence.
This patch uses 'encoding.trim' to trim output line correctly, even if
it contains multi-byte characters.
"rm -f loop.pyc" before changing "loop.py" in "test-progress.t"
ensures that re-compilation of "loop.py", even if "loop.py" and
"loop.pyc" have same timestamp in seconds.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sun, 06 Jul 2014 02:56:41 +0900 |
parents | 4694ccd5d994 |
children | e382cf9ec30b |
line wrap: on
line diff
--- a/hgext/progress.py Sun Jul 06 02:56:41 2014 +0900 +++ b/hgext/progress.py Sun Jul 06 02:56:41 2014 +0900 @@ -41,6 +41,8 @@ from mercurial.i18n import _ testedwith = 'internal' +from mercurial import encoding + def spacejoin(*args): return ' '.join(s for s in args if s) @@ -180,7 +182,7 @@ out = spacejoin(head, prog, tail) else: out = spacejoin(head, tail) - sys.stderr.write('\r' + out[:termwidth]) + sys.stderr.write('\r' + encoding.trim(out, termwidth)) self.lasttopic = topic sys.stderr.flush()