changeset 45681:a736ab681b78

errors: stop passing non-strings to Abort's constructor The next patch will change `Abort`'s constructor and `__bytes__` functions and they will start assuming that the first argument is the messages as `bytes`. Differential Revision: https://phab.mercurial-scm.org/D9178
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 08 Oct 2020 15:35:44 -0700
parents bb1a988ef4a5
children d2e1dcd4490d
files hgext/convert/cvsps.py mercurial/encoding.py mercurial/exchange.py tests/failfilemerge.py tests/test-bundle2-format.t tests/test-dirstate.t tests/test-fncache.t tests/test-histedit-edit.t tests/test-merge1.t tests/test-mq-qfold.t tests/test-mq-qnew.t tests/test-share-bookmarks.t tests/test-sparse-import.t
diffstat 13 files changed, 16 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/cvsps.py	Tue Oct 06 21:06:18 2020 -0700
+++ b/hgext/convert/cvsps.py	Thu Oct 08 15:35:44 2020 -0700
@@ -559,7 +559,7 @@
                     pass  # try next encoding
                 except LookupError as inst:  # unknown encoding, maybe
                     raise error.Abort(
-                        inst,
+                        pycompat.bytestr(inst),
                         hint=_(
                             b'check convert.cvsps.logencoding configuration'
                         ),
--- a/mercurial/encoding.py	Tue Oct 06 21:06:18 2020 -0700
+++ b/mercurial/encoding.py	Thu Oct 08 15:35:44 2020 -0700
@@ -207,7 +207,9 @@
                 # can't round-trip
                 return u.encode(_sysstr(encoding), "replace")
     except LookupError as k:
-        raise error.Abort(k, hint=b"please check your locale settings")
+        raise error.Abort(
+            pycompat.bytestr(k), hint=b"please check your locale settings"
+        )
 
 
 def fromlocal(s):
--- a/mercurial/exchange.py	Tue Oct 06 21:06:18 2020 -0700
+++ b/mercurial/exchange.py	Thu Oct 08 15:35:44 2020 -0700
@@ -1720,7 +1720,7 @@
         repo = reporef()
         cm = _(b'accept incoming changes (yn)?$$ &Yes $$ &No')
         if repo.ui.promptchoice(cm):
-            raise error.Abort("user aborted")
+            raise error.Abort(b"user aborted")
 
     tr.addvalidator(b'900-pull-prompt', prompt)
 
--- a/tests/failfilemerge.py	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/failfilemerge.py	Thu Oct 08 15:35:44 2020 -0700
@@ -12,7 +12,7 @@
 def failfilemerge(
     filemergefn, premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels=None
 ):
-    raise error.Abort("^C")
+    raise error.Abort(b"^C")
     return filemergefn(premerge, repo, mynode, orig, fcd, fco, fca, labels)
 
 
--- a/tests/test-bundle2-format.t	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/test-bundle2-format.t	Thu Oct 08 15:35:44 2020 -0700
@@ -22,6 +22,7 @@
   > from mercurial import changegroup
   > from mercurial import error
   > from mercurial import obsolete
+  > from mercurial import pycompat
   > from mercurial import registrar
   > from mercurial.utils import procutil
   > 
@@ -169,7 +170,7 @@
   >         for chunk in bundler.getchunks():
   >             file.write(chunk)
   >     except RuntimeError as exc:
-  >         raise error.Abort(exc)
+  >         raise error.Abort(pycompat.bytestr(exc))
   >     finally:
   >         file.flush()
   > 
--- a/tests/test-dirstate.t	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/test-dirstate.t	Thu Oct 08 15:35:44 2020 -0700
@@ -74,7 +74,7 @@
   > )
   > 
   > def wraprecordupdates(*args):
-  >     raise error.Abort("simulated error while recording dirstateupdates")
+  >     raise error.Abort(b"simulated error while recording dirstateupdates")
   > 
   > def reposetup(ui, repo):
   >     extensions.wrapfunction(mergestatemod, 'recordupdates',
--- a/tests/test-fncache.t	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/test-fncache.t	Thu Oct 08 15:35:44 2020 -0700
@@ -238,7 +238,7 @@
   > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
   >     def releasewrap():
   >         l.held = False # ensure __del__ is a noop
-  >         raise error.Abort("forced lock failure")
+  >         raise error.Abort(b"forced lock failure")
   >     l = orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
   >     return l
   > 
--- a/tests/test-histedit-edit.t	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/test-histedit-edit.t	Thu Oct 08 15:35:44 2020 -0700
@@ -311,7 +311,7 @@
   > def reposetup(ui, repo):
   >     class commitfailure(repo.__class__):
   >         def commit(self, *args, **kwargs):
-  >             raise error.Abort('emulating unexpected abort')
+  >             raise error.Abort(b'emulating unexpected abort')
   >     repo.__class__ = commitfailure
   > EOF
   $ cat >> .hg/hgrc <<EOF
--- a/tests/test-merge1.t	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/test-merge1.t	Thu Oct 08 15:35:44 2020 -0700
@@ -360,7 +360,7 @@
   > )
   > def applyupdates(orig, *args, **kwargs):
   >     orig(*args, **kwargs)
-  >     raise error.Abort('intentional aborting')
+  >     raise error.Abort(b'intentional aborting')
   > def extsetup(ui):
   >     extensions.wrapfunction(merge, "applyupdates", applyupdates)
   > EOF
--- a/tests/test-mq-qfold.t	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/test-mq-qfold.t	Thu Oct 08 15:35:44 2020 -0700
@@ -153,7 +153,7 @@
   > def reposetup(ui, repo):
   >     class commitfailure(repo.__class__):
   >         def commit(self, *args, **kwargs):
-  >             raise error.Abort('emulating unexpected abort')
+  >             raise error.Abort(b'emulating unexpected abort')
   >     repo.__class__ = commitfailure
   > EOF
 
--- a/tests/test-mq-qnew.t	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/test-mq-qnew.t	Thu Oct 08 15:35:44 2020 -0700
@@ -256,7 +256,7 @@
   > def reposetup(ui, repo):
   >     class commitfailure(repo.__class__):
   >         def commit(self, *args, **kwargs):
-  >             raise error.Abort('emulating unexpected abort')
+  >             raise error.Abort(b'emulating unexpected abort')
   >     repo.__class__ = commitfailure
   > EOF
   $ cat >> .hg/hgrc <<EOF
--- a/tests/test-share-bookmarks.t	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/test-share-bookmarks.t	Thu Oct 08 15:35:44 2020 -0700
@@ -230,7 +230,7 @@
   > )
   > def _pullbookmarks(orig, pullop):
   >     orig(pullop)
-  >     raise error.HookAbort('forced failure by extension')
+  >     raise error.HookAbort(b'forced failure by extension')
   > def extsetup(ui):
   >     extensions.wrapfunction(exchange, '_pullbookmarks', _pullbookmarks)
   > EOF
--- a/tests/test-sparse-import.t	Tue Oct 06 21:06:18 2020 -0700
+++ b/tests/test-sparse-import.t	Thu Oct 08 15:35:44 2020 -0700
@@ -153,7 +153,7 @@
   > from mercurial import error, sparse
   > def extsetup(ui):
   >     def abort_refresh(*args, **kwargs):
-  >         raise error.Abort('sparse._refresh called!')
+  >         raise error.Abort(b'sparse._refresh called!')
   >     sparse.refreshwdir = abort_refresh
   > EOF
   $ cat >> $HGRCPATH <<EOF