py3: convert known-int values to bytes using %d
authorAugie Fackler <augie@google.com>
Sun, 25 Feb 2018 23:09:07 -0500
changeset 36423 2831d918e1b4
parent 36422 04c319a07c7b
child 36424 3ab9d74dd1c5
py3: convert known-int values to bytes using %d I decided to grep around for \sstr\( and see what low-hanging fruit that showed me. This was part of that hunt. That grep pattern still has some things worth exploring. Differential Revision: https://phab.mercurial-scm.org/D2441
mercurial/exchange.py
mercurial/obsolete.py
mercurial/patch.py
mercurial/progress.py
--- a/mercurial/exchange.py	Sun Feb 25 23:08:41 2018 -0500
+++ b/mercurial/exchange.py	Sun Feb 25 23:09:07 2018 -0500
@@ -1151,8 +1151,8 @@
         for newremotehead in outdated:
             r = pushop.remote.pushkey('phases',
                                       newremotehead.hex(),
-                                      str(phases.draft),
-                                      str(phases.public))
+                                      ('%d' % phases.draft),
+                                      ('%d' % phases.public))
             if not r:
                 pushop.ui.warn(_('updating %s to public failed!\n')
                                % newremotehead)
--- a/mercurial/obsolete.py	Sun Feb 25 23:08:41 2018 -0500
+++ b/mercurial/obsolete.py	Sun Feb 25 23:09:07 2018 -0500
@@ -656,7 +656,7 @@
             self.caches.clear()
         # records the number of new markers for the transaction hooks
         previous = int(transaction.hookargs.get('new_obsmarkers', '0'))
-        transaction.hookargs['new_obsmarkers'] = str(previous + len(new))
+        transaction.hookargs['new_obsmarkers'] = '%d' % (previous + len(new))
         return len(new)
 
     def mergemarkers(self, transaction, data):
--- a/mercurial/patch.py	Sun Feb 25 23:08:41 2018 -0500
+++ b/mercurial/patch.py	Sun Feb 25 23:09:07 2018 -0500
@@ -566,7 +566,7 @@
                 root = tempfile.mkdtemp(prefix='hg-patch-')
                 self.opener = vfsmod.vfs(root)
             # Avoid filename issues with these simple names
-            fn = str(self.created)
+            fn = '%d' % self.created
             self.opener.write(fn, data)
             self.created += 1
             self.files[fname] = (fn, mode, copied)
--- a/mercurial/progress.py	Sun Feb 25 23:08:41 2018 -0500
+++ b/mercurial/progress.py	Sun Feb 25 23:09:07 2018 -0500
@@ -121,7 +121,7 @@
                 if total:
                     add = b'%*d/%d' % (len(str(total)), pos, total)
                 else:
-                    add = str(pos)
+                    add = b'%d' % pos
             elif indicator.startswith('item') and item:
                 slice = 'end'
                 if '-' in indicator: