# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2018-03-01 18:30:41 # Node ID 7af7443877daad61d66222085c594e05d803d04a # Parent eafd380fe1b8b8cd3580298cc7e5fc450d3ab183 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 diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -192,7 +192,7 @@ class shelvedstate(object): 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 @@ class shelvedstate(object): 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 @@ class shelvedstate(object): 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 @@ def _rebaserestoredcommit(ui, repo, opts 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 @@ def _dounshelve(ui, repo, *shelved, **op 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 '