py3: convert known-int values to bytes using %d
authorAugie Fackler <augie@google.com>
Sun, 25 Feb 2018 23:09:07 -0500
changeset 43013 2831d918e1b47c175208441561cb3836cc2df0e3
parent 43012 04c319a07c7b8d152e4bd00dd42d887cca24488a
child 43014 3ab9d74dd1c53efd2bfc9fd8938bc098df907244
push id705
push usergszorc@mozilla.com
push dateMon, 26 Feb 2018 23:47:38 +0000
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
+++ b/mercurial/exchange.py
@@ -1146,18 +1146,18 @@ def _pushsyncphase(pushop):
         pushop.stepsdone.add('phases')
 
         # filter heads already turned public by the push
         outdated = [c for c in outdated if c.node() not in pheads]
         # fallback to independent pushkey command
         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)
 
 def _localphasemove(pushop, nodes, phase=phases.public):
     """move <nodes> to <phase> in the local source repo"""
     if pushop.trmanager:
         phases.advanceboundary(pushop.repo,
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -651,17 +651,17 @@ class obsstore(object):
             addedmarkers = transaction.changes.get('obsmarkers')
             if addedmarkers is not None:
                 addedmarkers.update(new)
             self._addmarkers(new, data)
             # new marker *may* have changed several set. invalidate the cache.
             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):
         """merge a binary stream of markers inside the obsstore
 
         Returns the number of new markers added."""
         version, markers = _readmarkers(data)
         return self.add(transaction, markers)
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -561,17 +561,17 @@ class filestore(object):
         if self.maxsize < 0 or (len(data) + self.size) <= self.maxsize:
             self.data[fname] = (data, mode, copied)
             self.size += len(data)
         else:
             if self.opener is None:
                 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)
 
     def getfile(self, fname):
         if fname in self.data:
             return self.data[fname]
         if not self.opener or fname not in self.files:
--- a/mercurial/progress.py
+++ b/mercurial/progress.py
@@ -116,17 +116,17 @@ class progbar(object):
         for indicator in self.order:
             add = ''
             if indicator == 'topic':
                 add = topic
             elif indicator == 'number':
                 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:
                     wid = int(indicator.split('-')[1])
                 elif '+' in indicator:
                     slice = 'beginning'
                     wid = int(indicator.split('+')[1])
                 else: