Mercurial > hg-stable
changeset 36240:707aba4d48b5
progress: use '%*d' to pad progress value
Follows up 7f5108e58083. The problem of '% Nd' is that ' ' means we want
{' ' or '-'} as a sign character. We should instead write '%Nd' to pad up
to N characters with space, and N can be '*'.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 14 Feb 2018 21:36:15 +0900 |
parents | 46260fac5563 |
children | 01280638bdb1 |
files | mercurial/progress.py |
diffstat | 1 files changed, 1 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/progress.py Wed Feb 14 21:29:27 2018 +0900 +++ b/mercurial/progress.py Wed Feb 14 21:36:15 2018 +0900 @@ -119,12 +119,7 @@ add = topic elif indicator == 'number': if total: - padamount = '%d' % len(str(total)) - # '% 1d' % 1 adds an extra space compared to '% 1s' % 1. - # To avoid this change in output, we convert to a string - # first, then do the padding. - spos = '%d' % pos - add = ('% '+ padamount + 's/%d') % (spos, total) + add = b'%*d/%d' % (len(str(total)), pos, total) else: add = str(pos) elif indicator.startswith('item') and item: