D2535: py3: use pycompat.bytestr() to convert error messages to bytes
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Fri Mar 2 02:00:19 UTC 2018
pulkit created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D2535
AFFECTED FILES
hgext/convert/subversion.py
hgext/gpg.py
hgext/journal.py
hgext/largefiles/overrides.py
hgext/mq.py
hgext/narrow/narrowbundle2.py
hgext/relink.py
CHANGE DETAILS
diff --git a/hgext/relink.py b/hgext/relink.py
--- a/hgext/relink.py
+++ b/hgext/relink.py
@@ -187,7 +187,7 @@
relinked += 1
savedbytes += sz
except OSError as inst:
- ui.warn('%s: %s\n' % (tgt, str(inst)))
+ ui.warn('%s: %s\n' % (tgt, pycompat.bytestr(inst)))
ui.progress(_('relinking'), None)
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -25,6 +25,7 @@
exchange,
extensions,
narrowspec,
+ pycompat,
repair,
util,
wireproto,
@@ -449,7 +450,7 @@
except OSError as e:
if e.errno != errno.ENOENT:
ui.warn(_('error removing %s: %s\n') %
- (undovfs.join(undofile), str(e)))
+ (undovfs.join(undofile), pycompat.bytestr(e)))
# Remove partial backup only if there were no exceptions
vfs.unlink(chgrpfile)
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -722,7 +722,8 @@
try:
os.unlink(undo)
except OSError as inst:
- self.ui.warn(_('error removing undo: %s\n') % str(inst))
+ self.ui.warn(_('error removing undo: %s\n') % \
+ pycompat.bytestr(inst))
def backup(self, repo, files, copy=False):
# backup local changes in --force case
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -598,7 +598,7 @@
try:
result = orig(ui, repo, pats, opts, rename)
except error.Abort as e:
- if str(e) != _('no files to copy'):
+ if pycompat.bytestr(e) != _('no files to copy'):
raise e
else:
nonormalfiles = True
@@ -705,7 +705,7 @@
lfdirstate.add(destlfile)
lfdirstate.write()
except error.Abort as e:
- if str(e) != _('no files to copy'):
+ if pycompat.bytestr(e) != _('no files to copy'):
raise e
else:
nolfiles = True
diff --git a/hgext/journal.py b/hgext/journal.py
--- a/hgext/journal.py
+++ b/hgext/journal.py
@@ -507,7 +507,7 @@
ctx = repo[hash]
displayer.show(ctx)
except error.RepoLookupError as e:
- fm.write('repolookuperror', "%s\n\n", str(e))
+ fm.write('repolookuperror', "%s\n\n", pycompat.bytestr(e))
displayer.close()
fm.end()
diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -317,7 +317,7 @@
repo.commit(message, opts['user'], opts['date'], match=msigs,
editor=editor)
except ValueError as inst:
- raise error.Abort(str(inst))
+ raise error.Abort(pycompat.bytestr(inst))
def node2txt(repo, node, ver):
"""map a manifest into some text"""
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -146,7 +146,7 @@
# Caller may interrupt the iteration
pickle.dump(None, fp, protocol)
except Exception as inst:
- pickle.dump(str(inst), fp, protocol)
+ pickle.dump(pycompat.bytestr(inst), fp, protocol)
else:
pickle.dump(None, fp, protocol)
fp.flush()
To: pulkit, durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list