changeset 44074:806d14efec8d

fsmonitor: properly handle str ex.msg ex.msg is always a str, since pywatchman uses str for exception messages. This commit removes a b'' from a string compare to avoid types mismatch and adds a coercion to bytes before stuffing the exception message on our local exception type, which uses bytes for the message elsewhere in this file. Differential Revision: https://phab.mercurial-scm.org/D7855
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 13 Jan 2020 20:09:32 -0800
parents b9e174d4ed11
children 2122ffa903ea
files hgext/fsmonitor/watchmanclient.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/fsmonitor/watchmanclient.py	Mon Dec 23 01:12:20 2019 -0500
+++ b/hgext/fsmonitor/watchmanclient.py	Mon Jan 13 20:09:32 2020 -0800
@@ -105,11 +105,11 @@
                 )
             return self._watchmanclient.query(*watchmanargs)
         except pywatchman.CommandError as ex:
-            if b'unable to resolve root' in ex.msg:
+            if 'unable to resolve root' in ex.msg:
                 raise WatchmanNoRoot(
                     self._root, stringutil.forcebytestr(ex.msg)
                 )
-            raise Unavailable(ex.msg)
+            raise Unavailable(stringutil.forcebytestr(ex.msg))
         except pywatchman.WatchmanError as ex:
             raise Unavailable(stringutil.forcebytestr(ex))