changeset 36190:7f5108e58083

progress: use %d to format ints instead of %s Due to behavioral changes between '% Ns' and '% Nd' this has some unfortunate extra dancing. I'm not sure of a better way to solve this problem. Differential Revision: https://phab.mercurial-scm.org/D2226
author Augie Fackler <augie@google.com>
date Tue, 13 Feb 2018 10:20:57 -0500
parents d541042f32f6
children 72d155a792b1
files mercurial/progress.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/progress.py	Tue Feb 13 08:43:14 2018 -0500
+++ b/mercurial/progress.py	Tue Feb 13 10:20:57 2018 -0500
@@ -120,7 +120,11 @@
             elif indicator == 'number':
                 if total:
                     padamount = '%d' % len(str(total))
-                    add = ('% '+ padamount + 's/%s') % (pos, 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)
                 else:
                     add = str(pos)
             elif indicator.startswith('item') and item: