D2226: progress: use %d to format ints instead of %s

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Tue Feb 13 12:14:49 EST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG7f5108e58083: progress: use %d to format ints instead of %s (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2226?vs=5632&id=5639

REVISION DETAIL
  https://phab.mercurial-scm.org/D2226

AFFECTED FILES
  mercurial/progress.py

CHANGE DETAILS

diff --git a/mercurial/progress.py b/mercurial/progress.py
--- a/mercurial/progress.py
+++ b/mercurial/progress.py
@@ -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:



To: durin42, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel


More information about the Mercurial-devel mailing list