comparison mercurial/progress.py @ 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 7f5108e58083
children 2831d918e1b4
comparison
equal deleted inserted replaced
36239:46260fac5563 36240:707aba4d48b5
117 add = '' 117 add = ''
118 if indicator == 'topic': 118 if indicator == 'topic':
119 add = topic 119 add = topic
120 elif indicator == 'number': 120 elif indicator == 'number':
121 if total: 121 if total:
122 padamount = '%d' % len(str(total)) 122 add = b'%*d/%d' % (len(str(total)), pos, total)
123 # '% 1d' % 1 adds an extra space compared to '% 1s' % 1.
124 # To avoid this change in output, we convert to a string
125 # first, then do the padding.
126 spos = '%d' % pos
127 add = ('% '+ padamount + 's/%d') % (spos, total)
128 else: 123 else:
129 add = str(pos) 124 add = str(pos)
130 elif indicator.startswith('item') and item: 125 elif indicator.startswith('item') and item:
131 slice = 'end' 126 slice = 'end'
132 if '-' in indicator: 127 if '-' in indicator: