Show More
@@ -9,8 +9,14 b' from __future__ import absolute_import' | |||||
9 |
|
9 | |||
10 | import getpass |
|
10 | import getpass | |
11 |
|
11 | |||
12 |
from mercurial import |
|
12 | from mercurial import ( | |
13 | from mercurial.utils import procutil |
|
13 | encoding, | |
|
14 | util, | |||
|
15 | ) | |||
|
16 | from mercurial.utils import ( | |||
|
17 | procutil, | |||
|
18 | stringutil, | |||
|
19 | ) | |||
14 |
|
20 | |||
15 | from . import pywatchman |
|
21 | from . import pywatchman | |
16 |
|
22 | |||
@@ -23,12 +29,14 b' class Unavailable(Exception):' | |||||
23 | self.warn = False |
|
29 | self.warn = False | |
24 | self.invalidate = invalidate |
|
30 | self.invalidate = invalidate | |
25 |
|
31 | |||
26 |
def __ |
|
32 | def __bytes__(self): | |
27 | if self.warn: |
|
33 | if self.warn: | |
28 | return b'warning: Watchman unavailable: %s' % self.msg |
|
34 | return b'warning: Watchman unavailable: %s' % self.msg | |
29 | else: |
|
35 | else: | |
30 | return b'Watchman unavailable: %s' % self.msg |
|
36 | return b'Watchman unavailable: %s' % self.msg | |
31 |
|
37 | |||
|
38 | __str__ = encoding.strmethod(__bytes__) | |||
|
39 | ||||
32 |
|
40 | |||
33 | class WatchmanNoRoot(Unavailable): |
|
41 | class WatchmanNoRoot(Unavailable): | |
34 | def __init__(self, root, msg): |
|
42 | def __init__(self, root, msg): | |
@@ -98,10 +106,12 b' class client(object):' | |||||
98 | return self._watchmanclient.query(*watchmanargs) |
|
106 | return self._watchmanclient.query(*watchmanargs) | |
99 | except pywatchman.CommandError as ex: |
|
107 | except pywatchman.CommandError as ex: | |
100 | if b'unable to resolve root' in ex.msg: |
|
108 | if b'unable to resolve root' in ex.msg: | |
101 |
raise WatchmanNoRoot( |
|
109 | raise WatchmanNoRoot( | |
|
110 | self._root, stringutil.forcebytestr(ex.msg) | |||
|
111 | ) | |||
102 | raise Unavailable(ex.msg) |
|
112 | raise Unavailable(ex.msg) | |
103 | except pywatchman.WatchmanError as ex: |
|
113 | except pywatchman.WatchmanError as ex: | |
104 | raise Unavailable(str(ex)) |
|
114 | raise Unavailable(stringutil.forcebytestr(ex)) | |
105 |
|
115 | |||
106 | def command(self, *args): |
|
116 | def command(self, *args): | |
107 | try: |
|
117 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now