changeset 37658:34758397ad1b

py3: use b"%d" instead of str() to convert integers to bytes Differential Revision: https://phab.mercurial-scm.org/D3319
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 13 Apr 2018 16:30:27 +0530
parents 23c4ddda7bbe
children 575f59cdd8a1
files hgext/convert/__init__.py hgext/convert/cvs.py hgext/convert/cvsps.py mercurial/lock.py
diffstat 4 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/__init__.py	Fri Apr 13 12:50:47 2018 -0700
+++ b/hgext/convert/__init__.py	Fri Apr 13 16:30:27 2018 +0530
@@ -482,7 +482,7 @@
     rev = ctx.extra().get('convert_revision', '')
     if rev.startswith('svn:'):
         if name == 'svnrev':
-            return str(subversion.revsplit(rev)[2])
+            return (b"%d" % subversion.revsplit(rev)[2])
         elif name == 'svnpath':
             return subversion.revsplit(rev)[1]
         elif name == 'svnuuid':
--- a/hgext/convert/cvs.py	Fri Apr 13 12:50:47 2018 -0700
+++ b/hgext/convert/cvs.py	Fri Apr 13 16:30:27 2018 +0530
@@ -91,7 +91,7 @@
             for cs in db:
                 if maxrev and cs.id > maxrev:
                     break
-                id = str(cs.id)
+                id = (b"%d" % cs.id)
                 cs.author = self.recode(cs.author)
                 self.lastbranch[cs.branch] = id
                 cs.comment = self.recode(cs.comment)
@@ -102,13 +102,13 @@
 
                 files = {}
                 for f in cs.entries:
-                    files[f.file] = "%s%s" % ('.'.join([str(x)
+                    files[f.file] = "%s%s" % ('.'.join([(b"%d" % x)
                                                         for x in f.revision]),
                                               ['', '(DEAD)'][f.dead])
 
                 # add current commit to set
                 c = commit(author=cs.author, date=date,
-                           parents=[str(p.id) for p in cs.parents],
+                           parents=[(b"%d" % p.id) for p in cs.parents],
                            desc=cs.comment, branch=cs.branch or '')
                 self.changeset[id] = c
                 self.files[id] = files
--- a/hgext/convert/cvsps.py	Fri Apr 13 12:50:47 2018 -0700
+++ b/hgext/convert/cvsps.py	Fri Apr 13 16:30:27 2018 +0530
@@ -919,7 +919,7 @@
             if opts["parents"] and cs.parents:
                 if len(cs.parents) > 1:
                     ui.write(('Parents: %s\n' %
-                             (','.join([str(p.id) for p in cs.parents]))))
+                             (','.join([(b"%d" % p.id) for p in cs.parents]))))
                 else:
                     ui.write(('Parent: %d\n' % cs.parents[0].id))
 
@@ -941,18 +941,18 @@
                     fn = fn[len(opts["prefix"]):]
                 ui.write('\t%s:%s->%s%s \n' % (
                         fn, '.'.join([str(x) for x in f.parent]) or 'INITIAL',
-                        '.'.join([str(x) for x in f.revision]),
+                        '.'.join([(b"%d" % x) for x in f.revision]),
                         ['', '(DEAD)'][f.dead]))
             ui.write('\n')
 
         # have we seen the start tag?
         if revisions and off:
-            if revisions[0] == str(cs.id) or \
+            if revisions[0] == (b"%d" % cs.id) or \
                 revisions[0] in cs.tags:
                 off = False
 
         # see if we reached the end tag
         if len(revisions) > 1 and not off:
-            if revisions[1] == str(cs.id) or \
+            if revisions[1] == (b"%d" % cs.id) or \
                 revisions[1] in cs.tags:
                 break
--- a/mercurial/lock.py	Fri Apr 13 12:50:47 2018 -0700
+++ b/mercurial/lock.py	Fri Apr 13 16:30:27 2018 +0530
@@ -348,7 +348,7 @@
         if self._parentheld:
             lockname = self.parentlock
         else:
-            lockname = '%s:%s' % (lock._host, self.pid)
+            lockname = b'%s:%d' % (lock._host, self.pid)
         self._inherited = True
         try:
             yield lockname