Merge lp:~jelmer/brz/move-errors-views into lp:brz
- move-errors-views
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Merged at revision: | 6740 |
Proposed branch: | lp:~jelmer/brz/move-errors-views |
Merge into: | lp:brz |
Diff against target: |
1186 lines (+297/-254) 24 files modified
breezy/builtins.py (+3/-3) breezy/bzr/smart/medium.py (+16/-3) breezy/bzr/smart/request.py (+9/-0) breezy/bzr/smart/vfs.py (+1/-1) breezy/commands.py (+29/-5) breezy/errors.py (+0/-153) breezy/mail_client.py (+30/-8) breezy/shelf.py (+24/-4) breezy/shelf_ui.py (+1/-1) breezy/smtp_connection.py (+31/-4) breezy/tests/__init__.py (+1/-0) breezy/tests/per_workingtree/test_views.py (+19/-19) breezy/tests/test_errors.py (+0/-27) breezy/tests/test_mail_client.py (+2/-2) breezy/tests/test_shelf.py (+11/-2) breezy/tests/test_shelf_ui.py (+2/-1) breezy/tests/test_smart_request.py (+8/-0) breezy/tests/test_smart_transport.py (+1/-1) breezy/tests/test_smtp_connection.py (+8/-8) breezy/tests/test_treebuilder.py (+8/-4) breezy/tests/test_views.py (+44/-0) breezy/treebuilder.py (+12/-2) breezy/views.py (+36/-5) breezy/workingtree.py (+1/-1) |
To merge this branch: | bzr merge lp:~jelmer/brz/move-errors-views |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Packman | Approve | ||
Review via email:
|
Commit message
Move a few more errors out of breezy.errors.
Description of the change
Move a few more errors to their respective modules, out of breezy.errors:
* views
* shelf
* smtp
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'breezy/builtins.py' | |||
2 | --- breezy/builtins.py 2017-07-21 14:18:24 +0000 | |||
3 | +++ breezy/builtins.py 2017-07-23 16:06:20 +0000 | |||
4 | @@ -245,7 +245,7 @@ | |||
5 | 245 | if view_files: | 245 | if view_files: |
6 | 246 | for filename in file_list: | 246 | for filename in file_list: |
7 | 247 | if not osutils.is_inside_any(view_files, filename): | 247 | if not osutils.is_inside_any(view_files, filename): |
9 | 248 | raise errors.FileOutsideView(filename, view_files) | 248 | raise views.FileOutsideView(filename, view_files) |
10 | 249 | file_list = file_list[:] | 249 | file_list = file_list[:] |
11 | 250 | file_list[0] = tree.abspath(relpath) | 250 | file_list[0] = tree.abspath(relpath) |
12 | 251 | else: | 251 | else: |
13 | @@ -299,7 +299,7 @@ | |||
14 | 299 | current_view = tree.views.get_view_info()[0] | 299 | current_view = tree.views.get_view_info()[0] |
15 | 300 | if current_view is not None: | 300 | if current_view is not None: |
16 | 301 | view_info = (current_view, tree.views.lookup_view()) | 301 | view_info = (current_view, tree.views.lookup_view()) |
18 | 302 | except errors.ViewsNotSupported: | 302 | except views.ViewsNotSupported: |
19 | 303 | pass | 303 | pass |
20 | 304 | return view_info | 304 | return view_info |
21 | 305 | 305 | ||
22 | @@ -3040,7 +3040,7 @@ | |||
23 | 3040 | else: | 3040 | else: |
24 | 3041 | fullpath = fp | 3041 | fullpath = fp |
25 | 3042 | views.check_path_in_view(tree, fullpath) | 3042 | views.check_path_in_view(tree, fullpath) |
27 | 3043 | except errors.FileOutsideView: | 3043 | except views.FileOutsideView: |
28 | 3044 | continue | 3044 | continue |
29 | 3045 | 3045 | ||
30 | 3046 | # Output the entry | 3046 | # Output the entry |
31 | 3047 | 3047 | ||
32 | === modified file 'breezy/bzr/smart/medium.py' | |||
33 | --- breezy/bzr/smart/medium.py 2017-06-11 20:15:04 +0000 | |||
34 | +++ breezy/bzr/smart/medium.py 2017-07-23 16:06:20 +0000 | |||
35 | @@ -41,7 +41,6 @@ | |||
36 | 41 | 41 | ||
37 | 42 | from breezy import ( | 42 | from breezy import ( |
38 | 43 | debug, | 43 | debug, |
39 | 44 | errors, | ||
40 | 45 | trace, | 44 | trace, |
41 | 46 | transport, | 45 | transport, |
42 | 47 | ui, | 46 | ui, |
43 | @@ -51,7 +50,10 @@ | |||
44 | 51 | from breezy.bzr.smart import client, protocol, request, signals, vfs | 50 | from breezy.bzr.smart import client, protocol, request, signals, vfs |
45 | 52 | from breezy.transport import ssh | 51 | from breezy.transport import ssh |
46 | 53 | """) | 52 | """) |
48 | 54 | from ... import osutils | 53 | from ... import ( |
49 | 54 | errors, | ||
50 | 55 | osutils, | ||
51 | 56 | ) | ||
52 | 55 | 57 | ||
53 | 56 | # Throughout this module buffer size parameters are either limited to be at | 58 | # Throughout this module buffer size parameters are either limited to be at |
54 | 57 | # most _MAX_READ_SIZE, or are ignored and _MAX_READ_SIZE is used instead. | 59 | # most _MAX_READ_SIZE, or are ignored and _MAX_READ_SIZE is used instead. |
55 | @@ -59,6 +61,17 @@ | |||
56 | 59 | # from non-sockets as well. | 61 | # from non-sockets as well. |
57 | 60 | _MAX_READ_SIZE = osutils.MAX_SOCKET_CHUNK | 62 | _MAX_READ_SIZE = osutils.MAX_SOCKET_CHUNK |
58 | 61 | 63 | ||
59 | 64 | |||
60 | 65 | class HpssVfsRequestNotAllowed(errors.BzrError): | ||
61 | 66 | |||
62 | 67 | _fmt = ("VFS requests over the smart server are not allowed. Encountered: " | ||
63 | 68 | "%(method)s, %(arguments)s.") | ||
64 | 69 | |||
65 | 70 | def __init__(self, method, arguments): | ||
66 | 71 | self.method = method | ||
67 | 72 | self.arguments = arguments | ||
68 | 73 | |||
69 | 74 | |||
70 | 62 | def _get_protocol_factory_for_bytes(bytes): | 75 | def _get_protocol_factory_for_bytes(bytes): |
71 | 63 | """Determine the right protocol factory for 'bytes'. | 76 | """Determine the right protocol factory for 'bytes'. |
72 | 64 | 77 | ||
73 | @@ -656,7 +669,7 @@ | |||
74 | 656 | # A method we don't know about doesn't count as a VFS method. | 669 | # A method we don't know about doesn't count as a VFS method. |
75 | 657 | return | 670 | return |
76 | 658 | if issubclass(request_method, vfs.VfsRequest): | 671 | if issubclass(request_method, vfs.VfsRequest): |
78 | 659 | raise errors.HpssVfsRequestNotAllowed(params.method, params.args) | 672 | raise HpssVfsRequestNotAllowed(params.method, params.args) |
79 | 660 | 673 | ||
80 | 661 | 674 | ||
81 | 662 | class _DebugCounter(object): | 675 | class _DebugCounter(object): |
82 | 663 | 676 | ||
83 | === modified file 'breezy/bzr/smart/request.py' | |||
84 | --- breezy/bzr/smart/request.py 2017-06-11 20:15:04 +0000 | |||
85 | +++ breezy/bzr/smart/request.py 2017-07-23 16:06:20 +0000 | |||
86 | @@ -58,6 +58,15 @@ | |||
87 | 58 | jail_info.transports = None | 58 | jail_info.transports = None |
88 | 59 | 59 | ||
89 | 60 | 60 | ||
90 | 61 | class DisabledMethod(errors.InternalBzrError): | ||
91 | 62 | |||
92 | 63 | _fmt = "The smart server method '%(class_name)s' is disabled." | ||
93 | 64 | |||
94 | 65 | def __init__(self, class_name): | ||
95 | 66 | errors.BzrError.__init__(self) | ||
96 | 67 | self.class_name = class_name | ||
97 | 68 | |||
98 | 69 | |||
99 | 61 | def _install_hook(): | 70 | def _install_hook(): |
100 | 62 | bzrdir.BzrDir.hooks.install_named_hook( | 71 | bzrdir.BzrDir.hooks.install_named_hook( |
101 | 63 | 'pre_open', _pre_open_hook, 'checking server jail') | 72 | 'pre_open', _pre_open_hook, 'checking server jail') |
102 | 64 | 73 | ||
103 | === modified file 'breezy/bzr/smart/vfs.py' | |||
104 | --- breezy/bzr/smart/vfs.py 2017-06-11 20:15:04 +0000 | |||
105 | +++ breezy/bzr/smart/vfs.py 2017-07-23 16:06:20 +0000 | |||
106 | @@ -60,7 +60,7 @@ | |||
107 | 60 | 60 | ||
108 | 61 | def _check_enabled(self): | 61 | def _check_enabled(self): |
109 | 62 | if not vfs_enabled(): | 62 | if not vfs_enabled(): |
111 | 63 | raise errors.DisabledMethod(self.__class__.__name__) | 63 | raise request.DisabledMethod(self.__class__.__name__) |
112 | 64 | 64 | ||
113 | 65 | def translate_client_path(self, relpath): | 65 | def translate_client_path(self, relpath): |
114 | 66 | # VFS requests are made with escaped paths so the escaping done in | 66 | # VFS requests are made with escaped paths so the escaping done in |
115 | 67 | 67 | ||
116 | === modified file 'breezy/commands.py' | |||
117 | --- breezy/commands.py 2017-07-20 00:00:04 +0000 | |||
118 | +++ breezy/commands.py 2017-07-23 16:06:20 +0000 | |||
119 | @@ -61,6 +61,27 @@ | |||
120 | 61 | _fmt = "Error in command line options" | 61 | _fmt = "Error in command line options" |
121 | 62 | 62 | ||
122 | 63 | 63 | ||
123 | 64 | class CommandAvailableInPlugin(Exception): | ||
124 | 65 | |||
125 | 66 | internal_error = False | ||
126 | 67 | |||
127 | 68 | def __init__(self, cmd_name, plugin_metadata, provider): | ||
128 | 69 | |||
129 | 70 | self.plugin_metadata = plugin_metadata | ||
130 | 71 | self.cmd_name = cmd_name | ||
131 | 72 | self.provider = provider | ||
132 | 73 | |||
133 | 74 | def __str__(self): | ||
134 | 75 | |||
135 | 76 | _fmt = ('"%s" is not a standard brz command. \n' | ||
136 | 77 | 'However, the following official plugin provides this command: %s\n' | ||
137 | 78 | 'You can install it by going to: %s' | ||
138 | 79 | % (self.cmd_name, self.plugin_metadata['name'], | ||
139 | 80 | self.plugin_metadata['url'])) | ||
140 | 81 | |||
141 | 82 | return _fmt | ||
142 | 83 | |||
143 | 84 | |||
144 | 64 | class CommandInfo(object): | 85 | class CommandInfo(object): |
145 | 65 | """Information about a command.""" | 86 | """Information about a command.""" |
146 | 66 | 87 | ||
147 | @@ -325,13 +346,16 @@ | |||
148 | 325 | return cmd | 346 | return cmd |
149 | 326 | 347 | ||
150 | 327 | 348 | ||
151 | 349 | class NoPluginAvailable(errors.BzrError): | ||
152 | 350 | pass | ||
153 | 351 | |||
154 | 352 | |||
155 | 328 | def _try_plugin_provider(cmd_name): | 353 | def _try_plugin_provider(cmd_name): |
156 | 329 | """Probe for a plugin provider having cmd_name.""" | 354 | """Probe for a plugin provider having cmd_name.""" |
157 | 330 | try: | 355 | try: |
158 | 331 | plugin_metadata, provider = probe_for_provider(cmd_name) | 356 | plugin_metadata, provider = probe_for_provider(cmd_name) |
162 | 332 | raise errors.CommandAvailableInPlugin(cmd_name, | 357 | raise CommandAvailableInPlugin(cmd_name, plugin_metadata, provider) |
163 | 333 | plugin_metadata, provider) | 358 | except NoPluginAvailable: |
161 | 334 | except errors.NoPluginAvailable: | ||
164 | 335 | pass | 359 | pass |
165 | 336 | 360 | ||
166 | 337 | 361 | ||
167 | @@ -346,9 +370,9 @@ | |||
168 | 346 | for provider in command_providers_registry: | 370 | for provider in command_providers_registry: |
169 | 347 | try: | 371 | try: |
170 | 348 | return provider.plugin_for_command(cmd_name), provider | 372 | return provider.plugin_for_command(cmd_name), provider |
172 | 349 | except errors.NoPluginAvailable: | 373 | except NoPluginAvailable: |
173 | 350 | pass | 374 | pass |
175 | 351 | raise errors.NoPluginAvailable(cmd_name) | 375 | raise NoPluginAvailable(cmd_name) |
176 | 352 | 376 | ||
177 | 353 | 377 | ||
178 | 354 | def _get_bzr_command(cmd_or_None, cmd_name): | 378 | def _get_bzr_command(cmd_or_None, cmd_name): |
179 | 355 | 379 | ||
180 | === modified file 'breezy/errors.py' | |||
181 | --- breezy/errors.py 2017-07-21 14:18:24 +0000 | |||
182 | +++ breezy/errors.py 2017-07-23 16:06:20 +0000 | |||
183 | @@ -146,11 +146,6 @@ | |||
184 | 146 | internal_error = True | 146 | internal_error = True |
185 | 147 | 147 | ||
186 | 148 | 148 | ||
187 | 149 | class AlreadyBuilding(BzrError): | ||
188 | 150 | |||
189 | 151 | _fmt = "The tree builder is already building a tree." | ||
190 | 152 | |||
191 | 153 | |||
192 | 154 | class BranchError(BzrError): | 149 | class BranchError(BzrError): |
193 | 155 | """Base class for concrete 'errors about a branch'.""" | 150 | """Base class for concrete 'errors about a branch'.""" |
194 | 156 | 151 | ||
195 | @@ -177,15 +172,6 @@ | |||
196 | 177 | self.msg = msg | 172 | self.msg = msg |
197 | 178 | 173 | ||
198 | 179 | 174 | ||
199 | 180 | class DisabledMethod(InternalBzrError): | ||
200 | 181 | |||
201 | 182 | _fmt = "The smart server method '%(class_name)s' is disabled." | ||
202 | 183 | |||
203 | 184 | def __init__(self, class_name): | ||
204 | 185 | BzrError.__init__(self) | ||
205 | 186 | self.class_name = class_name | ||
206 | 187 | |||
207 | 188 | |||
208 | 189 | class IncompatibleVersion(BzrError): | 175 | class IncompatibleVersion(BzrError): |
209 | 190 | 176 | ||
210 | 191 | _fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\ | 177 | _fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\ |
211 | @@ -301,11 +287,6 @@ | |||
212 | 301 | self.base = base | 287 | self.base = base |
213 | 302 | 288 | ||
214 | 303 | 289 | ||
215 | 304 | class NotBuilding(BzrError): | ||
216 | 305 | |||
217 | 306 | _fmt = "Not currently building a tree." | ||
218 | 307 | |||
219 | 308 | |||
220 | 309 | class NotLocalUrl(BzrError): | 290 | class NotLocalUrl(BzrError): |
221 | 310 | 291 | ||
222 | 311 | _fmt = "%(url)s is not a local path." | 292 | _fmt = "%(url)s is not a local path." |
223 | @@ -2503,11 +2484,6 @@ | |||
224 | 2503 | self.name = name.decode("utf-8") | 2484 | self.name = name.decode("utf-8") |
225 | 2504 | 2485 | ||
226 | 2505 | 2486 | ||
227 | 2506 | class NoDestinationAddress(InternalBzrError): | ||
228 | 2507 | |||
229 | 2508 | _fmt = "Message does not have a destination address." | ||
230 | 2509 | |||
231 | 2510 | |||
232 | 2511 | class RepositoryDataStreamError(BzrError): | 2487 | class RepositoryDataStreamError(BzrError): |
233 | 2512 | 2488 | ||
234 | 2513 | _fmt = "Corrupt or incompatible data stream: %(reason)s" | 2489 | _fmt = "Corrupt or incompatible data stream: %(reason)s" |
235 | @@ -2516,48 +2492,6 @@ | |||
236 | 2516 | self.reason = reason | 2492 | self.reason = reason |
237 | 2517 | 2493 | ||
238 | 2518 | 2494 | ||
239 | 2519 | class SMTPError(BzrError): | ||
240 | 2520 | |||
241 | 2521 | _fmt = "SMTP error: %(error)s" | ||
242 | 2522 | |||
243 | 2523 | def __init__(self, error): | ||
244 | 2524 | self.error = error | ||
245 | 2525 | |||
246 | 2526 | |||
247 | 2527 | class NoMessageSupplied(BzrError): | ||
248 | 2528 | |||
249 | 2529 | _fmt = "No message supplied." | ||
250 | 2530 | |||
251 | 2531 | |||
252 | 2532 | class NoMailAddressSpecified(BzrError): | ||
253 | 2533 | |||
254 | 2534 | _fmt = "No mail-to address (--mail-to) or output (-o) specified." | ||
255 | 2535 | |||
256 | 2536 | |||
257 | 2537 | class MailClientNotFound(BzrError): | ||
258 | 2538 | |||
259 | 2539 | _fmt = "Unable to find mail client with the following names:"\ | ||
260 | 2540 | " %(mail_command_list_string)s" | ||
261 | 2541 | |||
262 | 2542 | def __init__(self, mail_command_list): | ||
263 | 2543 | mail_command_list_string = ', '.join(mail_command_list) | ||
264 | 2544 | BzrError.__init__(self, mail_command_list=mail_command_list, | ||
265 | 2545 | mail_command_list_string=mail_command_list_string) | ||
266 | 2546 | |||
267 | 2547 | class SMTPConnectionRefused(SMTPError): | ||
268 | 2548 | |||
269 | 2549 | _fmt = "SMTP connection to %(host)s refused" | ||
270 | 2550 | |||
271 | 2551 | def __init__(self, error, host): | ||
272 | 2552 | self.error = error | ||
273 | 2553 | self.host = host | ||
274 | 2554 | |||
275 | 2555 | |||
276 | 2556 | class DefaultSMTPConnectionRefused(SMTPConnectionRefused): | ||
277 | 2557 | |||
278 | 2558 | _fmt = "Please specify smtp_server. No server at default %(host)s." | ||
279 | 2559 | |||
280 | 2560 | |||
281 | 2561 | class BzrDirError(BzrError): | 2495 | class BzrDirError(BzrError): |
282 | 2562 | 2496 | ||
283 | 2563 | def __init__(self, controldir): | 2497 | def __init__(self, controldir): |
284 | @@ -2708,31 +2642,6 @@ | |||
285 | 2708 | self.timezone = timezone | 2642 | self.timezone = timezone |
286 | 2709 | 2643 | ||
287 | 2710 | 2644 | ||
288 | 2711 | class CommandAvailableInPlugin(Exception): | ||
289 | 2712 | |||
290 | 2713 | internal_error = False | ||
291 | 2714 | |||
292 | 2715 | def __init__(self, cmd_name, plugin_metadata, provider): | ||
293 | 2716 | |||
294 | 2717 | self.plugin_metadata = plugin_metadata | ||
295 | 2718 | self.cmd_name = cmd_name | ||
296 | 2719 | self.provider = provider | ||
297 | 2720 | |||
298 | 2721 | def __str__(self): | ||
299 | 2722 | |||
300 | 2723 | _fmt = ('"%s" is not a standard brz command. \n' | ||
301 | 2724 | 'However, the following official plugin provides this command: %s\n' | ||
302 | 2725 | 'You can install it by going to: %s' | ||
303 | 2726 | % (self.cmd_name, self.plugin_metadata['name'], | ||
304 | 2727 | self.plugin_metadata['url'])) | ||
305 | 2728 | |||
306 | 2729 | return _fmt | ||
307 | 2730 | |||
308 | 2731 | |||
309 | 2732 | class NoPluginAvailable(BzrError): | ||
310 | 2733 | pass | ||
311 | 2734 | |||
312 | 2735 | |||
313 | 2736 | class UnableEncodePath(BzrError): | 2645 | class UnableEncodePath(BzrError): |
314 | 2737 | 2646 | ||
315 | 2738 | _fmt = ('Unable to encode %(kind)s path %(path)r in ' | 2647 | _fmt = ('Unable to encode %(kind)s path %(path)r in ' |
316 | @@ -2804,11 +2713,6 @@ | |||
317 | 2804 | self.msg = msg | 2713 | self.msg = msg |
318 | 2805 | 2714 | ||
319 | 2806 | 2715 | ||
320 | 2807 | class ShelfCorrupt(BzrError): | ||
321 | 2808 | |||
322 | 2809 | _fmt = "Shelf corrupt." | ||
323 | 2810 | |||
324 | 2811 | |||
325 | 2812 | class DecompressCorruption(BzrError): | 2716 | class DecompressCorruption(BzrError): |
326 | 2813 | 2717 | ||
327 | 2814 | _fmt = "Corruption while decompressing repository file%(orig_error)s" | 2718 | _fmt = "Corruption while decompressing repository file%(orig_error)s" |
328 | @@ -2821,22 +2725,6 @@ | |||
329 | 2821 | BzrError.__init__(self) | 2725 | BzrError.__init__(self) |
330 | 2822 | 2726 | ||
331 | 2823 | 2727 | ||
332 | 2824 | class NoSuchShelfId(BzrError): | ||
333 | 2825 | |||
334 | 2826 | _fmt = 'No changes are shelved with id "%(shelf_id)d".' | ||
335 | 2827 | |||
336 | 2828 | def __init__(self, shelf_id): | ||
337 | 2829 | BzrError.__init__(self, shelf_id=shelf_id) | ||
338 | 2830 | |||
339 | 2831 | |||
340 | 2832 | class InvalidShelfId(BzrError): | ||
341 | 2833 | |||
342 | 2834 | _fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.' | ||
343 | 2835 | |||
344 | 2836 | def __init__(self, invalid_id): | ||
345 | 2837 | BzrError.__init__(self, invalid_id=invalid_id) | ||
346 | 2838 | |||
347 | 2839 | |||
348 | 2840 | class JailBreak(BzrError): | 2728 | class JailBreak(BzrError): |
349 | 2841 | 2729 | ||
350 | 2842 | _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'." | 2730 | _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'." |
351 | @@ -2858,37 +2746,6 @@ | |||
352 | 2858 | BzrError.__init__(self, format=format, url=url) | 2746 | BzrError.__init__(self, format=format, url=url) |
353 | 2859 | 2747 | ||
354 | 2860 | 2748 | ||
355 | 2861 | class NoSuchView(BzrError): | ||
356 | 2862 | """A view does not exist. | ||
357 | 2863 | """ | ||
358 | 2864 | |||
359 | 2865 | _fmt = u"No such view: %(view_name)s." | ||
360 | 2866 | |||
361 | 2867 | def __init__(self, view_name): | ||
362 | 2868 | self.view_name = view_name | ||
363 | 2869 | |||
364 | 2870 | |||
365 | 2871 | class ViewsNotSupported(BzrError): | ||
366 | 2872 | """Views are not supported by a tree format. | ||
367 | 2873 | """ | ||
368 | 2874 | |||
369 | 2875 | _fmt = ("Views are not supported by %(tree)s;" | ||
370 | 2876 | " use 'brz upgrade' to change your tree to a later format.") | ||
371 | 2877 | |||
372 | 2878 | def __init__(self, tree): | ||
373 | 2879 | self.tree = tree | ||
374 | 2880 | |||
375 | 2881 | |||
376 | 2882 | class FileOutsideView(BzrError): | ||
377 | 2883 | |||
378 | 2884 | _fmt = ('Specified file "%(file_name)s" is outside the current view: ' | ||
379 | 2885 | '%(view_str)s') | ||
380 | 2886 | |||
381 | 2887 | def __init__(self, file_name, view_files): | ||
382 | 2888 | self.file_name = file_name | ||
383 | 2889 | self.view_str = ", ".join(view_files) | ||
384 | 2890 | |||
385 | 2891 | |||
386 | 2892 | class UnresumableWriteGroup(BzrError): | 2749 | class UnresumableWriteGroup(BzrError): |
387 | 2893 | 2750 | ||
388 | 2894 | _fmt = ("Repository %(repository)s cannot resume write group " | 2751 | _fmt = ("Repository %(repository)s cannot resume write group " |
389 | @@ -2953,16 +2810,6 @@ | |||
390 | 2953 | self.branch_url = branch_url | 2810 | self.branch_url = branch_url |
391 | 2954 | 2811 | ||
392 | 2955 | 2812 | ||
393 | 2956 | class HpssVfsRequestNotAllowed(BzrError): | ||
394 | 2957 | |||
395 | 2958 | _fmt = ("VFS requests over the smart server are not allowed. Encountered: " | ||
396 | 2959 | "%(method)s, %(arguments)s.") | ||
397 | 2960 | |||
398 | 2961 | def __init__(self, method, arguments): | ||
399 | 2962 | self.method = method | ||
400 | 2963 | self.arguments = arguments | ||
401 | 2964 | |||
402 | 2965 | |||
403 | 2966 | class UnsupportedKindChange(BzrError): | 2813 | class UnsupportedKindChange(BzrError): |
404 | 2967 | 2814 | ||
405 | 2968 | _fmt = ("Kind change from %(from_kind)s to %(to_kind)s for " | 2815 | _fmt = ("Kind change from %(from_kind)s to %(to_kind)s for " |
406 | 2969 | 2816 | ||
407 | === modified file 'breezy/mail_client.py' | |||
408 | --- breezy/mail_client.py 2017-06-05 20:48:31 +0000 | |||
409 | +++ breezy/mail_client.py 2017-07-23 16:06:20 +0000 | |||
410 | @@ -36,6 +36,28 @@ | |||
411 | 36 | mail_client_registry = registry.Registry() | 36 | mail_client_registry = registry.Registry() |
412 | 37 | 37 | ||
413 | 38 | 38 | ||
414 | 39 | class MailClientNotFound(errors.BzrError): | ||
415 | 40 | |||
416 | 41 | _fmt = "Unable to find mail client with the following names:"\ | ||
417 | 42 | " %(mail_command_list_string)s" | ||
418 | 43 | |||
419 | 44 | def __init__(self, mail_command_list): | ||
420 | 45 | mail_command_list_string = ', '.join(mail_command_list) | ||
421 | 46 | errors.BzrError.__init__( | ||
422 | 47 | self, mail_command_list=mail_command_list, | ||
423 | 48 | mail_command_list_string=mail_command_list_string) | ||
424 | 49 | |||
425 | 50 | |||
426 | 51 | class NoMessageSupplied(errors.BzrError): | ||
427 | 52 | |||
428 | 53 | _fmt = "No message supplied." | ||
429 | 54 | |||
430 | 55 | |||
431 | 56 | class NoMailAddressSpecified(errors.BzrError): | ||
432 | 57 | |||
433 | 58 | _fmt = "No mail-to address (--mail-to) or output (-o) specified." | ||
434 | 59 | |||
435 | 60 | |||
436 | 39 | class MailClient(object): | 61 | class MailClient(object): |
437 | 40 | """A mail client that can send messages with attachements.""" | 62 | """A mail client that can send messages with attachements.""" |
438 | 41 | 63 | ||
439 | @@ -107,10 +129,10 @@ | |||
440 | 107 | extension, basename=None, body=None): | 129 | extension, basename=None, body=None): |
441 | 108 | """See MailClient.compose""" | 130 | """See MailClient.compose""" |
442 | 109 | if not to: | 131 | if not to: |
444 | 110 | raise errors.NoMailAddressSpecified() | 132 | raise NoMailAddressSpecified() |
445 | 111 | body = msgeditor.edit_commit_message(prompt, start_message=body) | 133 | body = msgeditor.edit_commit_message(prompt, start_message=body) |
446 | 112 | if body == '': | 134 | if body == '': |
448 | 113 | raise errors.NoMessageSupplied() | 135 | raise NoMessageSupplied() |
449 | 114 | email_message.EmailMessage.send(self.config, | 136 | email_message.EmailMessage.send(self.config, |
450 | 115 | self.config.get('email'), | 137 | self.config.get('email'), |
451 | 116 | to, | 138 | to, |
452 | @@ -190,7 +212,7 @@ | |||
453 | 190 | else: | 212 | else: |
454 | 191 | break | 213 | break |
455 | 192 | else: | 214 | else: |
457 | 193 | raise errors.MailClientNotFound(self._client_commands) | 215 | raise MailClientNotFound(self._client_commands) |
458 | 194 | 216 | ||
459 | 195 | def _get_compose_commandline(self, to, subject, attach_path, body): | 217 | def _get_compose_commandline(self, to, subject, attach_path, body): |
460 | 196 | """Determine the commandline to use for composing a message | 218 | """Determine the commandline to use for composing a message |
461 | @@ -365,7 +387,7 @@ | |||
462 | 365 | 'body=' + urlutils.quote(self._encode_safe(body))) | 387 | 'body=' + urlutils.quote(self._encode_safe(body))) |
463 | 366 | # to must be supplied for the claws-mail --compose syntax to work. | 388 | # to must be supplied for the claws-mail --compose syntax to work. |
464 | 367 | if to is None: | 389 | if to is None: |
466 | 368 | raise errors.NoMailAddressSpecified() | 390 | raise NoMailAddressSpecified() |
467 | 369 | compose_url = 'mailto:%s?%s' % ( | 391 | compose_url = 'mailto:%s?%s' % ( |
468 | 370 | self._encode_safe(to), '&'.join(compose_url)) | 392 | self._encode_safe(to), '&'.join(compose_url)) |
469 | 371 | # Collect command-line options. | 393 | # Collect command-line options. |
470 | @@ -396,7 +418,7 @@ | |||
471 | 396 | def _get_compose_commandline(self, to, subject, attach_path, body=None): | 418 | def _get_compose_commandline(self, to, subject, attach_path, body=None): |
472 | 397 | """See ExternalMailClient._get_compose_commandline""" | 419 | """See ExternalMailClient._get_compose_commandline""" |
473 | 398 | if not to: | 420 | if not to: |
475 | 399 | raise errors.NoMailAddressSpecified() | 421 | raise NoMailAddressSpecified() |
476 | 400 | commandline = [self._encode_safe(to)] | 422 | commandline = [self._encode_safe(to)] |
477 | 401 | if subject is not None: | 423 | if subject is not None: |
478 | 402 | commandline.extend(['--subject', self._encode_safe(subject)]) | 424 | commandline.extend(['--subject', self._encode_safe(subject)]) |
479 | @@ -535,7 +557,7 @@ | |||
480 | 535 | attach_path) | 557 | attach_path) |
481 | 536 | except simplemapi.MAPIError as e: | 558 | except simplemapi.MAPIError as e: |
482 | 537 | if e.code != simplemapi.MAPI_USER_ABORT: | 559 | if e.code != simplemapi.MAPI_USER_ABORT: |
484 | 538 | raise errors.MailClientNotFound(['MAPI supported mail client' | 560 | raise MailClientNotFound(['MAPI supported mail client' |
485 | 539 | ' (error %d)' % (e.code,)]) | 561 | ' (error %d)' % (e.code,)]) |
486 | 540 | mail_client_registry.register('mapi', MAPIClient, | 562 | mail_client_registry.register('mapi', MAPIClient, |
487 | 541 | help=MAPIClient.__doc__) | 563 | help=MAPIClient.__doc__) |
488 | @@ -620,7 +642,7 @@ | |||
489 | 620 | return self._mail_client().compose(prompt, to, subject, | 642 | return self._mail_client().compose(prompt, to, subject, |
490 | 621 | attachment, mime_subtype, | 643 | attachment, mime_subtype, |
491 | 622 | extension, basename, body) | 644 | extension, basename, body) |
493 | 623 | except errors.MailClientNotFound: | 645 | except MailClientNotFound: |
494 | 624 | return Editor(self.config).compose(prompt, to, subject, | 646 | return Editor(self.config).compose(prompt, to, subject, |
495 | 625 | attachment, mime_subtype, extension, body) | 647 | attachment, mime_subtype, extension, body) |
496 | 626 | 648 | ||
497 | @@ -630,7 +652,7 @@ | |||
498 | 630 | try: | 652 | try: |
499 | 631 | return self._mail_client().compose_merge_request(to, subject, | 653 | return self._mail_client().compose_merge_request(to, subject, |
500 | 632 | directive, basename=basename, body=body) | 654 | directive, basename=basename, body=body) |
502 | 633 | except errors.MailClientNotFound: | 655 | except MailClientNotFound: |
503 | 634 | return Editor(self.config).compose_merge_request(to, subject, | 656 | return Editor(self.config).compose_merge_request(to, subject, |
504 | 635 | directive, basename=basename, body=body) | 657 | directive, basename=basename, body=body) |
505 | 636 | mail_client_registry.register('default', DefaultMail, | 658 | mail_client_registry.register('default', DefaultMail, |
506 | 637 | 659 | ||
507 | === modified file 'breezy/shelf.py' | |||
508 | --- breezy/shelf.py 2017-06-24 13:32:35 +0000 | |||
509 | +++ breezy/shelf.py 2017-07-23 16:06:20 +0000 | |||
510 | @@ -19,11 +19,11 @@ | |||
511 | 19 | import errno | 19 | import errno |
512 | 20 | import re | 20 | import re |
513 | 21 | 21 | ||
514 | 22 | from . import errors | ||
515 | 22 | from .lazy_import import lazy_import | 23 | from .lazy_import import lazy_import |
516 | 23 | lazy_import(globals(), """ | 24 | lazy_import(globals(), """ |
517 | 24 | from breezy import ( | 25 | from breezy import ( |
518 | 25 | bencode, | 26 | bencode, |
519 | 26 | errors, | ||
520 | 27 | merge, | 27 | merge, |
521 | 28 | merge3, | 28 | merge3, |
522 | 29 | transform, | 29 | transform, |
523 | @@ -34,6 +34,27 @@ | |||
524 | 34 | """) | 34 | """) |
525 | 35 | 35 | ||
526 | 36 | 36 | ||
527 | 37 | class ShelfCorrupt(errors.BzrError): | ||
528 | 38 | |||
529 | 39 | _fmt = "Shelf corrupt." | ||
530 | 40 | |||
531 | 41 | |||
532 | 42 | class NoSuchShelfId(errors.BzrError): | ||
533 | 43 | |||
534 | 44 | _fmt = 'No changes are shelved with id "%(shelf_id)d".' | ||
535 | 45 | |||
536 | 46 | def __init__(self, shelf_id): | ||
537 | 47 | errors.BzrError.__init__(self, shelf_id=shelf_id) | ||
538 | 48 | |||
539 | 49 | |||
540 | 50 | class InvalidShelfId(errors.BzrError): | ||
541 | 51 | |||
542 | 52 | _fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.' | ||
543 | 53 | |||
544 | 54 | def __init__(self, invalid_id): | ||
545 | 55 | errors.BzrError.__init__(self, invalid_id=invalid_id) | ||
546 | 56 | |||
547 | 57 | |||
548 | 37 | class ShelfCreator(object): | 58 | class ShelfCreator(object): |
549 | 38 | """Create a transform to shelve objects and its inverse.""" | 59 | """Create a transform to shelve objects and its inverse.""" |
550 | 39 | 60 | ||
551 | @@ -318,7 +339,7 @@ | |||
552 | 318 | def parse_metadata(records): | 339 | def parse_metadata(records): |
553 | 319 | names, metadata_bytes = next(records) | 340 | names, metadata_bytes = next(records) |
554 | 320 | if names[0] != ('metadata',): | 341 | if names[0] != ('metadata',): |
556 | 321 | raise errors.ShelfCorrupt | 342 | raise ShelfCorrupt |
557 | 322 | metadata = bencode.bdecode(metadata_bytes) | 343 | metadata = bencode.bdecode(metadata_bytes) |
558 | 323 | message = metadata.get('message') | 344 | message = metadata.get('message') |
559 | 324 | if message is not None: | 345 | if message is not None: |
560 | @@ -409,8 +430,7 @@ | |||
561 | 409 | except IOError as e: | 430 | except IOError as e: |
562 | 410 | if e.errno != errno.ENOENT: | 431 | if e.errno != errno.ENOENT: |
563 | 411 | raise | 432 | raise |
566 | 412 | from . import errors | 433 | raise NoSuchShelfId(shelf_id) |
565 | 413 | raise errors.NoSuchShelfId(shelf_id) | ||
567 | 414 | 434 | ||
568 | 415 | def get_unshelver(self, shelf_id): | 435 | def get_unshelver(self, shelf_id): |
569 | 416 | """Return an unshelver for a given shelf_id. | 436 | """Return an unshelver for a given shelf_id. |
570 | 417 | 437 | ||
571 | === modified file 'breezy/shelf_ui.py' | |||
572 | --- breezy/shelf_ui.py 2017-06-24 13:32:35 +0000 | |||
573 | +++ breezy/shelf_ui.py 2017-07-23 16:06:20 +0000 | |||
574 | @@ -398,7 +398,7 @@ | |||
575 | 398 | try: | 398 | try: |
576 | 399 | shelf_id = int(shelf_id) | 399 | shelf_id = int(shelf_id) |
577 | 400 | except ValueError: | 400 | except ValueError: |
579 | 401 | raise errors.InvalidShelfId(shelf_id) | 401 | raise shelf.InvalidShelfId(shelf_id) |
580 | 402 | else: | 402 | else: |
581 | 403 | shelf_id = manager.last_shelf() | 403 | shelf_id = manager.last_shelf() |
582 | 404 | if shelf_id is None: | 404 | if shelf_id is None: |
583 | 405 | 405 | ||
584 | === modified file 'breezy/smtp_connection.py' | |||
585 | --- breezy/smtp_connection.py 2017-06-05 20:48:31 +0000 | |||
586 | +++ breezy/smtp_connection.py 2017-07-23 16:06:20 +0000 | |||
587 | @@ -28,10 +28,8 @@ | |||
588 | 28 | osutils, | 28 | osutils, |
589 | 29 | ) | 29 | ) |
590 | 30 | from .errors import ( | 30 | from .errors import ( |
595 | 31 | NoDestinationAddress, | 31 | BzrError, |
596 | 32 | SMTPError, | 32 | InternalBzrError, |
593 | 33 | DefaultSMTPConnectionRefused, | ||
594 | 34 | SMTPConnectionRefused, | ||
597 | 35 | ) | 33 | ) |
598 | 36 | 34 | ||
599 | 37 | 35 | ||
600 | @@ -49,6 +47,35 @@ | |||
601 | 49 | ''') | 47 | ''') |
602 | 50 | 48 | ||
603 | 51 | 49 | ||
604 | 50 | class SMTPError(BzrError): | ||
605 | 51 | |||
606 | 52 | _fmt = "SMTP error: %(error)s" | ||
607 | 53 | |||
608 | 54 | def __init__(self, error): | ||
609 | 55 | self.error = error | ||
610 | 56 | |||
611 | 57 | |||
612 | 58 | class SMTPConnectionRefused(SMTPError): | ||
613 | 59 | |||
614 | 60 | _fmt = "SMTP connection to %(host)s refused" | ||
615 | 61 | |||
616 | 62 | def __init__(self, error, host): | ||
617 | 63 | self.error = error | ||
618 | 64 | self.host = host | ||
619 | 65 | |||
620 | 66 | |||
621 | 67 | class DefaultSMTPConnectionRefused(SMTPConnectionRefused): | ||
622 | 68 | |||
623 | 69 | _fmt = "Please specify smtp_server. No server at default %(host)s." | ||
624 | 70 | |||
625 | 71 | |||
626 | 72 | |||
627 | 73 | class NoDestinationAddress(InternalBzrError): | ||
628 | 74 | |||
629 | 75 | _fmt = "Message does not have a destination address." | ||
630 | 76 | |||
631 | 77 | |||
632 | 78 | |||
633 | 52 | class SMTPConnection(object): | 79 | class SMTPConnection(object): |
634 | 53 | """Connect to an SMTP server and send an email. | 80 | """Connect to an SMTP server and send an email. |
635 | 54 | 81 | ||
636 | 55 | 82 | ||
637 | === modified file 'breezy/tests/__init__.py' | |||
638 | --- breezy/tests/__init__.py 2017-07-02 13:44:33 +0000 | |||
639 | +++ breezy/tests/__init__.py 2017-07-23 16:06:20 +0000 | |||
640 | @@ -4053,6 +4053,7 @@ | |||
641 | 4053 | 'breezy.tests.test_version_info', | 4053 | 'breezy.tests.test_version_info', |
642 | 4054 | 'breezy.tests.test_versionedfile', | 4054 | 'breezy.tests.test_versionedfile', |
643 | 4055 | 'breezy.tests.test_vf_search', | 4055 | 'breezy.tests.test_vf_search', |
644 | 4056 | 'breezy.tests.test_views', | ||
645 | 4056 | 'breezy.tests.test_weave', | 4057 | 'breezy.tests.test_weave', |
646 | 4057 | 'breezy.tests.test_whitebox', | 4058 | 'breezy.tests.test_whitebox', |
647 | 4058 | 'breezy.tests.test_win32utils', | 4059 | 'breezy.tests.test_win32utils', |
648 | 4059 | 4060 | ||
649 | === modified file 'breezy/tests/per_workingtree/test_views.py' | |||
650 | --- breezy/tests/per_workingtree/test_views.py 2017-05-22 00:56:52 +0000 | |||
651 | +++ breezy/tests/per_workingtree/test_views.py 2017-07-23 16:06:20 +0000 | |||
652 | @@ -21,7 +21,7 @@ | |||
653 | 21 | """ | 21 | """ |
654 | 22 | 22 | ||
655 | 23 | 23 | ||
657 | 24 | from breezy import views, errors | 24 | from breezy import views as _mod_views |
658 | 25 | from breezy.tests import TestNotApplicable, TestSkipped | 25 | from breezy.tests import TestNotApplicable, TestSkipped |
659 | 26 | from breezy.workingtree import WorkingTree | 26 | from breezy.workingtree import WorkingTree |
660 | 27 | 27 | ||
661 | @@ -64,7 +64,7 @@ | |||
662 | 64 | self.assertEqual(view_current, current) | 64 | self.assertEqual(view_current, current) |
663 | 65 | self.assertEqual(view_dict, views) | 65 | self.assertEqual(view_dict, views) |
664 | 66 | # test setting a current view which does not exist | 66 | # test setting a current view which does not exist |
666 | 67 | self.assertRaises(errors.NoSuchView, | 67 | self.assertRaises(_mod_views.NoSuchView, |
667 | 68 | wt.views.set_view_info, 'yet-another', view_dict) | 68 | wt.views.set_view_info, 'yet-another', view_dict) |
668 | 69 | current, views = wt.views.get_view_info() | 69 | current, views = wt.views.get_view_info() |
669 | 70 | self.assertEqual(view_current, current) | 70 | self.assertEqual(view_current, current) |
670 | @@ -116,7 +116,7 @@ | |||
671 | 116 | wt = self.make_branch_and_tree('wt') | 116 | wt = self.make_branch_and_tree('wt') |
672 | 117 | try: | 117 | try: |
673 | 118 | wt.views.lookup_view('opaque') | 118 | wt.views.lookup_view('opaque') |
675 | 119 | except errors.NoSuchView as e: | 119 | except _mod_views.NoSuchView as e: |
676 | 120 | self.assertEqual(e.view_name, 'opaque') | 120 | self.assertEqual(e.view_name, 'opaque') |
677 | 121 | self.assertEqual(str(e), 'No such view: opaque.') | 121 | self.assertEqual(str(e), 'No such view: opaque.') |
678 | 122 | else: | 122 | else: |
679 | @@ -130,15 +130,15 @@ | |||
680 | 130 | # now try to delete it | 130 | # now try to delete it |
681 | 131 | wt.views.delete_view(view_name) | 131 | wt.views.delete_view(view_name) |
682 | 132 | # now you can't look it up | 132 | # now you can't look it up |
684 | 133 | self.assertRaises(errors.NoSuchView, | 133 | self.assertRaises(_mod_views.NoSuchView, |
685 | 134 | wt.views.lookup_view, view_name) | 134 | wt.views.lookup_view, view_name) |
686 | 135 | # and it's not in the dictionary | 135 | # and it's not in the dictionary |
687 | 136 | self.assertEqual(wt.views.get_view_info()[1], {}) | 136 | self.assertEqual(wt.views.get_view_info()[1], {}) |
688 | 137 | # and you can't remove it a second time | 137 | # and you can't remove it a second time |
690 | 138 | self.assertRaises(errors.NoSuchView, | 138 | self.assertRaises(_mod_views.NoSuchView, |
691 | 139 | wt.views.delete_view, view_name) | 139 | wt.views.delete_view, view_name) |
692 | 140 | # or remove a view that never existed | 140 | # or remove a view that never existed |
694 | 141 | self.assertRaises(errors.NoSuchView, | 141 | self.assertRaises(_mod_views.NoSuchView, |
695 | 142 | wt.views.delete_view, view_name + '2') | 142 | wt.views.delete_view, view_name + '2') |
696 | 143 | 143 | ||
697 | 144 | def test_check_path_in_view(self): | 144 | def test_check_path_in_view(self): |
698 | @@ -148,14 +148,14 @@ | |||
699 | 148 | view_current: ['dir-1'], | 148 | view_current: ['dir-1'], |
700 | 149 | 'other-name': ['dir-2']} | 149 | 'other-name': ['dir-2']} |
701 | 150 | wt.views.set_view_info(view_current, view_dict) | 150 | wt.views.set_view_info(view_current, view_dict) |
710 | 151 | self.assertEqual(views.check_path_in_view(wt, 'dir-1'), None) | 151 | self.assertEqual(_mod_views.check_path_in_view(wt, 'dir-1'), None) |
711 | 152 | self.assertEqual(views.check_path_in_view(wt, 'dir-1/sub'), None) | 152 | self.assertEqual(_mod_views.check_path_in_view(wt, 'dir-1/sub'), None) |
712 | 153 | self.assertRaises(errors.FileOutsideView, | 153 | self.assertRaises(_mod_views.FileOutsideView, |
713 | 154 | views.check_path_in_view, wt, 'dir-2') | 154 | _mod_views.check_path_in_view, wt, 'dir-2') |
714 | 155 | self.assertRaises(errors.FileOutsideView, | 155 | self.assertRaises(_mod_views.FileOutsideView, |
715 | 156 | views.check_path_in_view, wt, 'dir-2/sub') | 156 | _mod_views.check_path_in_view, wt, 'dir-2/sub') |
716 | 157 | self.assertRaises(errors.FileOutsideView, | 157 | self.assertRaises(_mod_views.FileOutsideView, |
717 | 158 | views.check_path_in_view, wt, 'other') | 158 | _mod_views.check_path_in_view, wt, 'other') |
718 | 159 | 159 | ||
719 | 160 | 160 | ||
720 | 161 | class TestUnsupportedViews(TestCaseWithWorkingTree): | 161 | class TestUnsupportedViews(TestCaseWithWorkingTree): |
721 | @@ -176,13 +176,13 @@ | |||
722 | 176 | 176 | ||
723 | 177 | def test_view_methods_raise(self): | 177 | def test_view_methods_raise(self): |
724 | 178 | wt = self.make_branch_and_tree('wt') | 178 | wt = self.make_branch_and_tree('wt') |
726 | 179 | self.assertRaises(errors.ViewsNotSupported, | 179 | self.assertRaises(_mod_views.ViewsNotSupported, |
727 | 180 | wt.views.set_view_info, 'bar', {'bar': ['bars/']}) | 180 | wt.views.set_view_info, 'bar', {'bar': ['bars/']}) |
729 | 181 | self.assertRaises(errors.ViewsNotSupported, | 181 | self.assertRaises(_mod_views.ViewsNotSupported, |
730 | 182 | wt.views.get_view_info) | 182 | wt.views.get_view_info) |
732 | 183 | self.assertRaises(errors.ViewsNotSupported, | 183 | self.assertRaises(_mod_views.ViewsNotSupported, |
733 | 184 | wt.views.lookup_view, 'foo') | 184 | wt.views.lookup_view, 'foo') |
735 | 185 | self.assertRaises(errors.ViewsNotSupported, | 185 | self.assertRaises(_mod_views.ViewsNotSupported, |
736 | 186 | wt.views.set_view, 'foo', 'bar') | 186 | wt.views.set_view, 'foo', 'bar') |
738 | 187 | self.assertRaises(errors.ViewsNotSupported, | 187 | self.assertRaises(_mod_views.ViewsNotSupported, |
739 | 188 | wt.views.delete_view, 'foo') | 188 | wt.views.delete_view, 'foo') |
740 | 189 | 189 | ||
741 | === modified file 'breezy/tests/test_errors.py' | |||
742 | --- breezy/tests/test_errors.py 2017-07-21 14:18:24 +0000 | |||
743 | +++ breezy/tests/test_errors.py 2017-07-23 16:06:20 +0000 | |||
744 | @@ -77,11 +77,6 @@ | |||
745 | 77 | " appears to be corrupt: trailing garbage: \"x\"", | 77 | " appears to be corrupt: trailing garbage: \"x\"", |
746 | 78 | str(error)) | 78 | str(error)) |
747 | 79 | 79 | ||
748 | 80 | def test_disabled_method(self): | ||
749 | 81 | error = errors.DisabledMethod("class name") | ||
750 | 82 | self.assertEqualDiff( | ||
751 | 83 | "The smart server method 'class name' is disabled.", str(error)) | ||
752 | 84 | |||
753 | 85 | def test_duplicate_file_id(self): | 80 | def test_duplicate_file_id(self): |
754 | 86 | error = errors.DuplicateFileId('a_file_id', 'foo') | 81 | error = errors.DuplicateFileId('a_file_id', 'foo') |
755 | 87 | self.assertEqualDiff('File id {a_file_id} already exists in inventory' | 82 | self.assertEqualDiff('File id {a_file_id} already exists in inventory' |
756 | @@ -548,28 +543,6 @@ | |||
757 | 548 | self.assertEqual(str(err), "Branching 'bar'(foo) must create a" | 543 | self.assertEqual(str(err), "Branching 'bar'(foo) must create a" |
758 | 549 | " working tree.") | 544 | " working tree.") |
759 | 550 | 545 | ||
760 | 551 | def test_no_such_view(self): | ||
761 | 552 | err = errors.NoSuchView('foo') | ||
762 | 553 | self.assertEqual("No such view: foo.", str(err)) | ||
763 | 554 | |||
764 | 555 | def test_views_not_supported(self): | ||
765 | 556 | err = errors.ViewsNotSupported('atree') | ||
766 | 557 | err_str = str(err) | ||
767 | 558 | self.assertStartsWith(err_str, "Views are not supported by ") | ||
768 | 559 | self.assertEndsWith(err_str, "; use 'brz upgrade' to change your " | ||
769 | 560 | "tree to a later format.") | ||
770 | 561 | |||
771 | 562 | def test_file_outside_view(self): | ||
772 | 563 | err = errors.FileOutsideView('baz', ['foo', 'bar']) | ||
773 | 564 | self.assertEqual('Specified file "baz" is outside the current view: ' | ||
774 | 565 | 'foo, bar', str(err)) | ||
775 | 566 | |||
776 | 567 | def test_invalid_shelf_id(self): | ||
777 | 568 | invalid_id = "foo" | ||
778 | 569 | err = errors.InvalidShelfId(invalid_id) | ||
779 | 570 | self.assertEqual('"foo" is not a valid shelf id, ' | ||
780 | 571 | 'try a number instead.', str(err)) | ||
781 | 572 | |||
782 | 573 | def test_unresumable_write_group(self): | 546 | def test_unresumable_write_group(self): |
783 | 574 | repo = "dummy repo" | 547 | repo = "dummy repo" |
784 | 575 | wg_tokens = ['token'] | 548 | wg_tokens = ['token'] |
785 | 576 | 549 | ||
786 | === modified file 'breezy/tests/test_mail_client.py' | |||
787 | --- breezy/tests/test_mail_client.py 2017-05-22 00:56:52 +0000 | |||
788 | +++ breezy/tests/test_mail_client.py 2017-07-23 16:06:20 +0000 | |||
789 | @@ -118,7 +118,7 @@ | |||
790 | 118 | 118 | ||
791 | 119 | def test_commandline(self): | 119 | def test_commandline(self): |
792 | 120 | xdg_email = mail_client.XDGEmail(None) | 120 | xdg_email = mail_client.XDGEmail(None) |
794 | 121 | self.assertRaises(errors.NoMailAddressSpecified, | 121 | self.assertRaises(mail_client.NoMailAddressSpecified, |
795 | 122 | xdg_email._get_compose_commandline, | 122 | xdg_email._get_compose_commandline, |
796 | 123 | None, None, 'file%') | 123 | None, None, 'file%') |
797 | 124 | commandline = xdg_email._get_compose_commandline( | 124 | commandline = xdg_email._get_compose_commandline( |
798 | @@ -233,7 +233,7 @@ | |||
799 | 233 | 233 | ||
800 | 234 | def test_to_required(self): | 234 | def test_to_required(self): |
801 | 235 | claws = mail_client.Claws(None) | 235 | claws = mail_client.Claws(None) |
803 | 236 | self.assertRaises(errors.NoMailAddressSpecified, | 236 | self.assertRaises(mail_client.NoMailAddressSpecified, |
804 | 237 | claws._get_compose_commandline, | 237 | claws._get_compose_commandline, |
805 | 238 | None, None, 'file%') | 238 | None, None, 'file%') |
806 | 239 | 239 | ||
807 | 240 | 240 | ||
808 | === modified file 'breezy/tests/test_shelf.py' | |||
809 | --- breezy/tests/test_shelf.py 2017-06-08 23:30:31 +0000 | |||
810 | +++ breezy/tests/test_shelf.py 2017-07-23 16:06:20 +0000 | |||
811 | @@ -43,6 +43,15 @@ | |||
812 | 43 | "17:_removed_contentsle11:_removed_idle14:_tree_path_idsdeeE") | 43 | "17:_removed_contentsle11:_removed_idle14:_tree_path_idsdeeE") |
813 | 44 | 44 | ||
814 | 45 | 45 | ||
815 | 46 | class TestErrors(tests.TestCase): | ||
816 | 47 | |||
817 | 48 | def test_invalid_shelf_id(self): | ||
818 | 49 | invalid_id = "foo" | ||
819 | 50 | err = shelf.InvalidShelfId(invalid_id) | ||
820 | 51 | self.assertEqual('"foo" is not a valid shelf id, ' | ||
821 | 52 | 'try a number instead.', str(err)) | ||
822 | 53 | |||
823 | 54 | |||
824 | 46 | class TestPrepareShelf(tests.TestCaseWithTransport): | 55 | class TestPrepareShelf(tests.TestCaseWithTransport): |
825 | 47 | 56 | ||
826 | 48 | def prepare_shelve_rename(self): | 57 | def prepare_shelve_rename(self): |
827 | @@ -622,7 +631,7 @@ | |||
828 | 622 | 'foo'))]) | 631 | 'foo'))]) |
829 | 623 | shelf_file = open('shelf', 'rb') | 632 | shelf_file = open('shelf', 'rb') |
830 | 624 | self.addCleanup(shelf_file.close) | 633 | self.addCleanup(shelf_file.close) |
832 | 625 | e = self.assertRaises(errors.ShelfCorrupt, | 634 | e = self.assertRaises(shelf.ShelfCorrupt, |
833 | 626 | shelf.Unshelver.from_tree_and_shelf, tree, | 635 | shelf.Unshelver.from_tree_and_shelf, tree, |
834 | 627 | shelf_file) | 636 | shelf_file) |
835 | 628 | self.assertEqual('Shelf corrupt.', str(e)) | 637 | self.assertEqual('Shelf corrupt.', str(e)) |
836 | @@ -733,7 +742,7 @@ | |||
837 | 733 | 742 | ||
838 | 734 | def test_read_non_existant(self): | 743 | def test_read_non_existant(self): |
839 | 735 | manager = self.get_manager() | 744 | manager = self.get_manager() |
841 | 736 | e = self.assertRaises(errors.NoSuchShelfId, manager.read_shelf, 1) | 745 | e = self.assertRaises(shelf.NoSuchShelfId, manager.read_shelf, 1) |
842 | 737 | self.assertEqual('No changes are shelved with id "1".', str(e)) | 746 | self.assertEqual('No changes are shelved with id "1".', str(e)) |
843 | 738 | 747 | ||
844 | 739 | def test_shelve_changes(self): | 748 | def test_shelve_changes(self): |
845 | 740 | 749 | ||
846 | === modified file 'breezy/tests/test_shelf_ui.py' | |||
847 | --- breezy/tests/test_shelf_ui.py 2017-05-22 00:56:52 +0000 | |||
848 | +++ breezy/tests/test_shelf_ui.py 2017-07-23 16:06:20 +0000 | |||
849 | @@ -23,6 +23,7 @@ | |||
850 | 23 | errors, | 23 | errors, |
851 | 24 | shelf_ui, | 24 | shelf_ui, |
852 | 25 | revision, | 25 | revision, |
853 | 26 | shelf, | ||
854 | 26 | tests, | 27 | tests, |
855 | 27 | ) | 28 | ) |
856 | 28 | from ..sixish import ( | 29 | from ..sixish import ( |
857 | @@ -568,7 +569,7 @@ | |||
858 | 568 | shelf_file.write('garbage') | 569 | shelf_file.write('garbage') |
859 | 569 | finally: | 570 | finally: |
860 | 570 | shelf_file.close() | 571 | shelf_file.close() |
862 | 571 | self.assertRaises(errors.InvalidShelfId, | 572 | self.assertRaises(shelf.InvalidShelfId, |
863 | 572 | shelf_ui.Unshelver.from_args, directory='tree', | 573 | shelf_ui.Unshelver.from_args, directory='tree', |
864 | 573 | action='delete-only', shelf_id='foo') | 574 | action='delete-only', shelf_id='foo') |
865 | 574 | 575 | ||
866 | 575 | 576 | ||
867 | === modified file 'breezy/tests/test_smart_request.py' | |||
868 | --- breezy/tests/test_smart_request.py 2017-06-11 20:15:04 +0000 | |||
869 | +++ breezy/tests/test_smart_request.py 2017-07-23 16:06:20 +0000 | |||
870 | @@ -90,6 +90,14 @@ | |||
871 | 90 | self.jail_transports_log.append(request.jail_info.transports) | 90 | self.jail_transports_log.append(request.jail_info.transports) |
872 | 91 | 91 | ||
873 | 92 | 92 | ||
874 | 93 | class ErrorTests(TestCase): | ||
875 | 94 | |||
876 | 95 | def test_disabled_method(self): | ||
877 | 96 | error = request.DisabledMethod("class name") | ||
878 | 97 | self.assertEqualDiff( | ||
879 | 98 | "The smart server method 'class name' is disabled.", str(error)) | ||
880 | 99 | |||
881 | 100 | |||
882 | 93 | class TestSmartRequest(TestCase): | 101 | class TestSmartRequest(TestCase): |
883 | 94 | 102 | ||
884 | 95 | def test_request_class_without_do_body(self): | 103 | def test_request_class_without_do_body(self): |
885 | 96 | 104 | ||
886 | === modified file 'breezy/tests/test_smart_transport.py' | |||
887 | --- breezy/tests/test_smart_transport.py 2017-06-11 20:15:04 +0000 | |||
888 | +++ breezy/tests/test_smart_transport.py 2017-07-23 16:06:20 +0000 | |||
889 | @@ -1796,7 +1796,7 @@ | |||
890 | 1796 | # set environment variable after construction to make sure it's | 1796 | # set environment variable after construction to make sure it's |
891 | 1797 | # examined. | 1797 | # examined. |
892 | 1798 | self.overrideEnv('BRZ_NO_SMART_VFS', '') | 1798 | self.overrideEnv('BRZ_NO_SMART_VFS', '') |
894 | 1799 | self.assertRaises(errors.DisabledMethod, handler.execute) | 1799 | self.assertRaises(_mod_request.DisabledMethod, handler.execute) |
895 | 1800 | 1800 | ||
896 | 1801 | def test_readonly_exception_becomes_transport_not_possible(self): | 1801 | def test_readonly_exception_becomes_transport_not_possible(self): |
897 | 1802 | """The response for a read-only error is ('ReadOnlyError').""" | 1802 | """The response for a read-only error is ('ReadOnlyError').""" |
898 | 1803 | 1803 | ||
899 | === modified file 'breezy/tests/test_smtp_connection.py' | |||
900 | --- breezy/tests/test_smtp_connection.py 2017-05-21 18:10:28 +0000 | |||
901 | +++ breezy/tests/test_smtp_connection.py 2017-07-23 16:06:20 +0000 | |||
902 | @@ -22,7 +22,6 @@ | |||
903 | 22 | from breezy import ( | 22 | from breezy import ( |
904 | 23 | config, | 23 | config, |
905 | 24 | email_message, | 24 | email_message, |
906 | 25 | errors, | ||
907 | 26 | smtp_connection, | 25 | smtp_connection, |
908 | 27 | tests, | 26 | tests, |
909 | 28 | ui, | 27 | ui, |
910 | @@ -106,10 +105,11 @@ | |||
911 | 106 | 105 | ||
912 | 107 | def test_missing_server(self): | 106 | def test_missing_server(self): |
913 | 108 | conn = self.get_connection('', smtp_factory=connection_refuser) | 107 | conn = self.get_connection('', smtp_factory=connection_refuser) |
915 | 109 | self.assertRaises(errors.DefaultSMTPConnectionRefused, conn._connect) | 108 | self.assertRaises(smtp_connection.DefaultSMTPConnectionRefused, |
916 | 109 | conn._connect) | ||
917 | 110 | conn = self.get_connection('smtp_server=smtp.example.com', | 110 | conn = self.get_connection('smtp_server=smtp.example.com', |
918 | 111 | smtp_factory=connection_refuser) | 111 | smtp_factory=connection_refuser) |
920 | 112 | self.assertRaises(errors.SMTPConnectionRefused, conn._connect) | 112 | self.assertRaises(smtp_connection.SMTPConnectionRefused, conn._connect) |
921 | 113 | 113 | ||
922 | 114 | def test_smtp_username(self): | 114 | def test_smtp_username(self): |
923 | 115 | conn = self.get_connection('') | 115 | conn = self.get_connection('') |
924 | @@ -195,7 +195,7 @@ | |||
925 | 195 | # Check that we raise an exception if both EHLO and HELO fail. | 195 | # Check that we raise an exception if both EHLO and HELO fail. |
926 | 196 | factory = StubSMTPFactory(fail_on=['ehlo', 'helo']) | 196 | factory = StubSMTPFactory(fail_on=['ehlo', 'helo']) |
927 | 197 | conn = self.get_connection('', smtp_factory=factory) | 197 | conn = self.get_connection('', smtp_factory=factory) |
929 | 198 | self.assertRaises(errors.SMTPError, conn._create_connection) | 198 | self.assertRaises(smtp_connection.SMTPError, conn._create_connection) |
930 | 199 | self.assertEqual([('connect', 'localhost'), | 199 | self.assertEqual([('connect', 'localhost'), |
931 | 200 | ('ehlo',), | 200 | ('ehlo',), |
932 | 201 | ('helo',)], factory._calls) | 201 | ('helo',)], factory._calls) |
933 | @@ -218,7 +218,7 @@ | |||
934 | 218 | factory = StubSMTPFactory(fail_on=['starttls'], | 218 | factory = StubSMTPFactory(fail_on=['starttls'], |
935 | 219 | smtp_features=['starttls']) | 219 | smtp_features=['starttls']) |
936 | 220 | conn = self.get_connection('', smtp_factory=factory) | 220 | conn = self.get_connection('', smtp_factory=factory) |
938 | 221 | self.assertRaises(errors.SMTPError, conn._create_connection) | 221 | self.assertRaises(smtp_connection.SMTPError, conn._create_connection) |
939 | 222 | self.assertEqual([('connect', 'localhost'), | 222 | self.assertEqual([('connect', 'localhost'), |
940 | 223 | ('ehlo',), | 223 | ('ehlo',), |
941 | 224 | ('has_extn', 'starttls'), | 224 | ('has_extn', 'starttls'), |
942 | @@ -257,18 +257,18 @@ | |||
943 | 257 | msg = Message() | 257 | msg = Message() |
944 | 258 | msg['From'] = '"J. Random Developer" <jrandom@example.com>' | 258 | msg['From'] = '"J. Random Developer" <jrandom@example.com>' |
945 | 259 | self.assertRaises( | 259 | self.assertRaises( |
947 | 260 | errors.NoDestinationAddress, | 260 | smtp_connection.NoDestinationAddress, |
948 | 261 | smtp_connection.SMTPConnection(config.MemoryStack("") | 261 | smtp_connection.SMTPConnection(config.MemoryStack("") |
949 | 262 | ).send_email, msg) | 262 | ).send_email, msg) |
950 | 263 | 263 | ||
951 | 264 | msg = email_message.EmailMessage('from@from.com', '', 'subject') | 264 | msg = email_message.EmailMessage('from@from.com', '', 'subject') |
952 | 265 | self.assertRaises( | 265 | self.assertRaises( |
954 | 266 | errors.NoDestinationAddress, | 266 | smtp_connection.NoDestinationAddress, |
955 | 267 | smtp_connection.SMTPConnection(config.MemoryStack("") | 267 | smtp_connection.SMTPConnection(config.MemoryStack("") |
956 | 268 | ).send_email, msg) | 268 | ).send_email, msg) |
957 | 269 | 269 | ||
958 | 270 | msg = email_message.EmailMessage('from@from.com', [], 'subject') | 270 | msg = email_message.EmailMessage('from@from.com', [], 'subject') |
959 | 271 | self.assertRaises( | 271 | self.assertRaises( |
961 | 272 | errors.NoDestinationAddress, | 272 | smtp_connection.NoDestinationAddress, |
962 | 273 | smtp_connection.SMTPConnection(config.MemoryStack("") | 273 | smtp_connection.SMTPConnection(config.MemoryStack("") |
963 | 274 | ).send_email, msg) | 274 | ).send_email, msg) |
964 | 275 | 275 | ||
965 | === modified file 'breezy/tests/test_treebuilder.py' | |||
966 | --- breezy/tests/test_treebuilder.py 2017-05-21 18:10:28 +0000 | |||
967 | +++ breezy/tests/test_treebuilder.py 2017-07-23 16:06:20 +0000 | |||
968 | @@ -20,7 +20,11 @@ | |||
969 | 20 | from breezy import errors, tests | 20 | from breezy import errors, tests |
970 | 21 | from breezy.memorytree import MemoryTree | 21 | from breezy.memorytree import MemoryTree |
971 | 22 | from breezy.tests import TestCaseWithTransport | 22 | from breezy.tests import TestCaseWithTransport |
973 | 23 | from breezy.treebuilder import TreeBuilder | 23 | from breezy.treebuilder import ( |
974 | 24 | AlreadyBuilding, | ||
975 | 25 | NotBuilding, | ||
976 | 26 | TreeBuilder, | ||
977 | 27 | ) | ||
978 | 24 | 28 | ||
979 | 25 | 29 | ||
980 | 26 | class FakeTree(object): | 30 | class FakeTree(object): |
981 | @@ -63,11 +67,11 @@ | |||
982 | 63 | builder = TreeBuilder() | 67 | builder = TreeBuilder() |
983 | 64 | tree = FakeTree() | 68 | tree = FakeTree() |
984 | 65 | builder.start_tree(tree) | 69 | builder.start_tree(tree) |
986 | 66 | self.assertRaises(errors.AlreadyBuilding, builder.start_tree, tree) | 70 | self.assertRaises(AlreadyBuilding, builder.start_tree, tree) |
987 | 67 | 71 | ||
988 | 68 | def test_finish_tree_not_started_errors(self): | 72 | def test_finish_tree_not_started_errors(self): |
989 | 69 | builder = TreeBuilder() | 73 | builder = TreeBuilder() |
991 | 70 | self.assertRaises(errors.NotBuilding, builder.finish_tree) | 74 | self.assertRaises(NotBuilding, builder.finish_tree) |
992 | 71 | 75 | ||
993 | 72 | def test_finish_tree_unlocks(self): | 76 | def test_finish_tree_unlocks(self): |
994 | 73 | builder = TreeBuilder() | 77 | builder = TreeBuilder() |
995 | @@ -78,7 +82,7 @@ | |||
996 | 78 | 82 | ||
997 | 79 | def test_build_tree_not_started_errors(self): | 83 | def test_build_tree_not_started_errors(self): |
998 | 80 | builder = TreeBuilder() | 84 | builder = TreeBuilder() |
1000 | 81 | self.assertRaises(errors.NotBuilding, builder.build, "foo") | 85 | self.assertRaises(NotBuilding, builder.build, "foo") |
1001 | 82 | 86 | ||
1002 | 83 | def test_build_tree(self): | 87 | def test_build_tree(self): |
1003 | 84 | """Test building works using a MemoryTree.""" | 88 | """Test building works using a MemoryTree.""" |
1004 | 85 | 89 | ||
1005 | === added file 'breezy/tests/test_views.py' | |||
1006 | --- breezy/tests/test_views.py 1970-01-01 00:00:00 +0000 | |||
1007 | +++ breezy/tests/test_views.py 2017-07-23 16:06:20 +0000 | |||
1008 | @@ -0,0 +1,44 @@ | |||
1009 | 1 | # Copyright (C) 2005-2011 Canonical Ltd | ||
1010 | 2 | # | ||
1011 | 3 | # This program is free software; you can redistribute it and/or modify | ||
1012 | 4 | # it under the terms of the GNU General Public License as published by | ||
1013 | 5 | # the Free Software Foundation; either version 2 of the License, or | ||
1014 | 6 | # (at your option) any later version. | ||
1015 | 7 | # | ||
1016 | 8 | # This program is distributed in the hope that it will be useful, | ||
1017 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1018 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1019 | 11 | # GNU General Public License for more details. | ||
1020 | 12 | # | ||
1021 | 13 | # You should have received a copy of the GNU General Public License | ||
1022 | 14 | # along with this program; if not, write to the Free Software | ||
1023 | 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
1024 | 16 | |||
1025 | 17 | from __future__ import absolute_import | ||
1026 | 18 | |||
1027 | 19 | from . import TestCase | ||
1028 | 20 | |||
1029 | 21 | from ..views import ( | ||
1030 | 22 | FileOutsideView, | ||
1031 | 23 | NoSuchView, | ||
1032 | 24 | ViewsNotSupported, | ||
1033 | 25 | ) | ||
1034 | 26 | |||
1035 | 27 | |||
1036 | 28 | class TestErrors(TestCase): | ||
1037 | 29 | |||
1038 | 30 | def test_no_such_view(self): | ||
1039 | 31 | err = NoSuchView('foo') | ||
1040 | 32 | self.assertEqual("No such view: foo.", str(err)) | ||
1041 | 33 | |||
1042 | 34 | def test_views_not_supported(self): | ||
1043 | 35 | err = ViewsNotSupported('atree') | ||
1044 | 36 | err_str = str(err) | ||
1045 | 37 | self.assertStartsWith(err_str, "Views are not supported by ") | ||
1046 | 38 | self.assertEndsWith(err_str, "; use 'brz upgrade' to change your " | ||
1047 | 39 | "tree to a later format.") | ||
1048 | 40 | |||
1049 | 41 | def test_file_outside_view(self): | ||
1050 | 42 | err = FileOutsideView('baz', ['foo', 'bar']) | ||
1051 | 43 | self.assertEqual('Specified file "baz" is outside the current view: ' | ||
1052 | 44 | 'foo, bar', str(err)) | ||
1053 | 0 | 45 | ||
1054 | === modified file 'breezy/treebuilder.py' | |||
1055 | --- breezy/treebuilder.py 2017-05-22 00:56:52 +0000 | |||
1056 | +++ breezy/treebuilder.py 2017-07-23 16:06:20 +0000 | |||
1057 | @@ -25,6 +25,16 @@ | |||
1058 | 25 | from . import errors | 25 | from . import errors |
1059 | 26 | 26 | ||
1060 | 27 | 27 | ||
1061 | 28 | class AlreadyBuilding(errors.BzrError): | ||
1062 | 29 | |||
1063 | 30 | _fmt = "The tree builder is already building a tree." | ||
1064 | 31 | |||
1065 | 32 | |||
1066 | 33 | class NotBuilding(errors.BzrError): | ||
1067 | 34 | |||
1068 | 35 | _fmt = "Not currently building a tree." | ||
1069 | 36 | |||
1070 | 37 | |||
1071 | 28 | class TreeBuilder(object): | 38 | class TreeBuilder(object): |
1072 | 29 | """A TreeBuilder allows the creation of specific content in one tree at a | 39 | """A TreeBuilder allows the creation of specific content in one tree at a |
1073 | 30 | time. | 40 | time. |
1074 | @@ -59,7 +69,7 @@ | |||
1075 | 59 | def _ensure_building(self): | 69 | def _ensure_building(self): |
1076 | 60 | """Raise NotBuilding if there is no current tree being built.""" | 70 | """Raise NotBuilding if there is no current tree being built.""" |
1077 | 61 | if self._tree is None: | 71 | if self._tree is None: |
1079 | 62 | raise errors.NotBuilding | 72 | raise NotBuilding |
1080 | 63 | 73 | ||
1081 | 64 | def finish_tree(self): | 74 | def finish_tree(self): |
1082 | 65 | """Finish building the current tree.""" | 75 | """Finish building the current tree.""" |
1083 | @@ -75,6 +85,6 @@ | |||
1084 | 75 | MutableTree interface. | 85 | MutableTree interface. |
1085 | 76 | """ | 86 | """ |
1086 | 77 | if self._tree is not None: | 87 | if self._tree is not None: |
1088 | 78 | raise errors.AlreadyBuilding | 88 | raise AlreadyBuilding |
1089 | 79 | self._tree = tree | 89 | self._tree = tree |
1090 | 80 | self._tree.lock_tree_write() | 90 | self._tree.lock_tree_write() |
1091 | 81 | 91 | ||
1092 | === modified file 'breezy/views.py' | |||
1093 | --- breezy/views.py 2017-05-22 00:56:52 +0000 | |||
1094 | +++ breezy/views.py 2017-07-23 16:06:20 +0000 | |||
1095 | @@ -36,6 +36,37 @@ | |||
1096 | 36 | _VIEWS_FORMAT1_MARKER = "Bazaar views format 1\n" | 36 | _VIEWS_FORMAT1_MARKER = "Bazaar views format 1\n" |
1097 | 37 | 37 | ||
1098 | 38 | 38 | ||
1099 | 39 | class NoSuchView(errors.BzrError): | ||
1100 | 40 | """A view does not exist. | ||
1101 | 41 | """ | ||
1102 | 42 | |||
1103 | 43 | _fmt = u"No such view: %(view_name)s." | ||
1104 | 44 | |||
1105 | 45 | def __init__(self, view_name): | ||
1106 | 46 | self.view_name = view_name | ||
1107 | 47 | |||
1108 | 48 | |||
1109 | 49 | class ViewsNotSupported(errors.BzrError): | ||
1110 | 50 | """Views are not supported by a tree format. | ||
1111 | 51 | """ | ||
1112 | 52 | |||
1113 | 53 | _fmt = ("Views are not supported by %(tree)s;" | ||
1114 | 54 | " use 'brz upgrade' to change your tree to a later format.") | ||
1115 | 55 | |||
1116 | 56 | def __init__(self, tree): | ||
1117 | 57 | self.tree = tree | ||
1118 | 58 | |||
1119 | 59 | |||
1120 | 60 | class FileOutsideView(errors.BzrError): | ||
1121 | 61 | |||
1122 | 62 | _fmt = ('Specified file "%(file_name)s" is outside the current view: ' | ||
1123 | 63 | '%(view_str)s') | ||
1124 | 64 | |||
1125 | 65 | def __init__(self, file_name, view_files): | ||
1126 | 66 | self.file_name = file_name | ||
1127 | 67 | self.view_str = ", ".join(view_files) | ||
1128 | 68 | |||
1129 | 69 | |||
1130 | 39 | class _Views(object): | 70 | class _Views(object): |
1131 | 40 | """Base class for View managers.""" | 71 | """Base class for View managers.""" |
1132 | 41 | 72 | ||
1133 | @@ -95,7 +126,7 @@ | |||
1134 | 95 | :param views: a map from view name to list of files/directories | 126 | :param views: a map from view name to list of files/directories |
1135 | 96 | """ | 127 | """ |
1136 | 97 | if current is not None and current not in views: | 128 | if current is not None and current not in views: |
1138 | 98 | raise errors.NoSuchView(current) | 129 | raise NoSuchView(current) |
1139 | 99 | self.tree.lock_write() | 130 | self.tree.lock_write() |
1140 | 100 | try: | 131 | try: |
1141 | 101 | self._current = current | 132 | self._current = current |
1142 | @@ -119,7 +150,7 @@ | |||
1143 | 119 | return [] | 150 | return [] |
1144 | 120 | return self._views[view_name] | 151 | return self._views[view_name] |
1145 | 121 | except KeyError: | 152 | except KeyError: |
1147 | 122 | raise errors.NoSuchView(view_name) | 153 | raise NoSuchView(view_name) |
1148 | 123 | 154 | ||
1149 | 124 | def set_view(self, view_name, view_files, make_current=True): | 155 | def set_view(self, view_name, view_files, make_current=True): |
1150 | 125 | """Add or update a view definition. | 156 | """Add or update a view definition. |
1151 | @@ -149,7 +180,7 @@ | |||
1152 | 149 | try: | 180 | try: |
1153 | 150 | del self._views[view_name] | 181 | del self._views[view_name] |
1154 | 151 | except KeyError: | 182 | except KeyError: |
1156 | 152 | raise errors.NoSuchView(view_name) | 183 | raise NoSuchView(view_name) |
1157 | 153 | if view_name == self._current: | 184 | if view_name == self._current: |
1158 | 154 | self._current = None | 185 | self._current = None |
1159 | 155 | self._save_view_info() | 186 | self._save_view_info() |
1160 | @@ -256,7 +287,7 @@ | |||
1161 | 256 | return False | 287 | return False |
1162 | 257 | 288 | ||
1163 | 258 | def _not_supported(self, *a, **k): | 289 | def _not_supported(self, *a, **k): |
1165 | 259 | raise errors.ViewsNotSupported(self.tree) | 290 | raise ViewsNotSupported(self.tree) |
1166 | 260 | 291 | ||
1167 | 261 | get_view_info = _not_supported | 292 | get_view_info = _not_supported |
1168 | 262 | set_view_info = _not_supported | 293 | set_view_info = _not_supported |
1169 | @@ -282,4 +313,4 @@ | |||
1170 | 282 | if tree.supports_views(): | 313 | if tree.supports_views(): |
1171 | 283 | view_files = tree.views.lookup_view() | 314 | view_files = tree.views.lookup_view() |
1172 | 284 | if view_files and not osutils.is_inside_any(view_files, relpath): | 315 | if view_files and not osutils.is_inside_any(view_files, relpath): |
1174 | 285 | raise errors.FileOutsideView(relpath, view_files) | 316 | raise FileOutsideView(relpath, view_files) |
1175 | 286 | 317 | ||
1176 | === modified file 'breezy/workingtree.py' | |||
1177 | --- breezy/workingtree.py 2017-07-02 21:26:29 +0000 | |||
1178 | +++ breezy/workingtree.py 2017-07-23 16:06:20 +0000 | |||
1179 | @@ -327,7 +327,7 @@ | |||
1180 | 327 | for filename in file_list: | 327 | for filename in file_list: |
1181 | 328 | relpath = fixer(osutils.dereference_path(filename)) | 328 | relpath = fixer(osutils.dereference_path(filename)) |
1182 | 329 | if view_files and not osutils.is_inside_any(view_files, relpath): | 329 | if view_files and not osutils.is_inside_any(view_files, relpath): |
1184 | 330 | raise errors.FileOutsideView(filename, view_files) | 330 | raise views.FileOutsideView(filename, view_files) |
1185 | 331 | new_list.append(relpath) | 331 | new_list.append(relpath) |
1186 | 332 | return new_list | 332 | return new_list |
1187 | 333 | 333 |
Changes look okay.