Patchwork D2520: py3: replace str() with it's bytes equivalent in hgext/shelve.py

login
register
mail settings
Submitter phabricator
Date March 1, 2018, 6:49 p.m.
Message ID <differential-rev-PHID-DREV-ufvco36aiayaqms4ae3s-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28572/
State Superseded
Headers show

Comments

phabricator - March 1, 2018, 6:49 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Internally we are dealing with bytes everywhere, so anything returning a unicode
  results in an error or some change in behaviour.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2520

AFFECTED FILES
  hgext/shelve.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -192,16 +192,16 @@ 
             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):
         """Read version information from shelvestate file"""
         fp = repo.vfs(cls._filename)
         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 '