D2226: progress: use %d to format ints instead of %s
yuja added a comment. Maybe we want `'%d'`, not `'% d'`? The latter means to use `' '` in place of `'+'` sign. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2226 To: durin42, #hg-reviewers, indygreg Cc: yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2226: progress: use %d to format ints instead of %s
durin42 added a comment. In https://phab.mercurial-scm.org/D2226#36921, @indygreg wrote: > Ugh. Maybe `.format()` would be better here. We can use that in 3.5 for bytes, right? Python 3.6.2 (default, Jul 17 2017, 17:35:42) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> b''.format Traceback (most recent call last): File "", line 1, in AttributeError: 'bytes' object has no attribute 'format' Sigh. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2226 To: durin42, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2226: progress: use %d to format ints instead of %s
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=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 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2226: progress: use %d to format ints instead of %s
indygreg accepted this revision. indygreg added a comment. This revision is now accepted and ready to land. Ugh. Maybe `.format()` would be better here. We can use that in 3.5 for bytes, right? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2226 To: durin42, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2226: progress: use %d to format ints instead of %s
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY 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. REPOSITORY rHG Mercurial 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 Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel