py3: replace str() with it's bytes equivalent in hgext/shelve.py
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 02 Mar 2018 00:00:41 +0530
changeset 36496 7af7443877da
parent 36495 eafd380fe1b8
child 36497 b2e54b257832
py3: replace str() with it's bytes equivalent in hgext/shelve.py Internally we are dealing with bytes everywhere, so anything returning a unicode results in an error or some change in behaviour. Differential Revision: https://phab.mercurial-scm.org/D2520
hgext/shelve.py
--- a/hgext/shelve.py	Thu Mar 01 23:59:20 2018 +0530
+++ b/hgext/shelve.py	Fri Mar 02 00:00:41 2018 +0530
@@ -192,7 +192,7 @@
             d['nodestoremove'] = [nodemod.bin(h)
                                   for h in d['nodestoremove'].split(' ')]
         except (ValueError, TypeError, KeyError) as err:
-            raise error.CorruptedState(str(err))
+            raise error.CorruptedState(pycompat.bytestr(err))
 
     @classmethod
     def _getversion(cls, repo):
@@ -201,7 +201,7 @@
         try:
             version = int(fp.readline().strip())
         except ValueError as err:
-            raise error.CorruptedState(str(err))
+            raise error.CorruptedState(pycompat.bytestr(err))
         finally:
             fp.close()
         return version
@@ -251,7 +251,7 @@
             if d.get('activebook', '') != cls._noactivebook:
                 obj.activebookmark = d.get('activebook', '')
         except (error.RepoLookupError, KeyError) as err:
-            raise error.CorruptedState(str(err))
+            raise error.CorruptedState(pycompat.bytestr(err))
 
         return obj
 
@@ -745,7 +745,7 @@
     try:
         rebase.rebase(ui, repo, **{
             r'rev': [shelvectx.rev()],
-            r'dest': str(tmpwctx.rev()),
+            r'dest': "%d" % tmpwctx.rev(),
             r'keep': True,
             r'tool': opts.get('tool', ''),
         })
@@ -881,7 +881,7 @@
                 raise
             cmdutil.wrongtooltocontinue(repo, _('unshelve'))
         except error.CorruptedState as err:
-            ui.debug(str(err) + '\n')
+            ui.debug(pycompat.bytestr(err) + '\n')
             if continuef:
                 msg = _('corrupted shelved state file')
                 hint = _('please run hg unshelve --abort to abort unshelve '