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

login
register
mail settings
Submitter phabricator
Date Feb. 13, 2018, 5:14 p.m.
Message ID <a932a61cf6d629ad97e909e2e5a2f58a@localhost.localdomain>
Download mbox | patch
Permalink /patch/27829/
State Not Applicable
Headers show

Comments

phabricator - Feb. 13, 2018, 5:14 p.m.
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




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

Patch

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: