Merge lp:~jelmer/brz/move-errors-more into lp:brz
- move-errors-more
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Approved by: | Jelmer Vernooij |
Approved revision: | no longer in the source branch. |
Merged at revision: | 6743 |
Proposed branch: | lp:~jelmer/brz/move-errors-more |
Merge into: | lp:brz |
Diff against target: |
3085 lines (+606/-594) 46 files modified
breezy/branch.py (+13/-2) breezy/builtins.py (+2/-2) breezy/bzr/_dirstate_helpers_py.py (+3/-4) breezy/bzr/_dirstate_helpers_pyx.pyx (+6/-6) breezy/bzr/branch.py (+4/-3) breezy/bzr/bzrdir.py (+11/-2) breezy/bzr/dirstate.py (+11/-1) breezy/bzr/groupcompress.py (+16/-2) breezy/bzr/index.py (+82/-27) breezy/bzr/remote.py (+2/-2) breezy/bzr/smart/request.py (+2/-1) breezy/commit.py (+25/-1) breezy/controldir.py (+12/-2) breezy/directory_service.py (+22/-2) breezy/errors.py (+0/-286) breezy/hooks.py (+14/-4) breezy/info.py (+2/-1) breezy/msgeditor.py (+7/-1) breezy/osutils.py (+14/-3) breezy/plugins/weave_fmt/bzrdir.py (+7/-3) breezy/push.py (+2/-1) breezy/reconfigure.py (+90/-17) breezy/rules.py (+8/-0) breezy/tests/blackbox/test_push.py (+1/-1) breezy/tests/per_branch/test_create_clone.py (+2/-2) breezy/tests/per_branch/test_sprout.py (+1/-1) breezy/tests/per_branch/test_stacking.py (+6/-6) breezy/tests/per_controldir/test_controldir.py (+3/-2) breezy/tests/per_foreign_vcs/test_branch.py (+3/-2) breezy/tests/per_workingtree/test_commit.py (+11/-6) breezy/tests/test__dirstate_helpers.py (+1/-2) breezy/tests/test_branch.py (+14/-2) breezy/tests/test_bzrdir.py (+3/-3) breezy/tests/test_commit.py (+3/-2) breezy/tests/test_controldir.py (+8/-0) breezy/tests/test_directory_service.py (+4/-3) breezy/tests/test_dirstate.py (+10/-0) breezy/tests/test_errors.py (+0/-42) breezy/tests/test_hooks.py (+16/-3) breezy/tests/test_index.py (+118/-118) breezy/tests/test_msgeditor.py (+1/-1) breezy/tests/test_osutils.py (+1/-1) breezy/tests/test_reconfigure.py (+16/-16) breezy/tests/test_rules.py (+9/-3) breezy/tests/test_version_info.py (+7/-5) breezy/version_info_formats/format_custom.py (+13/-0) |
To merge this branch: | bzr merge lp:~jelmer/brz/move-errors-more |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Packman | Approve | ||
Review via email: mp+327942@code.launchpad.net |
Commit message
Move more errors out of breezy.errors.
Description of the change
Move more errors out of breezy.errors.
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/branch.py' |
2 | --- breezy/branch.py 2017-07-15 13:23:08 +0000 |
3 | +++ breezy/branch.py 2017-07-24 01:10:54 +0000 |
4 | @@ -59,6 +59,17 @@ |
5 | from .trace import mutter, mutter_callsite, note, is_quiet |
6 | |
7 | |
8 | +class UnstackableBranchFormat(errors.BzrError): |
9 | + |
10 | + _fmt = ("The branch '%(url)s'(%(format)s) is not a stackable format. " |
11 | + "You will need to upgrade the branch to permit branch stacking.") |
12 | + |
13 | + def __init__(self, format, url): |
14 | + errors.BzrError.__init__(self) |
15 | + self.format = format |
16 | + self.url = url |
17 | + |
18 | + |
19 | class Branch(controldir.ControlComponent): |
20 | """Branch holding a history of revisions. |
21 | |
22 | @@ -816,7 +827,7 @@ |
23 | stacking. |
24 | """ |
25 | if not self._format.supports_stacking(): |
26 | - raise errors.UnstackableBranchFormat(self._format, self.user_url) |
27 | + raise UnstackableBranchFormat(self._format, self.user_url) |
28 | # XXX: Changing from one fallback repository to another does not check |
29 | # that all the data you need is present in the new fallback. |
30 | # Possibly it should. |
31 | @@ -824,7 +835,7 @@ |
32 | if not url: |
33 | try: |
34 | old_url = self.get_stacked_on_url() |
35 | - except (errors.NotStacked, errors.UnstackableBranchFormat, |
36 | + except (errors.NotStacked, UnstackableBranchFormat, |
37 | errors.UnstackableRepositoryFormat): |
38 | return |
39 | self._unstack() |
40 | |
41 | === modified file 'breezy/builtins.py' |
42 | --- breezy/builtins.py 2017-07-24 01:07:36 +0000 |
43 | +++ breezy/builtins.py 2017-07-24 01:10:54 +0000 |
44 | @@ -60,7 +60,7 @@ |
45 | from breezy.bzr import ( |
46 | btree_index, |
47 | ) |
48 | -from breezy.branch import Branch |
49 | +from breezy.branch import Branch, UnstackableBranchFormat |
50 | from breezy.conflicts import ConflictList |
51 | from breezy.transport import memory |
52 | from breezy.revisionspec import RevisionSpec, RevisionInfo |
53 | @@ -1524,7 +1524,7 @@ |
54 | try: |
55 | note(gettext('Created new stacked branch referring to %s.') % |
56 | branch.get_stacked_on_url()) |
57 | - except (errors.NotStacked, errors.UnstackableBranchFormat, |
58 | + except (errors.NotStacked, UnstackableBranchFormat, |
59 | errors.UnstackableRepositoryFormat) as e: |
60 | note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno()) |
61 | if bind: |
62 | |
63 | === modified file 'breezy/bzr/_dirstate_helpers_py.py' |
64 | --- breezy/bzr/_dirstate_helpers_py.py 2017-06-11 13:48:12 +0000 |
65 | +++ breezy/bzr/_dirstate_helpers_py.py 2017-07-24 01:10:54 +0000 |
66 | @@ -24,8 +24,7 @@ |
67 | |
68 | # We cannot import the dirstate module, because it loads this module |
69 | # All we really need is the IN_MEMORY_MODIFIED constant |
70 | -from breezy import errors |
71 | -from .dirstate import DirState |
72 | +from .dirstate import DirState, DirstateCorrupt |
73 | from ..sixish import ( |
74 | range, |
75 | ) |
76 | @@ -229,7 +228,7 @@ |
77 | # Remove the last blank entry |
78 | trailing = fields.pop() |
79 | if trailing != b'': |
80 | - raise errors.DirstateCorrupt(state, |
81 | + raise DirstateCorrupt(state, |
82 | 'trailing garbage: %r' % (trailing,)) |
83 | # consider turning fields into a tuple. |
84 | |
85 | @@ -248,7 +247,7 @@ |
86 | field_count = len(fields) |
87 | # this checks our adjustment, and also catches file too short. |
88 | if field_count - cur != expected_field_count: |
89 | - raise errors.DirstateCorrupt(state, |
90 | + raise DirstateCorrupt(state, |
91 | 'field count incorrect %s != %s, entry_size=%s, '\ |
92 | 'num_entries=%s fields=%r' % ( |
93 | field_count - cur, expected_field_count, entry_size, |
94 | |
95 | === modified file 'breezy/bzr/_dirstate_helpers_pyx.pyx' |
96 | --- breezy/bzr/_dirstate_helpers_pyx.pyx 2017-06-10 21:59:15 +0000 |
97 | +++ breezy/bzr/_dirstate_helpers_pyx.pyx 2017-07-24 01:10:54 +0000 |
98 | @@ -28,8 +28,8 @@ |
99 | import stat |
100 | import sys |
101 | |
102 | -from .. import cache_utf8, errors, osutils |
103 | -from .dirstate import DirState |
104 | +from .. import cache_utf8, osutils |
105 | +from .dirstate import DirState, DirstateCorrupt |
106 | from ..osutils import parent_directories, pathjoin, splitpath |
107 | |
108 | |
109 | @@ -561,7 +561,7 @@ |
110 | self.cur_cstr = <char*>memchr(next, c'\0', self.end_cstr - next) |
111 | if self.cur_cstr == NULL: |
112 | extra_len = self.end_cstr - next |
113 | - raise errors.DirstateCorrupt(self.state, |
114 | + raise DirstateCorrupt(self.state, |
115 | 'failed to find trailing NULL (\\0).' |
116 | ' Trailing garbage: %r' |
117 | % safe_string_from_size(next, extra_len)) |
118 | @@ -720,7 +720,7 @@ |
119 | # marker. |
120 | trailing = self.get_next(&cur_size) |
121 | if cur_size != 1 or trailing[0] != c'\n': |
122 | - raise errors.DirstateCorrupt(self.state, |
123 | + raise DirstateCorrupt(self.state, |
124 | 'Bad parse, we expected to end on \\n, not: %d %s: %s' |
125 | % (cur_size, safe_string_from_size(trailing, cur_size), |
126 | ret)) |
127 | @@ -767,7 +767,7 @@ |
128 | PyList_Append(current_block, entry) |
129 | entry_count = entry_count + 1 |
130 | if entry_count != expected_entry_count: |
131 | - raise errors.DirstateCorrupt(self.state, |
132 | + raise DirstateCorrupt(self.state, |
133 | 'We read the wrong number of entries.' |
134 | ' We expected to read %s, but read %s' |
135 | % (expected_entry_count, entry_count)) |
136 | @@ -1326,7 +1326,7 @@ |
137 | parent_entry = self.state._get_entry(self.target_index, |
138 | path_utf8=entry[0][0]) |
139 | if parent_entry is None: |
140 | - raise errors.DirstateCorrupt(self.state, |
141 | + raise DirstateCorrupt(self.state, |
142 | "We could not find the parent entry in index %d" |
143 | " for the entry: %s" |
144 | % (self.target_index, entry[0])) |
145 | |
146 | === modified file 'breezy/bzr/branch.py' |
147 | --- breezy/bzr/branch.py 2017-06-14 23:29:06 +0000 |
148 | +++ breezy/bzr/branch.py 2017-07-24 01:10:54 +0000 |
149 | @@ -42,6 +42,7 @@ |
150 | BranchFormat, |
151 | BranchWriteLockResult, |
152 | format_registry, |
153 | + UnstackableBranchFormat, |
154 | ) |
155 | from ..decorators import ( |
156 | needs_read_lock, |
157 | @@ -260,7 +261,7 @@ |
158 | return None |
159 | |
160 | def get_stacked_on_url(self): |
161 | - raise errors.UnstackableBranchFormat(self._format, self.user_url) |
162 | + raise UnstackableBranchFormat(self._format, self.user_url) |
163 | |
164 | def set_push_location(self, location): |
165 | """See Branch.set_push_location.""" |
166 | @@ -409,7 +410,7 @@ |
167 | try: |
168 | url = self.get_stacked_on_url() |
169 | except (errors.UnstackableRepositoryFormat, errors.NotStacked, |
170 | - errors.UnstackableBranchFormat): |
171 | + UnstackableBranchFormat): |
172 | pass |
173 | else: |
174 | for hook in Branch.hooks['transform_fallback_location']: |
175 | @@ -650,7 +651,7 @@ |
176 | """ |
177 | |
178 | def get_stacked_on_url(self): |
179 | - raise errors.UnstackableBranchFormat(self._format, self.user_url) |
180 | + raise UnstackableBranchFormat(self._format, self.user_url) |
181 | |
182 | |
183 | class BranchFormatMetadir(bzrdir.BzrFormat, BranchFormat): |
184 | |
185 | === modified file 'breezy/bzr/bzrdir.py' |
186 | --- breezy/bzr/bzrdir.py 2017-07-21 14:18:24 +0000 |
187 | +++ breezy/bzr/bzrdir.py 2017-07-24 01:10:54 +0000 |
188 | @@ -33,6 +33,7 @@ |
189 | lazy_import(globals(), """ |
190 | import breezy |
191 | from breezy import ( |
192 | + branch as _mod_branch, |
193 | cleanup, |
194 | fetch, |
195 | graph, |
196 | @@ -85,6 +86,14 @@ |
197 | self.feature = feature |
198 | |
199 | |
200 | +class FeatureAlreadyRegistered(errors.BzrError): |
201 | + |
202 | + _fmt = 'The feature %(feature)s has already been registered.' |
203 | + |
204 | + def __init__(self, feature): |
205 | + self.feature = feature |
206 | + |
207 | + |
208 | class BzrDir(controldir.ControlDir): |
209 | """A .bzr control diretory. |
210 | |
211 | @@ -177,7 +186,7 @@ |
212 | if preserve_stacking: |
213 | try: |
214 | stacked_on = local_branch.get_stacked_on_url() |
215 | - except (errors.UnstackableBranchFormat, |
216 | + except (_mod_branch.UnstackableBranchFormat, |
217 | errors.UnstackableRepositoryFormat, |
218 | errors.NotStacked): |
219 | pass |
220 | @@ -1856,7 +1865,7 @@ |
221 | stack_on = self._get_full_stack_on() |
222 | try: |
223 | branch.set_stacked_on_url(stack_on) |
224 | - except (errors.UnstackableBranchFormat, |
225 | + except (_mod_branch.UnstackableBranchFormat, |
226 | errors.UnstackableRepositoryFormat): |
227 | if self._require_stacking: |
228 | raise |
229 | |
230 | === modified file 'breezy/bzr/dirstate.py' |
231 | --- breezy/bzr/dirstate.py 2017-06-14 23:29:06 +0000 |
232 | +++ breezy/bzr/dirstate.py 2017-07-24 01:10:54 +0000 |
233 | @@ -258,6 +258,16 @@ |
234 | ERROR_DIRECTORY = 267 |
235 | |
236 | |
237 | +class DirstateCorrupt(errors.BzrError): |
238 | + |
239 | + _fmt = "The dirstate file (%(state)s) appears to be corrupt: %(msg)s" |
240 | + |
241 | + def __init__(self, state, msg): |
242 | + errors.BzrError.__init__(self) |
243 | + self.state = state |
244 | + self.msg = msg |
245 | + |
246 | + |
247 | class SHA1Provider(object): |
248 | """An interface for getting sha1s of a file.""" |
249 | |
250 | @@ -3583,7 +3593,7 @@ |
251 | # update the source details variable to be the real |
252 | # location. |
253 | if old_entry == (None, None): |
254 | - raise errors.CorruptDirstate(self.state._filename, |
255 | + raise DirstateCorrupt(self.state._filename, |
256 | "entry '%s/%s' is considered renamed from %r" |
257 | " but source does not exist\n" |
258 | "entry: %s" % (entry[0][0], entry[0][1], old_path, entry)) |
259 | |
260 | === modified file 'breezy/bzr/groupcompress.py' |
261 | --- breezy/bzr/groupcompress.py 2017-06-11 13:48:12 +0000 |
262 | +++ breezy/bzr/groupcompress.py 2017-07-24 01:10:54 +0000 |
263 | @@ -27,7 +27,6 @@ |
264 | annotate, |
265 | config, |
266 | debug, |
267 | - errors, |
268 | graph as _mod_graph, |
269 | osutils, |
270 | static_tuple, |
271 | @@ -42,6 +41,9 @@ |
272 | from breezy.i18n import gettext |
273 | """) |
274 | |
275 | +from .. import ( |
276 | + errors, |
277 | + ) |
278 | from .btree_index import BTreeBuilder |
279 | from ..lru_cache import LRUSizeCache |
280 | from ..sixish import ( |
281 | @@ -92,6 +94,18 @@ |
282 | return present_keys |
283 | |
284 | |
285 | +class DecompressCorruption(errors.BzrError): |
286 | + |
287 | + _fmt = "Corruption while decompressing repository file%(orig_error)s" |
288 | + |
289 | + def __init__(self, orig_error=None): |
290 | + if orig_error is not None: |
291 | + self.orig_error = ", %s" % (orig_error,) |
292 | + else: |
293 | + self.orig_error = "" |
294 | + errors.BzrError.__init__(self) |
295 | + |
296 | + |
297 | # The max zlib window size is 32kB, so if we set 'max_size' output of the |
298 | # decompressor to the requested bytes + 32kB, then we should guarantee |
299 | # num_bytes coming out. |
300 | @@ -457,7 +471,7 @@ |
301 | try: |
302 | self._manager._prepare_for_extract() |
303 | except zlib.error as value: |
304 | - raise errors.DecompressCorruption("zlib: " + str(value)) |
305 | + raise DecompressCorruption("zlib: " + str(value)) |
306 | block = self._manager._block |
307 | self._bytes = block.extract(self.key, self._start, self._end) |
308 | # There are code paths that first extract as fulltext, and then |
309 | |
310 | === modified file 'breezy/bzr/index.py' |
311 | --- breezy/bzr/index.py 2017-06-11 13:48:12 +0000 |
312 | +++ breezy/bzr/index.py 2017-07-24 01:10:54 +0000 |
313 | @@ -28,7 +28,6 @@ |
314 | |
315 | from bisect import bisect_right |
316 | import re |
317 | -import sys |
318 | |
319 | from ..lazy_import import lazy_import |
320 | lazy_import(globals(), """ |
321 | @@ -56,6 +55,62 @@ |
322 | _SIGNATURE = b"Bazaar Graph Index 1\n" |
323 | |
324 | |
325 | +class BadIndexFormatSignature(errors.BzrError): |
326 | + |
327 | + _fmt = "%(value)s is not an index of type %(_type)s." |
328 | + |
329 | + def __init__(self, value, _type): |
330 | + errors.BzrError.__init__(self) |
331 | + self.value = value |
332 | + self._type = _type |
333 | + |
334 | + |
335 | +class BadIndexData(errors.BzrError): |
336 | + |
337 | + _fmt = "Error in data for index %(value)s." |
338 | + |
339 | + def __init__(self, value): |
340 | + errors.BzrError.__init__(self) |
341 | + self.value = value |
342 | + |
343 | + |
344 | +class BadIndexDuplicateKey(errors.BzrError): |
345 | + |
346 | + _fmt = "The key '%(key)s' is already in index '%(index)s'." |
347 | + |
348 | + def __init__(self, key, index): |
349 | + errors.BzrError.__init__(self) |
350 | + self.key = key |
351 | + self.index = index |
352 | + |
353 | + |
354 | +class BadIndexKey(errors.BzrError): |
355 | + |
356 | + _fmt = "The key '%(key)s' is not a valid key." |
357 | + |
358 | + def __init__(self, key): |
359 | + errors.BzrError.__init__(self) |
360 | + self.key = key |
361 | + |
362 | + |
363 | +class BadIndexOptions(errors.BzrError): |
364 | + |
365 | + _fmt = "Could not parse options for index %(value)s." |
366 | + |
367 | + def __init__(self, value): |
368 | + errors.BzrError.__init__(self) |
369 | + self.value = value |
370 | + |
371 | + |
372 | +class BadIndexValue(errors.BzrError): |
373 | + |
374 | + _fmt = "The value '%(value)s' is not a valid value." |
375 | + |
376 | + def __init__(self, value): |
377 | + errors.BzrError.__init__(self) |
378 | + self.value = value |
379 | + |
380 | + |
381 | _whitespace_re = re.compile(b'[\t\n\x0b\x0c\r\x00 ]') |
382 | _newline_null_re = re.compile(b'[\n\0]') |
383 | |
384 | @@ -112,12 +167,12 @@ |
385 | def _check_key(self, key): |
386 | """Raise BadIndexKey if key is not a valid key for this index.""" |
387 | if type(key) not in (tuple, StaticTuple): |
388 | - raise errors.BadIndexKey(key) |
389 | + raise BadIndexKey(key) |
390 | if self._key_length != len(key): |
391 | - raise errors.BadIndexKey(key) |
392 | + raise BadIndexKey(key) |
393 | for element in key: |
394 | if not element or _whitespace_re.search(element) is not None: |
395 | - raise errors.BadIndexKey(element) |
396 | + raise BadIndexKey(element) |
397 | |
398 | def _external_references(self): |
399 | """Return references that are not present in this index. |
400 | @@ -201,9 +256,9 @@ |
401 | as_st = StaticTuple.from_sequence |
402 | self._check_key(key) |
403 | if _newline_null_re.search(value) is not None: |
404 | - raise errors.BadIndexValue(value) |
405 | + raise BadIndexValue(value) |
406 | if len(references) != self.reference_lists: |
407 | - raise errors.BadIndexValue(references) |
408 | + raise BadIndexValue(references) |
409 | node_refs = [] |
410 | absent_references = [] |
411 | for reference_list in references: |
412 | @@ -232,7 +287,7 @@ |
413 | (node_refs, |
414 | absent_references) = self._check_key_ref_value(key, references, value) |
415 | if key in self._nodes and self._nodes[key][0] != 'a': |
416 | - raise errors.BadIndexDuplicateKey(key, self) |
417 | + raise BadIndexDuplicateKey(key, self) |
418 | for reference in absent_references: |
419 | # There may be duplicates, but I don't think it is worth worrying |
420 | # about |
421 | @@ -492,7 +547,7 @@ |
422 | # cache the keys for quick set intersections |
423 | if trailers != 1: |
424 | # there must be one line - the empty trailer line. |
425 | - raise errors.BadIndexData(self) |
426 | + raise BadIndexData(self) |
427 | |
428 | def clear_cache(self): |
429 | """Clear out any cached/memoized values. |
430 | @@ -558,28 +613,28 @@ |
431 | def _read_prefix(self, stream): |
432 | signature = stream.read(len(self._signature())) |
433 | if not signature == self._signature(): |
434 | - raise errors.BadIndexFormatSignature(self._name, GraphIndex) |
435 | + raise BadIndexFormatSignature(self._name, GraphIndex) |
436 | options_line = stream.readline() |
437 | if not options_line.startswith(_OPTION_NODE_REFS): |
438 | - raise errors.BadIndexOptions(self) |
439 | + raise BadIndexOptions(self) |
440 | try: |
441 | self.node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):-1]) |
442 | except ValueError: |
443 | - raise errors.BadIndexOptions(self) |
444 | + raise BadIndexOptions(self) |
445 | options_line = stream.readline() |
446 | if not options_line.startswith(_OPTION_KEY_ELEMENTS): |
447 | - raise errors.BadIndexOptions(self) |
448 | + raise BadIndexOptions(self) |
449 | try: |
450 | self._key_length = int(options_line[len(_OPTION_KEY_ELEMENTS):-1]) |
451 | except ValueError: |
452 | - raise errors.BadIndexOptions(self) |
453 | + raise BadIndexOptions(self) |
454 | options_line = stream.readline() |
455 | if not options_line.startswith(_OPTION_LEN): |
456 | - raise errors.BadIndexOptions(self) |
457 | + raise BadIndexOptions(self) |
458 | try: |
459 | self._key_count = int(options_line[len(_OPTION_LEN):-1]) |
460 | except ValueError: |
461 | - raise errors.BadIndexOptions(self) |
462 | + raise BadIndexOptions(self) |
463 | |
464 | def _resolve_references(self, references): |
465 | """Return the resolved key references for references. |
466 | @@ -906,29 +961,29 @@ |
467 | """ |
468 | signature = bytes[0:len(self._signature())] |
469 | if not signature == self._signature(): |
470 | - raise errors.BadIndexFormatSignature(self._name, GraphIndex) |
471 | + raise BadIndexFormatSignature(self._name, GraphIndex) |
472 | lines = bytes[len(self._signature()):].splitlines() |
473 | options_line = lines[0] |
474 | if not options_line.startswith(_OPTION_NODE_REFS): |
475 | - raise errors.BadIndexOptions(self) |
476 | + raise BadIndexOptions(self) |
477 | try: |
478 | self.node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):]) |
479 | except ValueError: |
480 | - raise errors.BadIndexOptions(self) |
481 | + raise BadIndexOptions(self) |
482 | options_line = lines[1] |
483 | if not options_line.startswith(_OPTION_KEY_ELEMENTS): |
484 | - raise errors.BadIndexOptions(self) |
485 | + raise BadIndexOptions(self) |
486 | try: |
487 | self._key_length = int(options_line[len(_OPTION_KEY_ELEMENTS):]) |
488 | except ValueError: |
489 | - raise errors.BadIndexOptions(self) |
490 | + raise BadIndexOptions(self) |
491 | options_line = lines[2] |
492 | if not options_line.startswith(_OPTION_LEN): |
493 | - raise errors.BadIndexOptions(self) |
494 | + raise BadIndexOptions(self) |
495 | try: |
496 | self._key_count = int(options_line[len(_OPTION_LEN):]) |
497 | except ValueError: |
498 | - raise errors.BadIndexOptions(self) |
499 | + raise BadIndexOptions(self) |
500 | # calculate the bytes we have processed |
501 | header_end = (len(signature) + len(lines[0]) + len(lines[1]) + |
502 | len(lines[2]) + 3) |
503 | @@ -1087,7 +1142,7 @@ |
504 | continue |
505 | elements = line.split('\0') |
506 | if len(elements) != self._expected_elements: |
507 | - raise errors.BadIndexData(self) |
508 | + raise BadIndexData(self) |
509 | # keys are tuples. Each element is a string that may occur many |
510 | # times, so we intern them to save space. AB, RC, 200807 |
511 | key = tuple([intern(element) for element in elements[:self._key_length]]) |
512 | @@ -1739,11 +1794,11 @@ |
513 | for node in an_iter: |
514 | # cross checks |
515 | if node[1][:self.prefix_len] != self.prefix: |
516 | - raise errors.BadIndexData(self) |
517 | + raise BadIndexData(self) |
518 | for ref_list in node[3]: |
519 | for ref_node in ref_list: |
520 | if ref_node[:self.prefix_len] != self.prefix: |
521 | - raise errors.BadIndexData(self) |
522 | + raise BadIndexData(self) |
523 | yield node[0], node[1][self.prefix_len:], node[2], ( |
524 | tuple(tuple(ref_node[self.prefix_len:] for ref_node in ref_list) |
525 | for ref_list in node[3])) |
526 | @@ -1807,9 +1862,9 @@ |
527 | def _sanity_check_key(index_or_builder, key): |
528 | """Raise BadIndexKey if key cannot be used for prefix matching.""" |
529 | if key[0] is None: |
530 | - raise errors.BadIndexKey(key) |
531 | + raise BadIndexKey(key) |
532 | if len(key) != index_or_builder._key_length: |
533 | - raise errors.BadIndexKey(key) |
534 | + raise BadIndexKey(key) |
535 | |
536 | |
537 | def _iter_entries_prefix(index_or_builder, nodes_by_key, keys): |
538 | |
539 | === modified file 'breezy/bzr/remote.py' |
540 | --- breezy/bzr/remote.py 2017-06-22 01:06:22 +0000 |
541 | +++ breezy/bzr/remote.py 2017-07-24 01:10:54 +0000 |
542 | @@ -3362,7 +3362,7 @@ |
543 | # the vfs branch. |
544 | try: |
545 | fallback_url = self.get_stacked_on_url() |
546 | - except (errors.NotStacked, errors.UnstackableBranchFormat, |
547 | + except (errors.NotStacked, branch.UnstackableBranchFormat, |
548 | errors.UnstackableRepositoryFormat) as e: |
549 | return |
550 | self._is_stacked = True |
551 | @@ -4234,7 +4234,7 @@ |
552 | no_context_error_translators.register('TipChangeRejected', |
553 | lambda err: errors.TipChangeRejected(err.error_args[0].decode('utf8'))) |
554 | no_context_error_translators.register('UnstackableBranchFormat', |
555 | - lambda err: errors.UnstackableBranchFormat(*err.error_args)) |
556 | + lambda err: branch.UnstackableBranchFormat(*err.error_args)) |
557 | no_context_error_translators.register('UnstackableRepositoryFormat', |
558 | lambda err: errors.UnstackableRepositoryFormat(*err.error_args)) |
559 | no_context_error_translators.register('FileExists', |
560 | |
561 | === modified file 'breezy/bzr/smart/request.py' |
562 | --- breezy/bzr/smart/request.py 2017-07-21 13:51:15 +0000 |
563 | +++ breezy/bzr/smart/request.py 2017-07-24 01:10:54 +0000 |
564 | @@ -36,6 +36,7 @@ |
565 | import threading |
566 | |
567 | from ... import ( |
568 | + branch as _mod_branch, |
569 | debug, |
570 | errors, |
571 | osutils, |
572 | @@ -430,7 +431,7 @@ |
573 | return ('RevisionNotPresent', err.revision_id, err.file_id) |
574 | elif isinstance(err, errors.UnstackableRepositoryFormat): |
575 | return (('UnstackableRepositoryFormat', str(err.format), err.url)) |
576 | - elif isinstance(err, errors.UnstackableBranchFormat): |
577 | + elif isinstance(err, _mod_branch.UnstackableBranchFormat): |
578 | return ('UnstackableBranchFormat', str(err.format), err.url) |
579 | elif isinstance(err, errors.NotStacked): |
580 | return ('NotStacked',) |
581 | |
582 | === modified file 'breezy/commit.py' |
583 | --- breezy/commit.py 2017-06-20 22:54:06 +0000 |
584 | +++ breezy/commit.py 2017-07-24 01:10:54 +0000 |
585 | @@ -60,7 +60,7 @@ |
586 | from .branch import Branch |
587 | from .cleanup import OperationWithCleanups |
588 | import breezy.config |
589 | -from .errors import (BzrError, PointlessCommit, |
590 | +from .errors import (BzrError, |
591 | ConflictsInTree, |
592 | StrictCommitFailed |
593 | ) |
594 | @@ -75,6 +75,30 @@ |
595 | from .i18n import gettext |
596 | |
597 | |
598 | +class PointlessCommit(BzrError): |
599 | + |
600 | + _fmt = "No changes to commit" |
601 | + |
602 | + |
603 | +class CannotCommitSelectedFileMerge(BzrError): |
604 | + |
605 | + _fmt = 'Selected-file commit of merges is not supported yet:'\ |
606 | + ' files %(files_str)s' |
607 | + |
608 | + def __init__(self, files): |
609 | + files_str = ', '.join(files) |
610 | + BzrError.__init__(self, files=files, files_str=files_str) |
611 | + |
612 | + |
613 | +class ExcludesUnsupported(BzrError): |
614 | + |
615 | + _fmt = ('Excluding paths during commit is not supported by ' |
616 | + 'repository at %(repository)r.') |
617 | + |
618 | + def __init__(self, repository): |
619 | + BzrError.__init__(self, repository=repository) |
620 | + |
621 | + |
622 | def filter_excluded(iter_changes, exclude): |
623 | """Filter exclude filenames. |
624 | |
625 | |
626 | === modified file 'breezy/controldir.py' |
627 | --- breezy/controldir.py 2017-07-15 13:23:08 +0000 |
628 | +++ breezy/controldir.py 2017-07-24 01:10:54 +0000 |
629 | @@ -29,7 +29,6 @@ |
630 | import textwrap |
631 | |
632 | from breezy import ( |
633 | - errors, |
634 | hooks, |
635 | revision as _mod_revision, |
636 | transport as _mod_transport, |
637 | @@ -45,7 +44,18 @@ |
638 | from breezy.i18n import gettext |
639 | """) |
640 | |
641 | -from . import registry |
642 | +from . import ( |
643 | + errors, |
644 | + registry, |
645 | + ) |
646 | + |
647 | + |
648 | +class MustHaveWorkingTree(errors.BzrError): |
649 | + |
650 | + _fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.") |
651 | + |
652 | + def __init__(self, format, url): |
653 | + errors.BzrError.__init__(self, format=format, url=url) |
654 | |
655 | |
656 | class ControlComponent(object): |
657 | |
658 | === modified file 'breezy/directory_service.py' |
659 | --- breezy/directory_service.py 2017-06-11 00:27:48 +0000 |
660 | +++ breezy/directory_service.py 2017-07-24 01:10:54 +0000 |
661 | @@ -36,6 +36,26 @@ |
662 | """) |
663 | |
664 | |
665 | +class DirectoryLookupFailure(errors.BzrError): |
666 | + """Base type for lookup errors.""" |
667 | + |
668 | + |
669 | +class InvalidLocationAlias(DirectoryLookupFailure): |
670 | + |
671 | + _fmt = '"%(alias_name)s" is not a valid location alias.' |
672 | + |
673 | + def __init__(self, alias_name): |
674 | + DirectoryLookupFailure.__init__(self, alias_name=alias_name) |
675 | + |
676 | + |
677 | +class UnsetLocationAlias(DirectoryLookupFailure): |
678 | + |
679 | + _fmt = 'No %(alias_name)s location assigned.' |
680 | + |
681 | + def __init__(self, alias_name): |
682 | + DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:]) |
683 | + |
684 | + |
685 | class DirectoryServiceRegistry(registry.Registry): |
686 | """This object maintains and uses a list of directory services. |
687 | |
688 | @@ -99,11 +119,11 @@ |
689 | try: |
690 | method = self.branch_aliases.get(name[1:]) |
691 | except KeyError: |
692 | - raise errors.InvalidLocationAlias(url) |
693 | + raise InvalidLocationAlias(url) |
694 | else: |
695 | result = method(branch) |
696 | if result is None: |
697 | - raise errors.UnsetLocationAlias(url) |
698 | + raise UnsetLocationAlias(url) |
699 | if extra is not None: |
700 | result = urlutils.join(result, extra) |
701 | return result |
702 | |
703 | === modified file 'breezy/errors.py' |
704 | --- breezy/errors.py 2017-07-24 01:07:36 +0000 |
705 | +++ breezy/errors.py 2017-07-24 01:10:54 +0000 |
706 | @@ -162,16 +162,6 @@ |
707 | self.msg = msg |
708 | |
709 | |
710 | -class DirstateCorrupt(BzrError): |
711 | - |
712 | - _fmt = "The dirstate file (%(state)s) appears to be corrupt: %(msg)s" |
713 | - |
714 | - def __init__(self, state, msg): |
715 | - BzrError.__init__(self) |
716 | - self.state = state |
717 | - self.msg = msg |
718 | - |
719 | - |
720 | class IncompatibleVersion(BzrError): |
721 | |
722 | _fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\ |
723 | @@ -323,62 +313,6 @@ |
724 | self.not_locked = not_locked |
725 | |
726 | |
727 | -class BadIndexFormatSignature(BzrError): |
728 | - |
729 | - _fmt = "%(value)s is not an index of type %(_type)s." |
730 | - |
731 | - def __init__(self, value, _type): |
732 | - BzrError.__init__(self) |
733 | - self.value = value |
734 | - self._type = _type |
735 | - |
736 | - |
737 | -class BadIndexData(BzrError): |
738 | - |
739 | - _fmt = "Error in data for index %(value)s." |
740 | - |
741 | - def __init__(self, value): |
742 | - BzrError.__init__(self) |
743 | - self.value = value |
744 | - |
745 | - |
746 | -class BadIndexDuplicateKey(BzrError): |
747 | - |
748 | - _fmt = "The key '%(key)s' is already in index '%(index)s'." |
749 | - |
750 | - def __init__(self, key, index): |
751 | - BzrError.__init__(self) |
752 | - self.key = key |
753 | - self.index = index |
754 | - |
755 | - |
756 | -class BadIndexKey(BzrError): |
757 | - |
758 | - _fmt = "The key '%(key)s' is not a valid key." |
759 | - |
760 | - def __init__(self, key): |
761 | - BzrError.__init__(self) |
762 | - self.key = key |
763 | - |
764 | - |
765 | -class BadIndexOptions(BzrError): |
766 | - |
767 | - _fmt = "Could not parse options for index %(value)s." |
768 | - |
769 | - def __init__(self, value): |
770 | - BzrError.__init__(self) |
771 | - self.value = value |
772 | - |
773 | - |
774 | -class BadIndexValue(BzrError): |
775 | - |
776 | - _fmt = "The value '%(value)s' is not a valid value." |
777 | - |
778 | - def __init__(self, value): |
779 | - BzrError.__init__(self) |
780 | - self.value = value |
781 | - |
782 | - |
783 | class StrictCommitFailed(BzrError): |
784 | |
785 | _fmt = "Commit refused because there are unknown files in the tree" |
786 | @@ -482,16 +416,6 @@ |
787 | self.key = key |
788 | |
789 | |
790 | -class UnknownHook(BzrError): |
791 | - |
792 | - _fmt = "The %(type)s hook '%(hook)s' is unknown in this version of breezy." |
793 | - |
794 | - def __init__(self, hook_type, hook_name): |
795 | - BzrError.__init__(self) |
796 | - self.type = hook_type |
797 | - self.hook = hook_name |
798 | - |
799 | - |
800 | class UnsupportedProtocol(PathError): |
801 | |
802 | _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s' |
803 | @@ -500,17 +424,6 @@ |
804 | PathError.__init__(self, url, extra=extra) |
805 | |
806 | |
807 | -class UnstackableBranchFormat(BzrError): |
808 | - |
809 | - _fmt = ("The branch '%(url)s'(%(format)s) is not a stackable format. " |
810 | - "You will need to upgrade the branch to permit branch stacking.") |
811 | - |
812 | - def __init__(self, format, url): |
813 | - BzrError.__init__(self) |
814 | - self.format = format |
815 | - self.url = url |
816 | - |
817 | - |
818 | class UnstackableLocationError(BzrError): |
819 | |
820 | _fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'." |
821 | @@ -1018,36 +931,6 @@ |
822 | self.lock_token = lock_token |
823 | |
824 | |
825 | -class PointlessCommit(BzrError): |
826 | - |
827 | - _fmt = "No changes to commit" |
828 | - |
829 | - |
830 | -class CannotCommitSelectedFileMerge(BzrError): |
831 | - |
832 | - _fmt = 'Selected-file commit of merges is not supported yet:'\ |
833 | - ' files %(files_str)s' |
834 | - |
835 | - def __init__(self, files): |
836 | - files_str = ', '.join(files) |
837 | - BzrError.__init__(self, files=files, files_str=files_str) |
838 | - |
839 | - |
840 | -class ExcludesUnsupported(BzrError): |
841 | - |
842 | - _fmt = ('Excluding paths during commit is not supported by ' |
843 | - 'repository at %(repository)r.') |
844 | - |
845 | - def __init__(self, repository): |
846 | - BzrError.__init__(self, repository=repository) |
847 | - |
848 | - |
849 | -class BadCommitMessageEncoding(BzrError): |
850 | - |
851 | - _fmt = 'The specified commit message contains characters unsupported by '\ |
852 | - 'the current encoding.' |
853 | - |
854 | - |
855 | class UpgradeReadonly(BzrError): |
856 | |
857 | _fmt = "Upgrade URL cannot work with readonly URLs." |
858 | @@ -1062,11 +945,6 @@ |
859 | self.format = format |
860 | |
861 | |
862 | -class StrictCommitFailed(Exception): |
863 | - |
864 | - _fmt = "Commit refused because there are unknowns in the tree." |
865 | - |
866 | - |
867 | class NoSuchRevision(InternalBzrError): |
868 | |
869 | _fmt = "%(branch)s has no revision %(revision)s" |
870 | @@ -1992,17 +1870,6 @@ |
871 | _fmt = "Format error in conflict listings" |
872 | |
873 | |
874 | -class CorruptDirstate(BzrError): |
875 | - |
876 | - _fmt = ("Inconsistency in dirstate file %(dirstate_path)s.\n" |
877 | - "Error: %(description)s") |
878 | - |
879 | - def __init__(self, dirstate_path, description): |
880 | - BzrError.__init__(self) |
881 | - self.dirstate_path = dirstate_path |
882 | - self.description = description |
883 | - |
884 | - |
885 | class CorruptRepository(BzrError): |
886 | |
887 | _fmt = ("An error has been detected in the repository %(repo_path)s.\n" |
888 | @@ -2492,79 +2359,6 @@ |
889 | self.reason = reason |
890 | |
891 | |
892 | -class BzrDirError(BzrError): |
893 | - |
894 | - def __init__(self, controldir): |
895 | - from . import urlutils |
896 | - display_url = urlutils.unescape_for_display(controldir.user_url, |
897 | - 'ascii') |
898 | - BzrError.__init__(self, controldir=controldir, display_url=display_url) |
899 | - |
900 | - |
901 | -class UnsyncedBranches(BzrDirError): |
902 | - |
903 | - _fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See" |
904 | - " brz help sync-for-reconfigure.") |
905 | - |
906 | - def __init__(self, controldir, target_branch): |
907 | - BzrError.__init__(self, controldir) |
908 | - from . import urlutils |
909 | - self.target_url = urlutils.unescape_for_display(target_branch.base, |
910 | - 'ascii') |
911 | - |
912 | - |
913 | -class AlreadyBranch(BzrDirError): |
914 | - |
915 | - _fmt = "'%(display_url)s' is already a branch." |
916 | - |
917 | - |
918 | -class AlreadyTree(BzrDirError): |
919 | - |
920 | - _fmt = "'%(display_url)s' is already a tree." |
921 | - |
922 | - |
923 | -class AlreadyCheckout(BzrDirError): |
924 | - |
925 | - _fmt = "'%(display_url)s' is already a checkout." |
926 | - |
927 | - |
928 | -class AlreadyLightweightCheckout(BzrDirError): |
929 | - |
930 | - _fmt = "'%(display_url)s' is already a lightweight checkout." |
931 | - |
932 | - |
933 | -class AlreadyUsingShared(BzrDirError): |
934 | - |
935 | - _fmt = "'%(display_url)s' is already using a shared repository." |
936 | - |
937 | - |
938 | -class AlreadyStandalone(BzrDirError): |
939 | - |
940 | - _fmt = "'%(display_url)s' is already standalone." |
941 | - |
942 | - |
943 | -class AlreadyWithTrees(BzrDirError): |
944 | - |
945 | - _fmt = ("Shared repository '%(display_url)s' already creates " |
946 | - "working trees.") |
947 | - |
948 | - |
949 | -class AlreadyWithNoTrees(BzrDirError): |
950 | - |
951 | - _fmt = ("Shared repository '%(display_url)s' already doesn't create " |
952 | - "working trees.") |
953 | - |
954 | - |
955 | -class ReconfigurationNotSupported(BzrDirError): |
956 | - |
957 | - _fmt = "Requested reconfiguration of '%(display_url)s' is not supported." |
958 | - |
959 | - |
960 | -class NoBindLocation(BzrDirError): |
961 | - |
962 | - _fmt = "No location could be found to bind to at %(display_url)s." |
963 | - |
964 | - |
965 | class UncommittedChanges(BzrError): |
966 | |
967 | _fmt = ('Working tree "%(display_url)s" has uncommitted changes' |
968 | @@ -2605,19 +2399,6 @@ |
969 | ' (See brz shelve --list).%(more)s') |
970 | |
971 | |
972 | -class MissingTemplateVariable(BzrError): |
973 | - |
974 | - _fmt = 'Variable {%(name)s} is not available.' |
975 | - |
976 | - def __init__(self, name): |
977 | - self.name = name |
978 | - |
979 | - |
980 | -class NoTemplate(BzrError): |
981 | - |
982 | - _fmt = 'No template specified.' |
983 | - |
984 | - |
985 | class UnableCreateSymlink(BzrError): |
986 | |
987 | _fmt = 'Unable to create symlink %(path_str)son this platform' |
988 | @@ -2633,15 +2414,6 @@ |
989 | self.path_str = path_str |
990 | |
991 | |
992 | -class UnsupportedTimezoneFormat(BzrError): |
993 | - |
994 | - _fmt = ('Unsupported timezone format "%(timezone)s", ' |
995 | - 'options are "utc", "original", "local".') |
996 | - |
997 | - def __init__(self, timezone): |
998 | - self.timezone = timezone |
999 | - |
1000 | - |
1001 | class UnableEncodePath(BzrError): |
1002 | |
1003 | _fmt = ('Unable to encode %(kind)s path %(path)r in ' |
1004 | @@ -2662,28 +2434,6 @@ |
1005 | BzrError.__init__(self, alias_name=alias_name) |
1006 | |
1007 | |
1008 | -class DirectoryLookupFailure(BzrError): |
1009 | - """Base type for lookup errors.""" |
1010 | - |
1011 | - pass |
1012 | - |
1013 | - |
1014 | -class InvalidLocationAlias(DirectoryLookupFailure): |
1015 | - |
1016 | - _fmt = '"%(alias_name)s" is not a valid location alias.' |
1017 | - |
1018 | - def __init__(self, alias_name): |
1019 | - DirectoryLookupFailure.__init__(self, alias_name=alias_name) |
1020 | - |
1021 | - |
1022 | -class UnsetLocationAlias(DirectoryLookupFailure): |
1023 | - |
1024 | - _fmt = 'No %(alias_name)s location assigned.' |
1025 | - |
1026 | - def __init__(self, alias_name): |
1027 | - DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:]) |
1028 | - |
1029 | - |
1030 | class CannotBindAddress(BzrError): |
1031 | |
1032 | _fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.' |
1033 | @@ -2694,14 +2444,6 @@ |
1034 | orig_error=repr(orig_error.args)) |
1035 | |
1036 | |
1037 | -class UnknownRules(BzrError): |
1038 | - |
1039 | - _fmt = ('Unknown rules detected: %(unknowns_str)s.') |
1040 | - |
1041 | - def __init__(self, unknowns): |
1042 | - BzrError.__init__(self, unknowns_str=", ".join(unknowns)) |
1043 | - |
1044 | - |
1045 | class TipChangeRejected(BzrError): |
1046 | """A pre_change_branch_tip hook function may raise this to cleanly and |
1047 | explicitly abort a change to a branch tip. |
1048 | @@ -2713,18 +2455,6 @@ |
1049 | self.msg = msg |
1050 | |
1051 | |
1052 | -class DecompressCorruption(BzrError): |
1053 | - |
1054 | - _fmt = "Corruption while decompressing repository file%(orig_error)s" |
1055 | - |
1056 | - def __init__(self, orig_error=None): |
1057 | - if orig_error is not None: |
1058 | - self.orig_error = ", %s" % (orig_error,) |
1059 | - else: |
1060 | - self.orig_error = "" |
1061 | - BzrError.__init__(self) |
1062 | - |
1063 | - |
1064 | class JailBreak(BzrError): |
1065 | |
1066 | _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'." |
1067 | @@ -2738,14 +2468,6 @@ |
1068 | _fmt = 'The user aborted the operation.' |
1069 | |
1070 | |
1071 | -class MustHaveWorkingTree(BzrError): |
1072 | - |
1073 | - _fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.") |
1074 | - |
1075 | - def __init__(self, format, url): |
1076 | - BzrError.__init__(self, format=format, url=url) |
1077 | - |
1078 | - |
1079 | class UnresumableWriteGroup(BzrError): |
1080 | |
1081 | _fmt = ("Repository %(repository)s cannot resume write group " |
1082 | @@ -2822,14 +2544,6 @@ |
1083 | self.format = format |
1084 | |
1085 | |
1086 | -class FeatureAlreadyRegistered(BzrError): |
1087 | - |
1088 | - _fmt = 'The feature %(feature)s has already been registered.' |
1089 | - |
1090 | - def __init__(self, feature): |
1091 | - self.feature = feature |
1092 | - |
1093 | - |
1094 | class ChangesAlreadyStored(BzrCommandError): |
1095 | |
1096 | _fmt = ('Cannot store uncommitted changes because this branch already' |
1097 | |
1098 | === modified file 'breezy/hooks.py' |
1099 | --- breezy/hooks.py 2017-06-11 20:15:04 +0000 |
1100 | +++ breezy/hooks.py 2017-07-24 01:10:54 +0000 |
1101 | @@ -19,6 +19,7 @@ |
1102 | from __future__ import absolute_import |
1103 | |
1104 | from . import ( |
1105 | + errors, |
1106 | registry, |
1107 | ) |
1108 | from .lazy_import import lazy_import |
1109 | @@ -27,13 +28,22 @@ |
1110 | |
1111 | from breezy import ( |
1112 | _format_version_tuple, |
1113 | - errors, |
1114 | pyutils, |
1115 | ) |
1116 | from breezy.i18n import gettext |
1117 | """) |
1118 | |
1119 | |
1120 | +class UnknownHook(errors.BzrError): |
1121 | + |
1122 | + _fmt = "The %(type)s hook '%(hook)s' is unknown in this version of breezy." |
1123 | + |
1124 | + def __init__(self, hook_type, hook_name): |
1125 | + errors.BzrError.__init__(self) |
1126 | + self.type = hook_type |
1127 | + self.hook = hook_name |
1128 | + |
1129 | + |
1130 | class KnownHooksRegistry(registry.Registry): |
1131 | # known_hooks registry contains |
1132 | # tuple of (module, member name) which is the hook point |
1133 | @@ -204,7 +214,7 @@ |
1134 | try: |
1135 | hook = self[hook_name] |
1136 | except KeyError: |
1137 | - raise errors.UnknownHook(self.__class__.__name__, hook_name) |
1138 | + raise UnknownHook(self.__class__.__name__, hook_name) |
1139 | try: |
1140 | hook_lazy = getattr(hook, "hook_lazy") |
1141 | except AttributeError: |
1142 | @@ -229,7 +239,7 @@ |
1143 | try: |
1144 | hook = self[hook_name] |
1145 | except KeyError: |
1146 | - raise errors.UnknownHook(self.__class__.__name__, hook_name) |
1147 | + raise UnknownHook(self.__class__.__name__, hook_name) |
1148 | try: |
1149 | # list hooks, old-style, not yet deprecated but less useful. |
1150 | hook.append(a_callable) |
1151 | @@ -247,7 +257,7 @@ |
1152 | try: |
1153 | hook = self[hook_name] |
1154 | except KeyError: |
1155 | - raise errors.UnknownHook(self.__class__.__name__, hook_name) |
1156 | + raise UnknownHook(self.__class__.__name__, hook_name) |
1157 | try: |
1158 | uninstall = getattr(hook, "uninstall") |
1159 | except AttributeError: |
1160 | |
1161 | === modified file 'breezy/info.py' |
1162 | --- breezy/info.py 2017-07-15 13:23:08 +0000 |
1163 | +++ breezy/info.py 2017-07-24 01:10:54 +0000 |
1164 | @@ -22,6 +22,7 @@ |
1165 | import sys |
1166 | |
1167 | from . import ( |
1168 | + branch as _mod_branch, |
1169 | controldir, |
1170 | errors, |
1171 | hooks as _mod_hooks, |
1172 | @@ -162,7 +163,7 @@ |
1173 | locs.add_url('submit branch', branch.get_submit_branch()) |
1174 | try: |
1175 | locs.add_url('stacked on', branch.get_stacked_on_url()) |
1176 | - except (errors.UnstackableBranchFormat, errors.UnstackableRepositoryFormat, |
1177 | + except (_mod_branch.UnstackableBranchFormat, errors.UnstackableRepositoryFormat, |
1178 | errors.NotStacked): |
1179 | pass |
1180 | return locs |
1181 | |
1182 | === modified file 'breezy/msgeditor.py' |
1183 | --- breezy/msgeditor.py 2017-05-22 00:56:52 +0000 |
1184 | +++ breezy/msgeditor.py 2017-07-24 01:10:54 +0000 |
1185 | @@ -31,13 +31,19 @@ |
1186 | transport, |
1187 | ui, |
1188 | ) |
1189 | -from .errors import BzrError, BadCommitMessageEncoding |
1190 | +from .errors import BzrError |
1191 | from .hooks import Hooks |
1192 | from .sixish import ( |
1193 | StringIO, |
1194 | ) |
1195 | |
1196 | |
1197 | +class BadCommitMessageEncoding(BzrError): |
1198 | + |
1199 | + _fmt = 'The specified commit message contains characters unsupported by '\ |
1200 | + 'the current encoding.' |
1201 | + |
1202 | + |
1203 | def _get_editor(): |
1204 | """Return a sequence of possible editor binaries for the current platform""" |
1205 | try: |
1206 | |
1207 | === modified file 'breezy/osutils.py' |
1208 | --- breezy/osutils.py 2017-06-15 23:20:39 +0000 |
1209 | +++ breezy/osutils.py 2017-07-24 01:10:54 +0000 |
1210 | @@ -47,7 +47,6 @@ |
1211 | |
1212 | from breezy import ( |
1213 | config, |
1214 | - errors, |
1215 | trace, |
1216 | win32utils, |
1217 | ) |
1218 | @@ -66,7 +65,10 @@ |
1219 | |
1220 | |
1221 | import breezy |
1222 | -from . import _fs_enc |
1223 | +from . import ( |
1224 | + _fs_enc, |
1225 | + errors, |
1226 | + ) |
1227 | |
1228 | |
1229 | # Cross platform wall-clock time functionality with decent resolution. |
1230 | @@ -89,6 +91,15 @@ |
1231 | O_NOINHERIT = getattr(os, 'O_NOINHERIT', 0) |
1232 | |
1233 | |
1234 | +class UnsupportedTimezoneFormat(errors.BzrError): |
1235 | + |
1236 | + _fmt = ('Unsupported timezone format "%(timezone)s", ' |
1237 | + 'options are "utc", "original", "local".') |
1238 | + |
1239 | + def __init__(self, timezone): |
1240 | + self.timezone = timezone |
1241 | + |
1242 | + |
1243 | def get_unicode_argv(): |
1244 | if PY3: |
1245 | return sys.argv[1:] |
1246 | @@ -899,7 +910,7 @@ |
1247 | tt = time.localtime(t) |
1248 | offset = local_time_offset(t) |
1249 | else: |
1250 | - raise errors.UnsupportedTimezoneFormat(timezone) |
1251 | + raise UnsupportedTimezoneFormat(timezone) |
1252 | if date_fmt is None: |
1253 | date_fmt = "%a %Y-%m-%d %H:%M:%S" |
1254 | if show_offset: |
1255 | |
1256 | === modified file 'breezy/plugins/weave_fmt/bzrdir.py' |
1257 | --- breezy/plugins/weave_fmt/bzrdir.py 2017-06-11 20:33:20 +0000 |
1258 | +++ breezy/plugins/weave_fmt/bzrdir.py 2017-07-24 01:10:54 +0000 |
1259 | @@ -26,15 +26,19 @@ |
1260 | from ...controldir import ( |
1261 | ControlDir, |
1262 | Converter, |
1263 | + MustHaveWorkingTree, |
1264 | format_registry, |
1265 | ) |
1266 | +from ... import ( |
1267 | + errors, |
1268 | + ) |
1269 | from ...lazy_import import lazy_import |
1270 | lazy_import(globals(), """ |
1271 | import os |
1272 | import warnings |
1273 | |
1274 | from breezy import ( |
1275 | - errors, |
1276 | + branch as _mod_branch,, |
1277 | graph, |
1278 | lockable_files, |
1279 | lockdir, |
1280 | @@ -903,10 +907,10 @@ |
1281 | "source branch %r is not within %r with branch %r" % |
1282 | (source_branch, self, my_branch)) |
1283 | if stacked: |
1284 | - raise errors.UnstackableBranchFormat( |
1285 | + raise _mod_branch.UnstackableBranchFormat( |
1286 | self._format, self.root_transport.base) |
1287 | if not create_tree_if_local: |
1288 | - raise errors.MustHaveWorkingTree( |
1289 | + raise MustHaveWorkingTree( |
1290 | self._format, self.root_transport.base) |
1291 | from .workingtree import WorkingTreeFormat2 |
1292 | self._make_tail(url) |
1293 | |
1294 | === modified file 'breezy/push.py' |
1295 | --- breezy/push.py 2017-06-11 00:27:48 +0000 |
1296 | +++ breezy/push.py 2017-07-24 01:10:54 +0000 |
1297 | @@ -19,6 +19,7 @@ |
1298 | from __future__ import absolute_import |
1299 | |
1300 | from . import ( |
1301 | + branch as _mod_branch, |
1302 | controldir, |
1303 | errors, |
1304 | revision as _mod_revision, |
1305 | @@ -125,7 +126,7 @@ |
1306 | # TODO: Some more useful message about what was copied |
1307 | try: |
1308 | push_result.stacked_on = br_to.get_stacked_on_url() |
1309 | - except (errors.UnstackableBranchFormat, |
1310 | + except (_mod_branch.UnstackableBranchFormat, |
1311 | errors.UnstackableRepositoryFormat, |
1312 | errors.NotStacked): |
1313 | push_result.stacked_on = None |
1314 | |
1315 | === modified file 'breezy/reconfigure.py' |
1316 | --- breezy/reconfigure.py 2017-06-11 00:27:48 +0000 |
1317 | +++ breezy/reconfigure.py 2017-07-24 01:10:54 +0000 |
1318 | @@ -37,6 +37,79 @@ |
1319 | # assumptions about what kind of change will be done. |
1320 | |
1321 | |
1322 | +class BzrDirError(errors.BzrError): |
1323 | + |
1324 | + def __init__(self, controldir): |
1325 | + display_url = urlutils.unescape_for_display(controldir.user_url, |
1326 | + 'ascii') |
1327 | + errors.BzrError.__init__(self, controldir=controldir, |
1328 | + display_url=display_url) |
1329 | + |
1330 | + |
1331 | +class NoBindLocation(BzrDirError): |
1332 | + |
1333 | + _fmt = "No location could be found to bind to at %(display_url)s." |
1334 | + |
1335 | + |
1336 | +class UnsyncedBranches(BzrDirError): |
1337 | + |
1338 | + _fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See" |
1339 | + " brz help sync-for-reconfigure.") |
1340 | + |
1341 | + def __init__(self, controldir, target_branch): |
1342 | + BzrError.__init__(self, controldir) |
1343 | + from . import urlutils |
1344 | + self.target_url = urlutils.unescape_for_display(target_branch.base, |
1345 | + 'ascii') |
1346 | + |
1347 | + |
1348 | +class AlreadyBranch(BzrDirError): |
1349 | + |
1350 | + _fmt = "'%(display_url)s' is already a branch." |
1351 | + |
1352 | + |
1353 | +class AlreadyTree(BzrDirError): |
1354 | + |
1355 | + _fmt = "'%(display_url)s' is already a tree." |
1356 | + |
1357 | + |
1358 | +class AlreadyCheckout(BzrDirError): |
1359 | + |
1360 | + _fmt = "'%(display_url)s' is already a checkout." |
1361 | + |
1362 | + |
1363 | +class AlreadyLightweightCheckout(BzrDirError): |
1364 | + |
1365 | + _fmt = "'%(display_url)s' is already a lightweight checkout." |
1366 | + |
1367 | + |
1368 | +class AlreadyUsingShared(BzrDirError): |
1369 | + |
1370 | + _fmt = "'%(display_url)s' is already using a shared repository." |
1371 | + |
1372 | + |
1373 | +class AlreadyStandalone(BzrDirError): |
1374 | + |
1375 | + _fmt = "'%(display_url)s' is already standalone." |
1376 | + |
1377 | + |
1378 | +class AlreadyWithTrees(BzrDirError): |
1379 | + |
1380 | + _fmt = ("Shared repository '%(display_url)s' already creates " |
1381 | + "working trees.") |
1382 | + |
1383 | + |
1384 | +class AlreadyWithNoTrees(BzrDirError): |
1385 | + |
1386 | + _fmt = ("Shared repository '%(display_url)s' already doesn't create " |
1387 | + "working trees.") |
1388 | + |
1389 | + |
1390 | +class ReconfigurationNotSupported(BzrDirError): |
1391 | + |
1392 | + _fmt = "Requested reconfiguration of '%(display_url)s' is not supported." |
1393 | + |
1394 | + |
1395 | class ReconfigureStackedOn(object): |
1396 | """Reconfigures a branch to be stacked on another branch.""" |
1397 | |
1398 | @@ -120,13 +193,13 @@ |
1399 | """Return a Reconfiguration to convert this controldir into a branch |
1400 | |
1401 | :param controldir: The controldir to reconfigure |
1402 | - :raise errors.AlreadyBranch: if controldir is already a branch |
1403 | + :raise AlreadyBranch: if controldir is already a branch |
1404 | """ |
1405 | reconfiguration = Reconfigure(controldir) |
1406 | reconfiguration._plan_changes(want_tree=False, want_branch=True, |
1407 | want_bound=False, want_reference=False) |
1408 | if not reconfiguration.changes_planned(): |
1409 | - raise errors.AlreadyBranch(controldir) |
1410 | + raise AlreadyBranch(controldir) |
1411 | return reconfiguration |
1412 | |
1413 | @staticmethod |
1414 | @@ -134,13 +207,13 @@ |
1415 | """Return a Reconfiguration to convert this controldir into a tree |
1416 | |
1417 | :param controldir: The controldir to reconfigure |
1418 | - :raise errors.AlreadyTree: if controldir is already a tree |
1419 | + :raise AlreadyTree: if controldir is already a tree |
1420 | """ |
1421 | reconfiguration = Reconfigure(controldir) |
1422 | reconfiguration._plan_changes(want_tree=True, want_branch=True, |
1423 | want_bound=False, want_reference=False) |
1424 | if not reconfiguration.changes_planned(): |
1425 | - raise errors.AlreadyTree(controldir) |
1426 | + raise AlreadyTree(controldir) |
1427 | return reconfiguration |
1428 | |
1429 | @staticmethod |
1430 | @@ -149,13 +222,13 @@ |
1431 | |
1432 | :param controldir: The controldir to reconfigure |
1433 | :param bound_location: The location the checkout should be bound to. |
1434 | - :raise errors.AlreadyCheckout: if controldir is already a checkout |
1435 | + :raise AlreadyCheckout: if controldir is already a checkout |
1436 | """ |
1437 | reconfiguration = Reconfigure(controldir, bound_location) |
1438 | reconfiguration._plan_changes(want_tree=True, want_branch=True, |
1439 | want_bound=True, want_reference=False) |
1440 | if not reconfiguration.changes_planned(): |
1441 | - raise errors.AlreadyCheckout(controldir) |
1442 | + raise AlreadyCheckout(controldir) |
1443 | return reconfiguration |
1444 | |
1445 | @classmethod |
1446 | @@ -164,14 +237,14 @@ |
1447 | |
1448 | :param controldir: The controldir to reconfigure |
1449 | :param bound_location: The location the checkout should be bound to. |
1450 | - :raise errors.AlreadyLightweightCheckout: if controldir is already a |
1451 | + :raise AlreadyLightweightCheckout: if controldir is already a |
1452 | lightweight checkout |
1453 | """ |
1454 | reconfiguration = klass(controldir, reference_location) |
1455 | reconfiguration._plan_changes(want_tree=True, want_branch=False, |
1456 | want_bound=False, want_reference=True) |
1457 | if not reconfiguration.changes_planned(): |
1458 | - raise errors.AlreadyLightweightCheckout(controldir) |
1459 | + raise AlreadyLightweightCheckout(controldir) |
1460 | return reconfiguration |
1461 | |
1462 | @classmethod |
1463 | @@ -180,7 +253,7 @@ |
1464 | reconfiguration = klass(controldir) |
1465 | reconfiguration._set_use_shared(use_shared=True) |
1466 | if not reconfiguration.changes_planned(): |
1467 | - raise errors.AlreadyUsingShared(controldir) |
1468 | + raise AlreadyUsingShared(controldir) |
1469 | return reconfiguration |
1470 | |
1471 | @classmethod |
1472 | @@ -189,7 +262,7 @@ |
1473 | reconfiguration = klass(controldir) |
1474 | reconfiguration._set_use_shared(use_shared=False) |
1475 | if not reconfiguration.changes_planned(): |
1476 | - raise errors.AlreadyStandalone(controldir) |
1477 | + raise AlreadyStandalone(controldir) |
1478 | return reconfiguration |
1479 | |
1480 | @classmethod |
1481 | @@ -197,12 +270,12 @@ |
1482 | """Adjust a repository's working tree presence default""" |
1483 | reconfiguration = klass(controldir) |
1484 | if not reconfiguration.repository.is_shared(): |
1485 | - raise errors.ReconfigurationNotSupported(reconfiguration.controldir) |
1486 | + raise ReconfigurationNotSupported(reconfiguration.controldir) |
1487 | if with_trees and reconfiguration.repository.make_working_trees(): |
1488 | - raise errors.AlreadyWithTrees(controldir) |
1489 | + raise AlreadyWithTrees(controldir) |
1490 | elif (not with_trees |
1491 | and not reconfiguration.repository.make_working_trees()): |
1492 | - raise errors.AlreadyWithNoTrees(controldir) |
1493 | + raise AlreadyWithNoTrees(controldir) |
1494 | else: |
1495 | reconfiguration._repository_trees = with_trees |
1496 | return reconfiguration |
1497 | @@ -211,9 +284,9 @@ |
1498 | want_reference): |
1499 | """Determine which changes are needed to assume the configuration""" |
1500 | if not want_branch and not want_reference: |
1501 | - raise errors.ReconfigurationNotSupported(self.controldir) |
1502 | + raise ReconfigurationNotSupported(self.controldir) |
1503 | if want_branch and want_reference: |
1504 | - raise errors.ReconfigurationNotSupported(self.controldir) |
1505 | + raise ReconfigurationNotSupported(self.controldir) |
1506 | if self.repository is None: |
1507 | if not want_reference: |
1508 | self._create_repository = True |
1509 | @@ -302,7 +375,7 @@ |
1510 | return parent |
1511 | elif self.referenced_branch is not None: |
1512 | return self.referenced_branch.base |
1513 | - raise errors.NoBindLocation(self.controldir) |
1514 | + raise NoBindLocation(self.controldir) |
1515 | |
1516 | def apply(self, force=False): |
1517 | """Apply the reconfiguration |
1518 | @@ -311,7 +384,7 @@ |
1519 | destroy local changes. |
1520 | :raise errors.UncommittedChanges: if the local tree is to be destroyed |
1521 | but contains uncommitted changes. |
1522 | - :raise errors.NoBindLocation: if no bind location was specified and |
1523 | + :raise NoBindLocation: if no bind location was specified and |
1524 | none could be autodetected. |
1525 | """ |
1526 | if not force: |
1527 | |
1528 | === modified file 'breezy/rules.py' |
1529 | --- breezy/rules.py 2017-05-22 00:56:52 +0000 |
1530 | +++ breezy/rules.py 2017-07-24 01:10:54 +0000 |
1531 | @@ -43,6 +43,14 @@ |
1532 | _per_user_searcher = None |
1533 | |
1534 | |
1535 | +class UnknownRules(errors.BzrError): |
1536 | + |
1537 | + _fmt = ('Unknown rules detected: %(unknowns_str)s.') |
1538 | + |
1539 | + def __init__(self, unknowns): |
1540 | + errors.BzrError.__init__(self, unknowns_str=", ".join(unknowns)) |
1541 | + |
1542 | + |
1543 | class _RulesSearcher(object): |
1544 | """An object that provides rule-based preferences.""" |
1545 | |
1546 | |
1547 | === modified file 'breezy/tests/blackbox/test_push.py' |
1548 | --- breezy/tests/blackbox/test_push.py 2017-06-10 16:40:42 +0000 |
1549 | +++ breezy/tests/blackbox/test_push.py 2017-07-24 01:10:54 +0000 |
1550 | @@ -561,7 +561,7 @@ |
1551 | self.make_branch('from', format='pack-0.92') |
1552 | out, err = self.run_bzr('push -d from to') |
1553 | b = branch.Branch.open('to') |
1554 | - self.assertRaises(errors.UnstackableBranchFormat, b.get_stacked_on_url) |
1555 | + self.assertRaises(branch.UnstackableBranchFormat, b.get_stacked_on_url) |
1556 | |
1557 | def test_push_doesnt_create_broken_branch(self): |
1558 | """Pushing a new standalone branch works even when there's a default |
1559 | |
1560 | === modified file 'breezy/tests/per_branch/test_create_clone.py' |
1561 | --- breezy/tests/per_branch/test_create_clone.py 2017-06-11 14:07:05 +0000 |
1562 | +++ breezy/tests/per_branch/test_create_clone.py 2017-07-24 01:10:54 +0000 |
1563 | @@ -101,7 +101,7 @@ |
1564 | try: |
1565 | result = tree.branch.create_clone_on_transport(target_transport, |
1566 | stacked_on=trunk.base) |
1567 | - except errors.UnstackableBranchFormat: |
1568 | + except branch.UnstackableBranchFormat: |
1569 | if not trunk.repository._format.supports_full_versioned_files: |
1570 | raise tests.TestNotApplicable("can not stack on format") |
1571 | raise |
1572 | @@ -142,7 +142,7 @@ |
1573 | try: |
1574 | result = tree.branch.create_clone_on_transport(target_transport, |
1575 | stacked_on=trunk.base) |
1576 | - except errors.UnstackableBranchFormat: |
1577 | + except branch.UnstackableBranchFormat: |
1578 | if not trunk.repository._format.supports_full_versioned_files: |
1579 | raise tests.TestNotApplicable("can not stack on format") |
1580 | raise |
1581 | |
1582 | === modified file 'breezy/tests/per_branch/test_sprout.py' |
1583 | --- breezy/tests/per_branch/test_sprout.py 2017-06-11 14:07:05 +0000 |
1584 | +++ breezy/tests/per_branch/test_sprout.py 2017-07-24 01:10:54 +0000 |
1585 | @@ -209,7 +209,7 @@ |
1586 | dir = source.controldir.sprout(target_transport.base, |
1587 | source.last_revision(), possible_transports=[target_transport], |
1588 | source_branch=source, stacked=True) |
1589 | - except errors.UnstackableBranchFormat: |
1590 | + except _mod_branch.UnstackableBranchFormat: |
1591 | if not self.branch_format.supports_stacking(): |
1592 | raise tests.TestNotApplicable( |
1593 | "Format doesn't auto stack successfully.") |
1594 | |
1595 | === modified file 'breezy/tests/per_branch/test_stacking.py' |
1596 | --- breezy/tests/per_branch/test_stacking.py 2017-06-10 00:52:37 +0000 |
1597 | +++ breezy/tests/per_branch/test_stacking.py 2017-07-24 01:10:54 +0000 |
1598 | @@ -28,7 +28,7 @@ |
1599 | |
1600 | |
1601 | unstackable_format_errors = ( |
1602 | - errors.UnstackableBranchFormat, |
1603 | + branch.UnstackableBranchFormat, |
1604 | errors.UnstackableRepositoryFormat, |
1605 | ) |
1606 | |
1607 | @@ -309,14 +309,14 @@ |
1608 | cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked', |
1609 | preserve_stacking=False) |
1610 | unstacked_branch = cloned_unstacked_bzrdir.open_branch() |
1611 | - self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat), |
1612 | + self.assertRaises((errors.NotStacked, branch.UnstackableBranchFormat), |
1613 | unstacked_branch.get_stacked_on_url) |
1614 | |
1615 | def test_no_op_preserve_stacking(self): |
1616 | """With no stacking, preserve_stacking should be a no-op.""" |
1617 | branch = self.make_branch('source') |
1618 | cloned_bzrdir = branch.controldir.clone('cloned', preserve_stacking=True) |
1619 | - self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat), |
1620 | + self.assertRaises((errors.NotStacked, branch.UnstackableBranchFormat), |
1621 | cloned_bzrdir.open_branch().get_stacked_on_url) |
1622 | |
1623 | def make_stacked_on_matching(self, source): |
1624 | @@ -344,7 +344,7 @@ |
1625 | self.assertEqual('../stack-on', target.get_stacked_on_url()) |
1626 | else: |
1627 | self.assertRaises( |
1628 | - errors.UnstackableBranchFormat, target.get_stacked_on_url) |
1629 | + branch.UnstackableBranchFormat, target.get_stacked_on_url) |
1630 | |
1631 | def test_clone_stacking_policy_handling(self): |
1632 | """Obey policy where possible, ignore otherwise.""" |
1633 | @@ -361,7 +361,7 @@ |
1634 | self.assertEqual('../stack-on', target.get_stacked_on_url()) |
1635 | else: |
1636 | self.assertRaises( |
1637 | - errors.UnstackableBranchFormat, target.get_stacked_on_url) |
1638 | + branch.UnstackableBranchFormat, target.get_stacked_on_url) |
1639 | |
1640 | def test_sprout_to_smart_server_stacking_policy_handling(self): |
1641 | """Obey policy where possible, ignore otherwise.""" |
1642 | @@ -379,7 +379,7 @@ |
1643 | self.assertEqual('../stack-on', target.get_stacked_on_url()) |
1644 | else: |
1645 | self.assertRaises( |
1646 | - errors.UnstackableBranchFormat, target.get_stacked_on_url) |
1647 | + branch.UnstackableBranchFormat, target.get_stacked_on_url) |
1648 | |
1649 | def prepare_stacked_on_fetch(self): |
1650 | stack_on = self.make_branch_and_tree('stack-on') |
1651 | |
1652 | === modified file 'breezy/tests/per_controldir/test_controldir.py' |
1653 | --- breezy/tests/per_controldir/test_controldir.py 2017-06-11 14:07:05 +0000 |
1654 | +++ breezy/tests/per_controldir/test_controldir.py 2017-07-24 01:10:54 +0000 |
1655 | @@ -18,6 +18,7 @@ |
1656 | |
1657 | import breezy.branch |
1658 | from breezy import ( |
1659 | + branch as _mod_branch, |
1660 | check, |
1661 | controldir, |
1662 | errors, |
1663 | @@ -428,7 +429,7 @@ |
1664 | try: |
1665 | child = branch.controldir.clone_on_transport(child_transport, |
1666 | stacked_on=branch.base) |
1667 | - except (errors.UnstackableBranchFormat, |
1668 | + except (_mod_branch.UnstackableBranchFormat, |
1669 | errors.UnstackableRepositoryFormat): |
1670 | raise TestNotApplicable("branch or repository format does " |
1671 | "not support stacking") |
1672 | @@ -995,7 +996,7 @@ |
1673 | try: |
1674 | target = dir.sprout(self.get_url('target'), |
1675 | create_tree_if_local=False) |
1676 | - except errors.MustHaveWorkingTree: |
1677 | + except controldir.MustHaveWorkingTree: |
1678 | raise TestNotApplicable("control dir format requires working tree") |
1679 | self.assertPathDoesNotExist('target/foo') |
1680 | self.assertEqual(tree.branch.last_revision(), |
1681 | |
1682 | === modified file 'breezy/tests/per_foreign_vcs/test_branch.py' |
1683 | --- breezy/tests/per_foreign_vcs/test_branch.py 2017-06-10 00:52:37 +0000 |
1684 | +++ breezy/tests/per_foreign_vcs/test_branch.py 2017-07-24 01:10:54 +0000 |
1685 | @@ -17,10 +17,11 @@ |
1686 | |
1687 | """Tests specific to Branch implementations that use foreign VCS'es.""" |
1688 | |
1689 | - |
1690 | +from breezy.branch import ( |
1691 | + UnstackableBranchFormat, |
1692 | + ) |
1693 | from breezy.errors import ( |
1694 | IncompatibleFormat, |
1695 | - UnstackableBranchFormat, |
1696 | ) |
1697 | from breezy.revision import ( |
1698 | NULL_REVISION, |
1699 | |
1700 | === modified file 'breezy/tests/per_workingtree/test_commit.py' |
1701 | --- breezy/tests/per_workingtree/test_commit.py 2017-06-20 00:26:58 +0000 |
1702 | +++ breezy/tests/per_workingtree/test_commit.py 2017-07-24 01:10:54 +0000 |
1703 | @@ -29,6 +29,11 @@ |
1704 | transport as _mod_transport, |
1705 | ui, |
1706 | ) |
1707 | +from breezy.commit import ( |
1708 | + CannotCommitSelectedFileMerge, |
1709 | + ExcludesUnsupported, |
1710 | + PointlessCommit, |
1711 | + ) |
1712 | from breezy.tests.per_workingtree import TestCaseWithWorkingTree |
1713 | from breezy.tests.testui import ProgressRecordingUIFactory |
1714 | |
1715 | @@ -149,9 +154,9 @@ |
1716 | wt2.commit('change_right') |
1717 | wt.merge_from_branch(wt2.branch) |
1718 | try: |
1719 | - self.assertRaises(errors.CannotCommitSelectedFileMerge, |
1720 | + self.assertRaises(CannotCommitSelectedFileMerge, |
1721 | wt.commit, 'test', exclude=['foo']) |
1722 | - except errors.ExcludesUnsupported: |
1723 | + except ExcludesUnsupported: |
1724 | raise tests.TestNotApplicable("excludes not supported by this " |
1725 | "repository format") |
1726 | |
1727 | @@ -162,9 +167,9 @@ |
1728 | tree.commit('setup test') |
1729 | self.build_tree_contents([('a', 'new contents for "a"\n')]) |
1730 | try: |
1731 | - self.assertRaises(errors.PointlessCommit, tree.commit, 'test', |
1732 | + self.assertRaises(PointlessCommit, tree.commit, 'test', |
1733 | exclude=['a'], allow_pointless=False) |
1734 | - except errors.ExcludesUnsupported: |
1735 | + except ExcludesUnsupported: |
1736 | raise tests.TestNotApplicable("excludes not supported by this " |
1737 | "repository format") |
1738 | |
1739 | @@ -174,7 +179,7 @@ |
1740 | tree.smart_add(['.']) |
1741 | try: |
1742 | tree.commit('test', exclude=['b', 'c']) |
1743 | - except errors.ExcludesUnsupported: |
1744 | + except ExcludesUnsupported: |
1745 | raise tests.TestNotApplicable("excludes not supported by this " |
1746 | "repository format") |
1747 | # If b was excluded it will still be 'added' in status. |
1748 | @@ -458,7 +463,7 @@ |
1749 | rev_id = tree.commit('added reference') |
1750 | child_revid = subtree.last_revision() |
1751 | # now do a no-op commit with allow_pointless=False |
1752 | - self.assertRaises(errors.PointlessCommit, tree.commit, '', |
1753 | + self.assertRaises(PointlessCommit, tree.commit, '', |
1754 | allow_pointless=False) |
1755 | self.assertEqual(child_revid, subtree.last_revision()) |
1756 | self.assertEqual(rev_id, tree.last_revision()) |
1757 | |
1758 | === modified file 'breezy/tests/test__dirstate_helpers.py' |
1759 | --- breezy/tests/test__dirstate_helpers.py 2017-06-10 12:50:32 +0000 |
1760 | +++ breezy/tests/test__dirstate_helpers.py 2017-07-24 01:10:54 +0000 |
1761 | @@ -21,7 +21,6 @@ |
1762 | import time |
1763 | |
1764 | from .. import ( |
1765 | - errors, |
1766 | osutils, |
1767 | tests, |
1768 | ) |
1769 | @@ -724,7 +723,7 @@ |
1770 | finally: |
1771 | f.close() |
1772 | state.lock_read() |
1773 | - e = self.assertRaises(errors.DirstateCorrupt, |
1774 | + e = self.assertRaises(dirstate.DirstateCorrupt, |
1775 | state._read_dirblocks_if_needed) |
1776 | # Make sure we mention the bogus characters in the error |
1777 | self.assertContainsRe(str(e), 'bogus') |
1778 | |
1779 | === modified file 'breezy/tests/test_branch.py' |
1780 | --- breezy/tests/test_branch.py 2017-06-10 16:40:42 +0000 |
1781 | +++ breezy/tests/test_branch.py 2017-07-24 01:10:54 +0000 |
1782 | @@ -44,6 +44,18 @@ |
1783 | ) |
1784 | |
1785 | |
1786 | +class ErrorTests(tests.TestCase): |
1787 | + |
1788 | + def test_unstackable_branch_format(self): |
1789 | + format = u'foo' |
1790 | + url = "/foo" |
1791 | + error = _mod_branch.UnstackableBranchFormat(format, url) |
1792 | + self.assertEqualDiff( |
1793 | + "The branch '/foo'(foo) is not a stackable format. " |
1794 | + "You will need to upgrade the branch to permit branch stacking.", |
1795 | + str(error)) |
1796 | + |
1797 | + |
1798 | class TestDefaultFormat(tests.TestCase): |
1799 | |
1800 | def test_default_format(self): |
1801 | @@ -356,12 +368,12 @@ |
1802 | |
1803 | def test_set_stacked_on_url_errors(self): |
1804 | branch = self.make_branch('a', format=self.get_format_name()) |
1805 | - self.assertRaises(errors.UnstackableBranchFormat, |
1806 | + self.assertRaises(_mod_branch.UnstackableBranchFormat, |
1807 | branch.set_stacked_on_url, None) |
1808 | |
1809 | def test_default_stacked_location(self): |
1810 | branch = self.make_branch('a', format=self.get_format_name()) |
1811 | - self.assertRaises(errors.UnstackableBranchFormat, branch.get_stacked_on_url) |
1812 | + self.assertRaises(_mod_branch.UnstackableBranchFormat, branch.get_stacked_on_url) |
1813 | |
1814 | |
1815 | class TestBranch7(TestBranch67, tests.TestCaseWithTransport): |
1816 | |
1817 | === modified file 'breezy/tests/test_bzrdir.py' |
1818 | --- breezy/tests/test_bzrdir.py 2017-07-14 20:49:41 +0000 |
1819 | +++ breezy/tests/test_bzrdir.py 2017-07-24 01:10:54 +0000 |
1820 | @@ -560,14 +560,14 @@ |
1821 | child_branch, new_child_transport = self.prepare_default_stacking( |
1822 | child_format='pack-0.92') |
1823 | new_child = child_branch.controldir.clone_on_transport(new_child_transport) |
1824 | - self.assertRaises(errors.UnstackableBranchFormat, |
1825 | + self.assertRaises(branch.UnstackableBranchFormat, |
1826 | new_child.open_branch().get_stacked_on_url) |
1827 | |
1828 | def test_sprout_ignores_policy_for_unsupported_formats(self): |
1829 | child_branch, new_child_transport = self.prepare_default_stacking( |
1830 | child_format='pack-0.92') |
1831 | new_child = child_branch.controldir.sprout(new_child_transport.base) |
1832 | - self.assertRaises(errors.UnstackableBranchFormat, |
1833 | + self.assertRaises(branch.UnstackableBranchFormat, |
1834 | new_child.open_branch().get_stacked_on_url) |
1835 | |
1836 | def test_sprout_upgrades_format_if_stacked_specified(self): |
1837 | @@ -1556,7 +1556,7 @@ |
1838 | # a feature can only be registered once |
1839 | self.addCleanup(SampleBzrFormat.unregister_feature, "nested-trees") |
1840 | SampleBzrFormat.register_feature("nested-trees") |
1841 | - self.assertRaises(errors.FeatureAlreadyRegistered, |
1842 | + self.assertRaises(bzrdir.FeatureAlreadyRegistered, |
1843 | SampleBzrFormat.register_feature, "nested-trees") |
1844 | |
1845 | def test_feature_with_space(self): |
1846 | |
1847 | === modified file 'breezy/tests/test_commit.py' |
1848 | --- breezy/tests/test_commit.py 2017-07-04 20:03:11 +0000 |
1849 | +++ breezy/tests/test_commit.py 2017-07-24 01:10:54 +0000 |
1850 | @@ -26,12 +26,13 @@ |
1851 | from ..branch import Branch |
1852 | from ..bzr.bzrdir import BzrDirMetaFormat1 |
1853 | from ..commit import ( |
1854 | + CannotCommitSelectedFileMerge, |
1855 | Commit, |
1856 | NullCommitReporter, |
1857 | + PointlessCommit, |
1858 | filter_excluded, |
1859 | ) |
1860 | from ..errors import ( |
1861 | - PointlessCommit, |
1862 | BzrError, |
1863 | LockContention, |
1864 | ) |
1865 | @@ -763,7 +764,7 @@ |
1866 | tree.add_parent_tree_id('example') |
1867 | self.build_tree(['foo/bar', 'foo/baz']) |
1868 | tree.add(['bar', 'baz']) |
1869 | - err = self.assertRaises(errors.CannotCommitSelectedFileMerge, |
1870 | + err = self.assertRaises(CannotCommitSelectedFileMerge, |
1871 | tree.commit, 'commit 2', specific_files=['bar', 'baz']) |
1872 | self.assertEqual(['bar', 'baz'], err.files) |
1873 | self.assertEqual('Selected-file commit of merges is not supported' |
1874 | |
1875 | === modified file 'breezy/tests/test_controldir.py' |
1876 | --- breezy/tests/test_controldir.py 2017-06-13 10:58:02 +0000 |
1877 | +++ breezy/tests/test_controldir.py 2017-07-24 01:10:54 +0000 |
1878 | @@ -31,6 +31,14 @@ |
1879 | load_tests = load_tests_apply_scenarios |
1880 | |
1881 | |
1882 | +class ErrorTests(tests.TestCase): |
1883 | + |
1884 | + def test_must_have_working_tree(self): |
1885 | + err = controldir.MustHaveWorkingTree('foo', 'bar') |
1886 | + self.assertEqual(str(err), "Branching 'bar'(foo) must create a" |
1887 | + " working tree.") |
1888 | + |
1889 | + |
1890 | class SampleComponentFormat(controldir.ControlComponentFormat): |
1891 | |
1892 | def get_format_string(self): |
1893 | |
1894 | === modified file 'breezy/tests/test_directory_service.py' |
1895 | --- breezy/tests/test_directory_service.py 2017-06-10 00:17:06 +0000 |
1896 | +++ breezy/tests/test_directory_service.py 2017-07-24 01:10:54 +0000 |
1897 | @@ -17,13 +17,14 @@ |
1898 | """Test directory service implementation""" |
1899 | |
1900 | from .. import ( |
1901 | - errors, |
1902 | transport, |
1903 | urlutils, |
1904 | ) |
1905 | from ..directory_service import ( |
1906 | AliasDirectory, |
1907 | DirectoryServiceRegistry, |
1908 | + InvalidLocationAlias, |
1909 | + UnsetLocationAlias, |
1910 | directories, |
1911 | ) |
1912 | from . import TestCase, TestCaseWithTransport |
1913 | @@ -101,13 +102,13 @@ |
1914 | directories.dereference(':this/arg')) |
1915 | |
1916 | def test_lookup_badname(self): |
1917 | - e = self.assertRaises(errors.InvalidLocationAlias, |
1918 | + e = self.assertRaises(InvalidLocationAlias, |
1919 | directories.dereference, ':booga') |
1920 | self.assertEqual('":booga" is not a valid location alias.', |
1921 | str(e)) |
1922 | |
1923 | def test_lookup_badvalue(self): |
1924 | - e = self.assertRaises(errors.UnsetLocationAlias, |
1925 | + e = self.assertRaises(UnsetLocationAlias, |
1926 | directories.dereference, ':parent') |
1927 | self.assertEqual('No parent location assigned.', str(e)) |
1928 | |
1929 | |
1930 | === modified file 'breezy/tests/test_dirstate.py' |
1931 | --- breezy/tests/test_dirstate.py 2017-06-11 01:22:16 +0000 |
1932 | +++ breezy/tests/test_dirstate.py 2017-07-24 01:10:54 +0000 |
1933 | @@ -54,6 +54,16 @@ |
1934 | # set_path_id setting id when state is in memory modified |
1935 | |
1936 | |
1937 | +class ErrorTests(tests.TestCase): |
1938 | + |
1939 | + def test_dirstate_corrupt(self): |
1940 | + error = dirstate.DirstateCorrupt('.bzr/checkout/dirstate', |
1941 | + 'trailing garbage: "x"') |
1942 | + self.assertEqualDiff("The dirstate file (.bzr/checkout/dirstate)" |
1943 | + " appears to be corrupt: trailing garbage: \"x\"", |
1944 | + str(error)) |
1945 | + |
1946 | + |
1947 | load_tests = load_tests_apply_scenarios |
1948 | |
1949 | |
1950 | |
1951 | === modified file 'breezy/tests/test_errors.py' |
1952 | --- breezy/tests/test_errors.py 2017-07-24 01:07:36 +0000 |
1953 | +++ breezy/tests/test_errors.py 2017-07-24 01:10:54 +0000 |
1954 | @@ -63,20 +63,6 @@ |
1955 | "^Filename b?'bad/filen\\\\xe5me' is not valid in your current" |
1956 | " filesystem encoding UTF-8$") |
1957 | |
1958 | - def test_corrupt_dirstate(self): |
1959 | - error = errors.CorruptDirstate('path/to/dirstate', 'the reason why') |
1960 | - self.assertEqualDiff( |
1961 | - "Inconsistency in dirstate file path/to/dirstate.\n" |
1962 | - "Error: the reason why", |
1963 | - str(error)) |
1964 | - |
1965 | - def test_dirstate_corrupt(self): |
1966 | - error = errors.DirstateCorrupt('.bzr/checkout/dirstate', |
1967 | - 'trailing garbage: "x"') |
1968 | - self.assertEqualDiff("The dirstate file (.bzr/checkout/dirstate)" |
1969 | - " appears to be corrupt: trailing garbage: \"x\"", |
1970 | - str(error)) |
1971 | - |
1972 | def test_duplicate_file_id(self): |
1973 | error = errors.DuplicateFileId('a_file_id', 'foo') |
1974 | self.assertEqualDiff('File id {a_file_id} already exists in inventory' |
1975 | @@ -239,25 +225,6 @@ |
1976 | "('key',) which is encoded as 'fulltext'.", |
1977 | str(error)) |
1978 | |
1979 | - def test_unknown_hook(self): |
1980 | - error = errors.UnknownHook("branch", "foo") |
1981 | - self.assertEqualDiff("The branch hook 'foo' is unknown in this version" |
1982 | - " of breezy.", |
1983 | - str(error)) |
1984 | - error = errors.UnknownHook("tree", "bar") |
1985 | - self.assertEqualDiff("The tree hook 'bar' is unknown in this version" |
1986 | - " of breezy.", |
1987 | - str(error)) |
1988 | - |
1989 | - def test_unstackable_branch_format(self): |
1990 | - format = u'foo' |
1991 | - url = "/foo" |
1992 | - error = errors.UnstackableBranchFormat(format, url) |
1993 | - self.assertEqualDiff( |
1994 | - "The branch '/foo'(foo) is not a stackable format. " |
1995 | - "You will need to upgrade the branch to permit branch stacking.", |
1996 | - str(error)) |
1997 | - |
1998 | def test_unstackable_location(self): |
1999 | error = errors.UnstackableLocationError('foo', 'bar') |
2000 | self.assertEqualDiff("The branch 'foo' cannot be stacked on 'bar'.", |
2001 | @@ -501,10 +468,6 @@ |
2002 | err = errors.UnknownFormatError('bar', kind='foo') |
2003 | self.assertEqual("Unknown foo format: 'bar'", str(err)) |
2004 | |
2005 | - def test_unknown_rules(self): |
2006 | - err = errors.UnknownRules(['foo', 'bar']) |
2007 | - self.assertEqual("Unknown rules detected: foo, bar.", str(err)) |
2008 | - |
2009 | def test_tip_change_rejected(self): |
2010 | err = errors.TipChangeRejected(u'Unicode message\N{INTERROBANG}') |
2011 | self.assertEqual( |
2012 | @@ -538,11 +501,6 @@ |
2013 | finally: |
2014 | del err |
2015 | |
2016 | - def test_must_have_working_tree(self): |
2017 | - err = errors.MustHaveWorkingTree('foo', 'bar') |
2018 | - self.assertEqual(str(err), "Branching 'bar'(foo) must create a" |
2019 | - " working tree.") |
2020 | - |
2021 | def test_unresumable_write_group(self): |
2022 | repo = "dummy repo" |
2023 | wg_tokens = ['token'] |
2024 | |
2025 | === modified file 'breezy/tests/test_hooks.py' |
2026 | --- breezy/tests/test_hooks.py 2017-05-30 19:16:23 +0000 |
2027 | +++ breezy/tests/test_hooks.py 2017-07-24 01:10:54 +0000 |
2028 | @@ -26,12 +26,26 @@ |
2029 | from ..hooks import ( |
2030 | HookPoint, |
2031 | Hooks, |
2032 | + UnknownHook, |
2033 | install_lazy_named_hook, |
2034 | known_hooks, |
2035 | known_hooks_key_to_object, |
2036 | ) |
2037 | |
2038 | |
2039 | +class TestErrors(tests.TestCase): |
2040 | + |
2041 | + def test_unknown_hook(self): |
2042 | + error = UnknownHook("branch", "foo") |
2043 | + self.assertEqualDiff("The branch hook 'foo' is unknown in this version" |
2044 | + " of breezy.", |
2045 | + str(error)) |
2046 | + error = UnknownHook("tree", "bar") |
2047 | + self.assertEqualDiff("The tree hook 'bar' is unknown in this version" |
2048 | + " of breezy.", |
2049 | + str(error)) |
2050 | + |
2051 | + |
2052 | class TestHooks(tests.TestCase): |
2053 | |
2054 | def test_docs(self): |
2055 | @@ -76,7 +90,7 @@ |
2056 | |
2057 | def test_install_named_hook_raises_unknown_hook(self): |
2058 | hooks = Hooks("breezy.tests.test_hooks", "some_hooks") |
2059 | - self.assertRaises(errors.UnknownHook, hooks.install_named_hook, 'silly', |
2060 | + self.assertRaises(UnknownHook, hooks.install_named_hook, 'silly', |
2061 | None, "") |
2062 | |
2063 | def test_install_named_hook_appends_known_hook(self): |
2064 | @@ -118,8 +132,7 @@ |
2065 | |
2066 | def test_uninstall_named_hook_raises_unknown_hook(self): |
2067 | hooks = Hooks("breezy.tests.test_hooks", "some_hooks") |
2068 | - self.assertRaises(errors.UnknownHook, hooks.uninstall_named_hook, |
2069 | - 'silly', "") |
2070 | + self.assertRaises(UnknownHook, hooks.uninstall_named_hook, 'silly', "") |
2071 | |
2072 | def test_uninstall_named_hook_old_style(self): |
2073 | hooks = Hooks("breezy.tests.test_hooks", "some_hooks") |
2074 | |
2075 | === modified file 'breezy/tests/test_index.py' |
2076 | --- breezy/tests/test_index.py 2017-06-08 23:30:31 +0000 |
2077 | +++ breezy/tests/test_index.py 2017-07-24 01:10:54 +0000 |
2078 | @@ -22,14 +22,14 @@ |
2079 | transport, |
2080 | ) |
2081 | from ..bzr import ( |
2082 | - index, |
2083 | + index as _mod_index, |
2084 | ) |
2085 | |
2086 | |
2087 | class TestGraphIndexBuilder(tests.TestCaseWithMemoryTransport): |
2088 | |
2089 | def test_build_index_empty(self): |
2090 | - builder = index.GraphIndexBuilder() |
2091 | + builder = _mod_index.GraphIndexBuilder() |
2092 | stream = builder.finish() |
2093 | contents = stream.read() |
2094 | self.assertEqual( |
2095 | @@ -37,7 +37,7 @@ |
2096 | contents) |
2097 | |
2098 | def test_build_index_empty_two_element_keys(self): |
2099 | - builder = index.GraphIndexBuilder(key_elements=2) |
2100 | + builder = _mod_index.GraphIndexBuilder(key_elements=2) |
2101 | stream = builder.finish() |
2102 | contents = stream.read() |
2103 | self.assertEqual( |
2104 | @@ -45,7 +45,7 @@ |
2105 | contents) |
2106 | |
2107 | def test_build_index_one_reference_list_empty(self): |
2108 | - builder = index.GraphIndexBuilder(reference_lists=1) |
2109 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1) |
2110 | stream = builder.finish() |
2111 | contents = stream.read() |
2112 | self.assertEqual( |
2113 | @@ -53,7 +53,7 @@ |
2114 | contents) |
2115 | |
2116 | def test_build_index_two_reference_list_empty(self): |
2117 | - builder = index.GraphIndexBuilder(reference_lists=2) |
2118 | + builder = _mod_index.GraphIndexBuilder(reference_lists=2) |
2119 | stream = builder.finish() |
2120 | contents = stream.read() |
2121 | self.assertEqual( |
2122 | @@ -61,7 +61,7 @@ |
2123 | contents) |
2124 | |
2125 | def test_build_index_one_node_no_refs(self): |
2126 | - builder = index.GraphIndexBuilder() |
2127 | + builder = _mod_index.GraphIndexBuilder() |
2128 | builder.add_node(('akey', ), 'data') |
2129 | stream = builder.finish() |
2130 | contents = stream.read() |
2131 | @@ -70,7 +70,7 @@ |
2132 | "akey\x00\x00\x00data\n\n", contents) |
2133 | |
2134 | def test_build_index_one_node_no_refs_accepts_empty_reflist(self): |
2135 | - builder = index.GraphIndexBuilder() |
2136 | + builder = _mod_index.GraphIndexBuilder() |
2137 | builder.add_node(('akey', ), 'data', ()) |
2138 | stream = builder.finish() |
2139 | contents = stream.read() |
2140 | @@ -82,7 +82,7 @@ |
2141 | # multipart keys are separated by \x00 - because they are fixed length, |
2142 | # not variable this does not cause any issues, and seems clearer to the |
2143 | # author. |
2144 | - builder = index.GraphIndexBuilder(key_elements=2) |
2145 | + builder = _mod_index.GraphIndexBuilder(key_elements=2) |
2146 | builder.add_node(('akey', 'secondpart'), 'data') |
2147 | stream = builder.finish() |
2148 | contents = stream.read() |
2149 | @@ -91,7 +91,7 @@ |
2150 | "akey\x00secondpart\x00\x00\x00data\n\n", contents) |
2151 | |
2152 | def test_add_node_empty_value(self): |
2153 | - builder = index.GraphIndexBuilder() |
2154 | + builder = _mod_index.GraphIndexBuilder() |
2155 | builder.add_node(('akey', ), '') |
2156 | stream = builder.finish() |
2157 | contents = stream.read() |
2158 | @@ -101,7 +101,7 @@ |
2159 | |
2160 | def test_build_index_nodes_sorted(self): |
2161 | # the highest sorted node comes first. |
2162 | - builder = index.GraphIndexBuilder() |
2163 | + builder = _mod_index.GraphIndexBuilder() |
2164 | # use three to have a good chance of glitching dictionary hash |
2165 | # lookups etc. Insert in randomish order that is not correct |
2166 | # and not the reverse of the correct order. |
2167 | @@ -119,7 +119,7 @@ |
2168 | |
2169 | def test_build_index_2_element_key_nodes_sorted(self): |
2170 | # multiple element keys are sorted first-key, second-key. |
2171 | - builder = index.GraphIndexBuilder(key_elements=2) |
2172 | + builder = _mod_index.GraphIndexBuilder(key_elements=2) |
2173 | # use three values of each key element, to have a good chance of |
2174 | # glitching dictionary hash lookups etc. Insert in randomish order that |
2175 | # is not correct and not the reverse of the correct order. |
2176 | @@ -148,7 +148,7 @@ |
2177 | "\n", contents) |
2178 | |
2179 | def test_build_index_reference_lists_are_included_one(self): |
2180 | - builder = index.GraphIndexBuilder(reference_lists=1) |
2181 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1) |
2182 | builder.add_node(('key', ), 'data', ([], )) |
2183 | stream = builder.finish() |
2184 | contents = stream.read() |
2185 | @@ -158,7 +158,7 @@ |
2186 | "\n", contents) |
2187 | |
2188 | def test_build_index_reference_lists_with_2_element_keys(self): |
2189 | - builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2) |
2190 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1, key_elements=2) |
2191 | builder.add_node(('key', 'key2'), 'data', ([], )) |
2192 | stream = builder.finish() |
2193 | contents = stream.read() |
2194 | @@ -168,7 +168,7 @@ |
2195 | "\n", contents) |
2196 | |
2197 | def test_build_index_reference_lists_are_included_two(self): |
2198 | - builder = index.GraphIndexBuilder(reference_lists=2) |
2199 | + builder = _mod_index.GraphIndexBuilder(reference_lists=2) |
2200 | builder.add_node(('key', ), 'data', ([], [])) |
2201 | stream = builder.finish() |
2202 | contents = stream.read() |
2203 | @@ -178,12 +178,12 @@ |
2204 | "\n", contents) |
2205 | |
2206 | def test_clear_cache(self): |
2207 | - builder = index.GraphIndexBuilder(reference_lists=2) |
2208 | + builder = _mod_index.GraphIndexBuilder(reference_lists=2) |
2209 | # This is a no-op, but the api should exist |
2210 | builder.clear_cache() |
2211 | |
2212 | def test_node_references_are_byte_offsets(self): |
2213 | - builder = index.GraphIndexBuilder(reference_lists=1) |
2214 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1) |
2215 | builder.add_node(('reference', ), 'data', ([], )) |
2216 | builder.add_node(('key', ), 'data', ([('reference', )], )) |
2217 | stream = builder.finish() |
2218 | @@ -195,7 +195,7 @@ |
2219 | "\n", contents) |
2220 | |
2221 | def test_node_references_are_cr_delimited(self): |
2222 | - builder = index.GraphIndexBuilder(reference_lists=1) |
2223 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1) |
2224 | builder.add_node(('reference', ), 'data', ([], )) |
2225 | builder.add_node(('reference2', ), 'data', ([], )) |
2226 | builder.add_node(('key', ), 'data', |
2227 | @@ -210,7 +210,7 @@ |
2228 | "\n", contents) |
2229 | |
2230 | def test_multiple_reference_lists_are_tab_delimited(self): |
2231 | - builder = index.GraphIndexBuilder(reference_lists=2) |
2232 | + builder = _mod_index.GraphIndexBuilder(reference_lists=2) |
2233 | builder.add_node(('keference', ), 'data', ([], [])) |
2234 | builder.add_node(('rey', ), 'data', |
2235 | ([('keference', )], [('keference', )])) |
2236 | @@ -223,7 +223,7 @@ |
2237 | "\n", contents) |
2238 | |
2239 | def test_add_node_referencing_missing_key_makes_absent(self): |
2240 | - builder = index.GraphIndexBuilder(reference_lists=1) |
2241 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1) |
2242 | builder.add_node(('rey', ), 'data', |
2243 | ([('beference', ), ('aeference2', )], )) |
2244 | stream = builder.finish() |
2245 | @@ -237,7 +237,7 @@ |
2246 | |
2247 | def test_node_references_three_digits(self): |
2248 | # test the node digit expands as needed. |
2249 | - builder = index.GraphIndexBuilder(reference_lists=1) |
2250 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1) |
2251 | references = [(str(val), ) for val in range(8, -1, -1)] |
2252 | builder.add_node(('2-key', ), '', (references, )) |
2253 | stream = builder.finish() |
2254 | @@ -259,7 +259,7 @@ |
2255 | def test_absent_has_no_reference_overhead(self): |
2256 | # the offsets after an absent record should be correct when there are |
2257 | # >1 reference lists. |
2258 | - builder = index.GraphIndexBuilder(reference_lists=2) |
2259 | + builder = _mod_index.GraphIndexBuilder(reference_lists=2) |
2260 | builder.add_node(('parent', ), '', ([('aail', ), ('zther', )], [])) |
2261 | stream = builder.finish() |
2262 | contents = stream.read() |
2263 | @@ -271,99 +271,99 @@ |
2264 | "\n", contents) |
2265 | |
2266 | def test_add_node_bad_key(self): |
2267 | - builder = index.GraphIndexBuilder() |
2268 | + builder = _mod_index.GraphIndexBuilder() |
2269 | for bad_char in '\t\n\x0b\x0c\r\x00 ': |
2270 | - self.assertRaises(errors.BadIndexKey, builder.add_node, |
2271 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, |
2272 | ('a%skey' % bad_char, ), 'data') |
2273 | - self.assertRaises(errors.BadIndexKey, builder.add_node, |
2274 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, |
2275 | ('', ), 'data') |
2276 | - self.assertRaises(errors.BadIndexKey, builder.add_node, |
2277 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, |
2278 | 'not-a-tuple', 'data') |
2279 | # not enough length |
2280 | - self.assertRaises(errors.BadIndexKey, builder.add_node, |
2281 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, |
2282 | (), 'data') |
2283 | # too long |
2284 | - self.assertRaises(errors.BadIndexKey, builder.add_node, |
2285 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, |
2286 | ('primary', 'secondary'), 'data') |
2287 | # secondary key elements get checked too: |
2288 | - builder = index.GraphIndexBuilder(key_elements=2) |
2289 | + builder = _mod_index.GraphIndexBuilder(key_elements=2) |
2290 | for bad_char in '\t\n\x0b\x0c\r\x00 ': |
2291 | - self.assertRaises(errors.BadIndexKey, builder.add_node, |
2292 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, |
2293 | ('prefix', 'a%skey' % bad_char), 'data') |
2294 | |
2295 | def test_add_node_bad_data(self): |
2296 | - builder = index.GraphIndexBuilder() |
2297 | - self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ), |
2298 | + builder = _mod_index.GraphIndexBuilder() |
2299 | + self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ), |
2300 | 'data\naa') |
2301 | - self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ), |
2302 | + self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ), |
2303 | 'data\x00aa') |
2304 | |
2305 | def test_add_node_bad_mismatched_ref_lists_length(self): |
2306 | - builder = index.GraphIndexBuilder() |
2307 | - self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ), |
2308 | + builder = _mod_index.GraphIndexBuilder() |
2309 | + self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ), |
2310 | 'data aa', ([], )) |
2311 | - builder = index.GraphIndexBuilder(reference_lists=1) |
2312 | - self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ), |
2313 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1) |
2314 | + self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ), |
2315 | 'data aa') |
2316 | - self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ), |
2317 | + self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ), |
2318 | 'data aa', (), ) |
2319 | - self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ), |
2320 | + self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ), |
2321 | 'data aa', ([], [])) |
2322 | - builder = index.GraphIndexBuilder(reference_lists=2) |
2323 | - self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ), |
2324 | + builder = _mod_index.GraphIndexBuilder(reference_lists=2) |
2325 | + self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ), |
2326 | 'data aa') |
2327 | - self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ), |
2328 | + self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ), |
2329 | 'data aa', ([], )) |
2330 | - self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ), |
2331 | + self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ), |
2332 | 'data aa', ([], [], [])) |
2333 | |
2334 | def test_add_node_bad_key_in_reference_lists(self): |
2335 | # first list, first key - trivial |
2336 | - builder = index.GraphIndexBuilder(reference_lists=1) |
2337 | - self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ), |
2338 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1) |
2339 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ), |
2340 | 'data aa', ([('a key', )], )) |
2341 | # references keys must be tuples too |
2342 | - self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ), |
2343 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ), |
2344 | 'data aa', (['not-a-tuple'], )) |
2345 | # not enough length |
2346 | - self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ), |
2347 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ), |
2348 | 'data aa', ([()], )) |
2349 | # too long |
2350 | - self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ), |
2351 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ), |
2352 | 'data aa', ([('primary', 'secondary')], )) |
2353 | # need to check more than the first key in the list |
2354 | - self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ), |
2355 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ), |
2356 | 'data aa', ([('agoodkey', ), ('that is a bad key', )], )) |
2357 | # and if there is more than one list it should be getting checked |
2358 | # too |
2359 | - builder = index.GraphIndexBuilder(reference_lists=2) |
2360 | - self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ), |
2361 | + builder = _mod_index.GraphIndexBuilder(reference_lists=2) |
2362 | + self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ), |
2363 | 'data aa', ([], ['a bad key'])) |
2364 | |
2365 | def test_add_duplicate_key(self): |
2366 | - builder = index.GraphIndexBuilder() |
2367 | + builder = _mod_index.GraphIndexBuilder() |
2368 | builder.add_node(('key', ), 'data') |
2369 | - self.assertRaises(errors.BadIndexDuplicateKey, |
2370 | + self.assertRaises(_mod_index.BadIndexDuplicateKey, |
2371 | builder.add_node, ('key', ), 'data') |
2372 | |
2373 | def test_add_duplicate_key_2_elements(self): |
2374 | - builder = index.GraphIndexBuilder(key_elements=2) |
2375 | + builder = _mod_index.GraphIndexBuilder(key_elements=2) |
2376 | builder.add_node(('key', 'key'), 'data') |
2377 | - self.assertRaises(errors.BadIndexDuplicateKey, builder.add_node, |
2378 | + self.assertRaises(_mod_index.BadIndexDuplicateKey, builder.add_node, |
2379 | ('key', 'key'), 'data') |
2380 | |
2381 | def test_add_key_after_referencing_key(self): |
2382 | - builder = index.GraphIndexBuilder(reference_lists=1) |
2383 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1) |
2384 | builder.add_node(('key', ), 'data', ([('reference', )], )) |
2385 | builder.add_node(('reference', ), 'data', ([],)) |
2386 | |
2387 | def test_add_key_after_referencing_key_2_elements(self): |
2388 | - builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2) |
2389 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1, key_elements=2) |
2390 | builder.add_node(('k', 'ey'), 'data', ([('reference', 'tokey')], )) |
2391 | builder.add_node(('reference', 'tokey'), 'data', ([],)) |
2392 | |
2393 | def test_set_optimize(self): |
2394 | - builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2) |
2395 | + builder = _mod_index.GraphIndexBuilder(reference_lists=1, key_elements=2) |
2396 | builder.set_optimize(for_size=True) |
2397 | self.assertTrue(builder._optimize_for_size) |
2398 | builder.set_optimize(for_size=False) |
2399 | @@ -387,24 +387,24 @@ |
2400 | return nodes |
2401 | |
2402 | def make_index(self, ref_lists=0, key_elements=1, nodes=[]): |
2403 | - builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements) |
2404 | + builder = _mod_index.GraphIndexBuilder(ref_lists, key_elements=key_elements) |
2405 | for key, value, references in nodes: |
2406 | builder.add_node(key, value, references) |
2407 | stream = builder.finish() |
2408 | trans = transport.get_transport_from_url('trace+' + self.get_url()) |
2409 | size = trans.put_file('index', stream) |
2410 | - return index.GraphIndex(trans, 'index', size) |
2411 | + return _mod_index.GraphIndex(trans, 'index', size) |
2412 | |
2413 | def make_index_with_offset(self, ref_lists=0, key_elements=1, nodes=[], |
2414 | offset=0): |
2415 | - builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements) |
2416 | + builder = _mod_index.GraphIndexBuilder(ref_lists, key_elements=key_elements) |
2417 | for key, value, references in nodes: |
2418 | builder.add_node(key, value, references) |
2419 | content = builder.finish().read() |
2420 | size = len(content) |
2421 | trans = self.get_transport() |
2422 | trans.put_bytes('index', (' '*offset) + content) |
2423 | - return index.GraphIndex(trans, 'index', size, offset=offset) |
2424 | + return _mod_index.GraphIndex(trans, 'index', size, offset=offset) |
2425 | |
2426 | def test_clear_cache(self): |
2427 | index = self.make_index() |
2428 | @@ -415,7 +415,7 @@ |
2429 | def test_open_bad_index_no_error(self): |
2430 | trans = self.get_transport() |
2431 | trans.put_bytes('name', "not an index\n") |
2432 | - idx = index.GraphIndex(trans, 'name', 13) |
2433 | + idx = _mod_index.GraphIndex(trans, 'name', 13) |
2434 | |
2435 | def test_with_offset(self): |
2436 | nodes = self.make_nodes(200) |
2437 | @@ -838,22 +838,22 @@ |
2438 | |
2439 | def test_iter_missing_entry_empty_no_size(self): |
2440 | idx = self.make_index() |
2441 | - idx = index.GraphIndex(idx._transport, 'index', None) |
2442 | + idx = _mod_index.GraphIndex(idx._transport, 'index', None) |
2443 | self.assertEqual([], list(idx.iter_entries([('a', )]))) |
2444 | |
2445 | def test_iter_key_prefix_1_element_key_None(self): |
2446 | index = self.make_index() |
2447 | - self.assertRaises(errors.BadIndexKey, list, |
2448 | + self.assertRaises(_mod_index.BadIndexKey, list, |
2449 | index.iter_entries_prefix([(None, )])) |
2450 | |
2451 | def test_iter_key_prefix_wrong_length(self): |
2452 | index = self.make_index() |
2453 | - self.assertRaises(errors.BadIndexKey, list, |
2454 | + self.assertRaises(_mod_index.BadIndexKey, list, |
2455 | index.iter_entries_prefix([('foo', None)])) |
2456 | index = self.make_index(key_elements=2) |
2457 | - self.assertRaises(errors.BadIndexKey, list, |
2458 | + self.assertRaises(_mod_index.BadIndexKey, list, |
2459 | index.iter_entries_prefix([('foo', )])) |
2460 | - self.assertRaises(errors.BadIndexKey, list, |
2461 | + self.assertRaises(_mod_index.BadIndexKey, list, |
2462 | index.iter_entries_prefix([('foo', None, None)])) |
2463 | |
2464 | def test_iter_key_prefix_1_key_element_no_refs(self): |
2465 | @@ -935,8 +935,8 @@ |
2466 | def test_validate_bad_index_errors(self): |
2467 | trans = self.get_transport() |
2468 | trans.put_bytes('name', "not an index\n") |
2469 | - idx = index.GraphIndex(trans, 'name', 13) |
2470 | - self.assertRaises(errors.BadIndexFormatSignature, idx.validate) |
2471 | + idx = _mod_index.GraphIndex(trans, 'name', 13) |
2472 | + self.assertRaises(_mod_index.BadIndexFormatSignature, idx.validate) |
2473 | |
2474 | def test_validate_bad_node_refs(self): |
2475 | idx = self.make_index(2) |
2476 | @@ -945,7 +945,7 @@ |
2477 | # change the options line to end with a rather than a parseable number |
2478 | new_content = content[:-2] + 'a\n\n' |
2479 | trans.put_bytes('index', new_content) |
2480 | - self.assertRaises(errors.BadIndexOptions, idx.validate) |
2481 | + self.assertRaises(_mod_index.BadIndexOptions, idx.validate) |
2482 | |
2483 | def test_validate_missing_end_line_empty(self): |
2484 | index = self.make_index(2) |
2485 | @@ -953,7 +953,7 @@ |
2486 | content = trans.get_bytes('index') |
2487 | # truncate the last byte |
2488 | trans.put_bytes('index', content[:-1]) |
2489 | - self.assertRaises(errors.BadIndexData, index.validate) |
2490 | + self.assertRaises(_mod_index.BadIndexData, index.validate) |
2491 | |
2492 | def test_validate_missing_end_line_nonempty(self): |
2493 | index = self.make_index(2, nodes=[(('key', ), '', ([], []))]) |
2494 | @@ -961,7 +961,7 @@ |
2495 | content = trans.get_bytes('index') |
2496 | # truncate the last byte |
2497 | trans.put_bytes('index', content[:-1]) |
2498 | - self.assertRaises(errors.BadIndexData, index.validate) |
2499 | + self.assertRaises(_mod_index.BadIndexData, index.validate) |
2500 | |
2501 | def test_validate_empty(self): |
2502 | index = self.make_index() |
2503 | @@ -1056,25 +1056,25 @@ |
2504 | self.assertEqual(set(), search_keys) |
2505 | |
2506 | def test_supports_unlimited_cache(self): |
2507 | - builder = index.GraphIndexBuilder(0, key_elements=1) |
2508 | + builder = _mod_index.GraphIndexBuilder(0, key_elements=1) |
2509 | stream = builder.finish() |
2510 | trans = self.get_transport() |
2511 | size = trans.put_file('index', stream) |
2512 | # It doesn't matter what unlimited_cache does here, just that it can be |
2513 | # passed |
2514 | - idx = index.GraphIndex(trans, 'index', size, unlimited_cache=True) |
2515 | + idx = _mod_index.GraphIndex(trans, 'index', size, unlimited_cache=True) |
2516 | |
2517 | |
2518 | class TestCombinedGraphIndex(tests.TestCaseWithMemoryTransport): |
2519 | |
2520 | def make_index(self, name, ref_lists=0, key_elements=1, nodes=[]): |
2521 | - builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements) |
2522 | + builder = _mod_index.GraphIndexBuilder(ref_lists, key_elements=key_elements) |
2523 | for key, value, references in nodes: |
2524 | builder.add_node(key, value, references) |
2525 | stream = builder.finish() |
2526 | trans = self.get_transport() |
2527 | size = trans.put_file(name, stream) |
2528 | - return index.GraphIndex(trans, name, size) |
2529 | + return _mod_index.GraphIndex(trans, name, size) |
2530 | |
2531 | def make_combined_index_with_missing(self, missing=['1', '2']): |
2532 | """Create a CombinedGraphIndex which will have missing indexes. |
2533 | @@ -1103,7 +1103,7 @@ |
2534 | reload_counter[1] += 1 |
2535 | idx._indices[:] = new_indices |
2536 | return True |
2537 | - idx = index.CombinedGraphIndex([idx1, idx2], reload_func=reload) |
2538 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2], reload_func=reload) |
2539 | trans = self.get_transport() |
2540 | for fname in missing: |
2541 | trans.delete(fname) |
2542 | @@ -1111,11 +1111,11 @@ |
2543 | |
2544 | def test_open_missing_index_no_error(self): |
2545 | trans = self.get_transport() |
2546 | - idx1 = index.GraphIndex(trans, 'missing', 100) |
2547 | - idx = index.CombinedGraphIndex([idx1]) |
2548 | + idx1 = _mod_index.GraphIndex(trans, 'missing', 100) |
2549 | + idx = _mod_index.CombinedGraphIndex([idx1]) |
2550 | |
2551 | def test_add_index(self): |
2552 | - idx = index.CombinedGraphIndex([]) |
2553 | + idx = _mod_index.CombinedGraphIndex([]) |
2554 | idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())]) |
2555 | idx.insert_index(0, idx1) |
2556 | self.assertEqual([(idx1, ('key', ), '')], |
2557 | @@ -1136,7 +1136,7 @@ |
2558 | log.append(self._index) |
2559 | return self._index.clear_cache() |
2560 | |
2561 | - idx = index.CombinedGraphIndex([]) |
2562 | + idx = _mod_index.CombinedGraphIndex([]) |
2563 | idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())]) |
2564 | idx.insert_index(0, ClearCacheProxy(idx1)) |
2565 | idx2 = self.make_index('name', 0, nodes=[(('key', ), '', ())]) |
2566 | @@ -1146,24 +1146,24 @@ |
2567 | self.assertEqual(sorted([idx1, idx2]), sorted(log)) |
2568 | |
2569 | def test_iter_all_entries_empty(self): |
2570 | - idx = index.CombinedGraphIndex([]) |
2571 | + idx = _mod_index.CombinedGraphIndex([]) |
2572 | self.assertEqual([], list(idx.iter_all_entries())) |
2573 | |
2574 | def test_iter_all_entries_children_empty(self): |
2575 | idx1 = self.make_index('name') |
2576 | - idx = index.CombinedGraphIndex([idx1]) |
2577 | + idx = _mod_index.CombinedGraphIndex([idx1]) |
2578 | self.assertEqual([], list(idx.iter_all_entries())) |
2579 | |
2580 | def test_iter_all_entries_simple(self): |
2581 | idx1 = self.make_index('name', nodes=[(('name', ), 'data', ())]) |
2582 | - idx = index.CombinedGraphIndex([idx1]) |
2583 | + idx = _mod_index.CombinedGraphIndex([idx1]) |
2584 | self.assertEqual([(idx1, ('name', ), 'data')], |
2585 | list(idx.iter_all_entries())) |
2586 | |
2587 | def test_iter_all_entries_two_indices(self): |
2588 | idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())]) |
2589 | idx2 = self.make_index('name2', nodes=[(('2', ), '', ())]) |
2590 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2591 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2592 | self.assertEqual([(idx1, ('name', ), 'data'), |
2593 | (idx2, ('2', ), '')], |
2594 | list(idx.iter_all_entries())) |
2595 | @@ -1171,14 +1171,14 @@ |
2596 | def test_iter_entries_two_indices_dup_key(self): |
2597 | idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())]) |
2598 | idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())]) |
2599 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2600 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2601 | self.assertEqual([(idx1, ('name', ), 'data')], |
2602 | list(idx.iter_entries([('name', )]))) |
2603 | |
2604 | def test_iter_all_entries_two_indices_dup_key(self): |
2605 | idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())]) |
2606 | idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())]) |
2607 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2608 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2609 | self.assertEqual([(idx1, ('name', ), 'data')], |
2610 | list(idx.iter_all_entries())) |
2611 | |
2612 | @@ -1188,7 +1188,7 @@ |
2613 | idx2 = self.make_index('2', 1, key_elements=2, nodes=[ |
2614 | (('name', 'fin2'), 'beta', ([], )), |
2615 | (('ref', 'erence'), 'refdata', ([], ))]) |
2616 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2617 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2618 | self.assertEqual({(idx1, ('name', 'fin1'), 'data', |
2619 | ((('ref', 'erence'),),)), |
2620 | (idx2, ('ref', 'erence'), 'refdata', ((), ))}, |
2621 | @@ -1200,19 +1200,19 @@ |
2622 | set(idx.iter_entries_prefix([('name', None)]))) |
2623 | |
2624 | def test_iter_nothing_empty(self): |
2625 | - idx = index.CombinedGraphIndex([]) |
2626 | + idx = _mod_index.CombinedGraphIndex([]) |
2627 | self.assertEqual([], list(idx.iter_entries([]))) |
2628 | |
2629 | def test_iter_nothing_children_empty(self): |
2630 | idx1 = self.make_index('name') |
2631 | - idx = index.CombinedGraphIndex([idx1]) |
2632 | + idx = _mod_index.CombinedGraphIndex([idx1]) |
2633 | self.assertEqual([], list(idx.iter_entries([]))) |
2634 | |
2635 | def test_iter_all_keys(self): |
2636 | idx1 = self.make_index('1', 1, nodes=[(('name', ), 'data', |
2637 | ([('ref', )], ))]) |
2638 | idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ((), ))]) |
2639 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2640 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2641 | self.assertEqual({(idx1, ('name', ), 'data', ((('ref', ), ), )), |
2642 | (idx2, ('ref', ), 'refdata', ((), ))}, |
2643 | set(idx.iter_entries([('name', ), ('ref', )]))) |
2644 | @@ -1222,41 +1222,41 @@ |
2645 | ([('ref', )], )), |
2646 | (('ref', ), 'refdata', ([], ))]) |
2647 | idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ([], ))]) |
2648 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2649 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2650 | self.assertEqual({(idx1, ('name', ), 'data', ((('ref',),),)), |
2651 | (idx1, ('ref', ), 'refdata', ((), ))}, |
2652 | set(idx.iter_entries([('name', ), ('ref', )]))) |
2653 | |
2654 | def test_iter_missing_entry_empty(self): |
2655 | - idx = index.CombinedGraphIndex([]) |
2656 | + idx = _mod_index.CombinedGraphIndex([]) |
2657 | self.assertEqual([], list(idx.iter_entries([('a', )]))) |
2658 | |
2659 | def test_iter_missing_entry_one_index(self): |
2660 | idx1 = self.make_index('1') |
2661 | - idx = index.CombinedGraphIndex([idx1]) |
2662 | + idx = _mod_index.CombinedGraphIndex([idx1]) |
2663 | self.assertEqual([], list(idx.iter_entries([('a', )]))) |
2664 | |
2665 | def test_iter_missing_entry_two_index(self): |
2666 | idx1 = self.make_index('1') |
2667 | idx2 = self.make_index('2') |
2668 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2669 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2670 | self.assertEqual([], list(idx.iter_entries([('a', )]))) |
2671 | |
2672 | def test_iter_entry_present_one_index_only(self): |
2673 | idx1 = self.make_index('1', nodes=[(('key', ), '', ())]) |
2674 | idx2 = self.make_index('2', nodes=[]) |
2675 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2676 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2677 | self.assertEqual([(idx1, ('key', ), '')], |
2678 | list(idx.iter_entries([('key', )]))) |
2679 | # and in the other direction |
2680 | - idx = index.CombinedGraphIndex([idx2, idx1]) |
2681 | + idx = _mod_index.CombinedGraphIndex([idx2, idx1]) |
2682 | self.assertEqual([(idx1, ('key', ), '')], |
2683 | list(idx.iter_entries([('key', )]))) |
2684 | |
2685 | def test_key_count_empty(self): |
2686 | idx1 = self.make_index('1', nodes=[]) |
2687 | idx2 = self.make_index('2', nodes=[]) |
2688 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2689 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2690 | self.assertEqual(0, idx.key_count()) |
2691 | |
2692 | def test_key_count_sums_index_keys(self): |
2693 | @@ -1264,18 +1264,18 @@ |
2694 | (('1',), '', ()), |
2695 | (('2',), '', ())]) |
2696 | idx2 = self.make_index('2', nodes=[(('1',), '', ())]) |
2697 | - idx = index.CombinedGraphIndex([idx1, idx2]) |
2698 | + idx = _mod_index.CombinedGraphIndex([idx1, idx2]) |
2699 | self.assertEqual(3, idx.key_count()) |
2700 | |
2701 | def test_validate_bad_child_index_errors(self): |
2702 | trans = self.get_transport() |
2703 | trans.put_bytes('name', "not an index\n") |
2704 | - idx1 = index.GraphIndex(trans, 'name', 13) |
2705 | - idx = index.CombinedGraphIndex([idx1]) |
2706 | - self.assertRaises(errors.BadIndexFormatSignature, idx.validate) |
2707 | + idx1 = _mod_index.GraphIndex(trans, 'name', 13) |
2708 | + idx = _mod_index.CombinedGraphIndex([idx1]) |
2709 | + self.assertRaises(_mod_index.BadIndexFormatSignature, idx.validate) |
2710 | |
2711 | def test_validate_empty(self): |
2712 | - idx = index.CombinedGraphIndex([]) |
2713 | + idx = _mod_index.CombinedGraphIndex([]) |
2714 | idx.validate() |
2715 | |
2716 | def test_key_count_reloads(self): |
2717 | @@ -1403,7 +1403,7 @@ |
2718 | def test_reorder_after_iter_entries(self): |
2719 | # Four indices: [key1] in idx1, [key2,key3] in idx2, [] in idx3, |
2720 | # [key4] in idx4. |
2721 | - idx = index.CombinedGraphIndex([]) |
2722 | + idx = _mod_index.CombinedGraphIndex([]) |
2723 | idx.insert_index(0, self.make_index_with_simple_nodes('1'), '1') |
2724 | idx.insert_index(1, self.make_index_with_simple_nodes('2'), '2') |
2725 | idx.insert_index(2, self.make_index_with_simple_nodes('3'), '3') |
2726 | @@ -1420,8 +1420,8 @@ |
2727 | def test_reorder_propagates_to_siblings(self): |
2728 | # Two CombinedGraphIndex objects, with the same number of indicies with |
2729 | # matching names. |
2730 | - cgi1 = index.CombinedGraphIndex([]) |
2731 | - cgi2 = index.CombinedGraphIndex([]) |
2732 | + cgi1 = _mod_index.CombinedGraphIndex([]) |
2733 | + cgi2 = _mod_index.CombinedGraphIndex([]) |
2734 | cgi1.insert_index(0, self.make_index_with_simple_nodes('1-1'), 'one') |
2735 | cgi1.insert_index(1, self.make_index_with_simple_nodes('1-2'), 'two') |
2736 | cgi2.insert_index(0, self.make_index_with_simple_nodes('2-1'), 'one') |
2737 | @@ -1465,7 +1465,7 @@ |
2738 | (key3, 'value', ([key2],)), |
2739 | (key4, 'value', ([key3],)), |
2740 | ]) |
2741 | - c_index = index.CombinedGraphIndex([index1, index2]) |
2742 | + c_index = _mod_index.CombinedGraphIndex([index1, index2]) |
2743 | parent_map, missing_keys = c_index.find_ancestry([key1], 0) |
2744 | self.assertEqual({key1: ()}, parent_map) |
2745 | self.assertEqual(set(), missing_keys) |
2746 | @@ -1488,7 +1488,7 @@ |
2747 | index2 = self.make_index('34', ref_lists=1, nodes=[ |
2748 | (key3, 'value', ([key2],)), |
2749 | ]) |
2750 | - c_index = index.CombinedGraphIndex([index1, index2]) |
2751 | + c_index = _mod_index.CombinedGraphIndex([index1, index2]) |
2752 | # Searching for a key which is actually not present at all should |
2753 | # eventually converge |
2754 | parent_map, missing_keys = c_index.find_ancestry([key4], 0) |
2755 | @@ -1496,7 +1496,7 @@ |
2756 | self.assertEqual({key4}, missing_keys) |
2757 | |
2758 | def test_find_ancestors_no_indexes(self): |
2759 | - c_index = index.CombinedGraphIndex([]) |
2760 | + c_index = _mod_index.CombinedGraphIndex([]) |
2761 | key1 = ('key-1',) |
2762 | parent_map, missing_keys = c_index.find_ancestry([key1], 0) |
2763 | self.assertEqual({}, parent_map) |
2764 | @@ -1514,7 +1514,7 @@ |
2765 | index2 = self.make_index('34', ref_lists=1, nodes=[ |
2766 | (key4, 'value', ([key2, key3],)), |
2767 | ]) |
2768 | - c_index = index.CombinedGraphIndex([index1, index2]) |
2769 | + c_index = _mod_index.CombinedGraphIndex([index1, index2]) |
2770 | # Searching for a key which is actually not present at all should |
2771 | # eventually converge |
2772 | parent_map, missing_keys = c_index.find_ancestry([key4], 0) |
2773 | @@ -1536,7 +1536,7 @@ |
2774 | class TestInMemoryGraphIndex(tests.TestCaseWithMemoryTransport): |
2775 | |
2776 | def make_index(self, ref_lists=0, key_elements=1, nodes=[]): |
2777 | - result = index.InMemoryGraphIndex(ref_lists, key_elements=key_elements) |
2778 | + result = _mod_index.InMemoryGraphIndex(ref_lists, key_elements=key_elements) |
2779 | result.add_nodes(nodes) |
2780 | return result |
2781 | |
2782 | @@ -1667,13 +1667,13 @@ |
2783 | |
2784 | def make_index(self, ref_lists=1, key_elements=2, nodes=[], |
2785 | add_callback=False): |
2786 | - result = index.InMemoryGraphIndex(ref_lists, key_elements=key_elements) |
2787 | + result = _mod_index.InMemoryGraphIndex(ref_lists, key_elements=key_elements) |
2788 | result.add_nodes(nodes) |
2789 | if add_callback: |
2790 | add_nodes_callback = result.add_nodes |
2791 | else: |
2792 | add_nodes_callback = None |
2793 | - adapter = index.GraphIndexPrefixAdapter( |
2794 | + adapter = _mod_index.GraphIndexPrefixAdapter( |
2795 | result, ('prefix', ), key_elements - 1, |
2796 | add_nodes_callback=add_nodes_callback) |
2797 | return result, adapter |
2798 | @@ -1698,18 +1698,18 @@ |
2799 | set(index.iter_all_entries())) |
2800 | |
2801 | def test_construct(self): |
2802 | - idx = index.InMemoryGraphIndex() |
2803 | - adapter = index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1) |
2804 | + idx = _mod_index.InMemoryGraphIndex() |
2805 | + adapter = _mod_index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1) |
2806 | |
2807 | def test_construct_with_callback(self): |
2808 | - idx = index.InMemoryGraphIndex() |
2809 | - adapter = index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1, |
2810 | + idx = _mod_index.InMemoryGraphIndex() |
2811 | + adapter = _mod_index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1, |
2812 | idx.add_nodes) |
2813 | |
2814 | def test_iter_all_entries_cross_prefix_map_errors(self): |
2815 | index, adapter = self.make_index(nodes=[ |
2816 | (('prefix', 'key1'), 'data1', ((('prefixaltered', 'key2'),),))]) |
2817 | - self.assertRaises(errors.BadIndexData, list, adapter.iter_all_entries()) |
2818 | + self.assertRaises(_mod_index.BadIndexData, list, adapter.iter_all_entries()) |
2819 | |
2820 | def test_iter_all_entries(self): |
2821 | index, adapter = self.make_index(nodes=[ |
2822 | |
2823 | === modified file 'breezy/tests/test_msgeditor.py' |
2824 | --- breezy/tests/test_msgeditor.py 2017-06-10 00:17:06 +0000 |
2825 | +++ breezy/tests/test_msgeditor.py 2017-07-24 01:10:54 +0000 |
2826 | @@ -339,7 +339,7 @@ |
2827 | self.make_fake_editor(message=char) |
2828 | |
2829 | working_tree = self.make_uncommitted_tree() |
2830 | - self.assertRaises(errors.BadCommitMessageEncoding, |
2831 | + self.assertRaises(msgeditor.BadCommitMessageEncoding, |
2832 | msgeditor.edit_commit_message, '') |
2833 | |
2834 | def test_set_commit_message_no_hooks(self): |
2835 | |
2836 | === modified file 'breezy/tests/test_osutils.py' |
2837 | --- breezy/tests/test_osutils.py 2017-06-15 00:39:26 +0000 |
2838 | +++ breezy/tests/test_osutils.py 2017-07-24 01:10:54 +0000 |
2839 | @@ -404,7 +404,7 @@ |
2840 | self.assertFormatedDelta('2 seconds in the future', -2) |
2841 | |
2842 | def test_format_date(self): |
2843 | - self.assertRaises(errors.UnsupportedTimezoneFormat, |
2844 | + self.assertRaises(osutils.UnsupportedTimezoneFormat, |
2845 | osutils.format_date, 0, timezone='foo') |
2846 | self.assertIsInstance(osutils.format_date(0), str) |
2847 | self.assertIsInstance(osutils.format_local_date(0), unicode) |
2848 | |
2849 | === modified file 'breezy/tests/test_reconfigure.py' |
2850 | --- breezy/tests/test_reconfigure.py 2017-06-10 16:40:42 +0000 |
2851 | +++ breezy/tests/test_reconfigure.py 2017-07-24 01:10:54 +0000 |
2852 | @@ -62,7 +62,7 @@ |
2853 | |
2854 | def test_branch_to_branch(self): |
2855 | branch = self.make_branch('branch') |
2856 | - self.assertRaises(errors.AlreadyBranch, |
2857 | + self.assertRaises(reconfigure.AlreadyBranch, |
2858 | reconfigure.Reconfigure.to_branch, branch.controldir) |
2859 | |
2860 | def test_repo_to_branch(self): |
2861 | @@ -142,13 +142,13 @@ |
2862 | |
2863 | def test_tree_to_tree(self): |
2864 | tree = self.make_branch_and_tree('tree') |
2865 | - self.assertRaises(errors.AlreadyTree, reconfigure.Reconfigure.to_tree, |
2866 | - tree.controldir) |
2867 | + self.assertRaises(reconfigure.AlreadyTree, |
2868 | + reconfigure.Reconfigure.to_tree, tree.controldir) |
2869 | |
2870 | def test_select_bind_location(self): |
2871 | branch = self.make_branch('branch') |
2872 | reconfiguration = reconfigure.Reconfigure(branch.controldir) |
2873 | - self.assertRaises(errors.NoBindLocation, |
2874 | + self.assertRaises(reconfigure.NoBindLocation, |
2875 | reconfiguration._select_bind_location) |
2876 | branch.set_parent('http://parent') |
2877 | reconfiguration = reconfigure.Reconfigure(branch.controldir) |
2878 | @@ -189,7 +189,7 @@ |
2879 | |
2880 | tree = self.make_branch_and_tree('tree') |
2881 | reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir) |
2882 | - self.assertRaises(errors.NoBindLocation, reconfiguration.apply) |
2883 | + self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply) |
2884 | # setting a parent allows it to become a checkout |
2885 | tree.branch.set_parent(parent.base) |
2886 | reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir) |
2887 | @@ -208,7 +208,7 @@ |
2888 | tree = self.make_branch_and_tree('tree') |
2889 | reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
2890 | tree.controldir) |
2891 | - self.assertRaises(errors.NoBindLocation, reconfiguration.apply) |
2892 | + self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply) |
2893 | # setting a parent allows it to become a checkout |
2894 | tree.branch.set_parent(parent.base) |
2895 | reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
2896 | @@ -223,7 +223,7 @@ |
2897 | def test_checkout_to_checkout(self): |
2898 | parent = self.make_branch('parent') |
2899 | checkout = parent.create_checkout('checkout') |
2900 | - self.assertRaises(errors.AlreadyCheckout, |
2901 | + self.assertRaises(reconfigure.AlreadyCheckout, |
2902 | reconfigure.Reconfigure.to_checkout, checkout.controldir) |
2903 | |
2904 | def make_unsynced_checkout(self): |
2905 | @@ -236,7 +236,7 @@ |
2906 | |
2907 | def test_unsynced_checkout_to_lightweight(self): |
2908 | checkout, parent, reconfiguration = self.make_unsynced_checkout() |
2909 | - self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply) |
2910 | + self.assertRaises(reconfigure.UnsyncedBranches, reconfiguration.apply) |
2911 | |
2912 | def test_synced_checkout_to_lightweight(self): |
2913 | checkout, parent, reconfiguration = self.make_unsynced_checkout() |
2914 | @@ -294,7 +294,7 @@ |
2915 | def test_lightweight_checkout_to_lightweight_checkout(self): |
2916 | parent = self.make_branch('parent') |
2917 | checkout = parent.create_checkout('checkout', lightweight=True) |
2918 | - self.assertRaises(errors.AlreadyLightweightCheckout, |
2919 | + self.assertRaises(reconfigure.AlreadyLightweightCheckout, |
2920 | reconfigure.Reconfigure.to_lightweight_checkout, |
2921 | checkout.controldir) |
2922 | |
2923 | @@ -308,7 +308,7 @@ |
2924 | repo = self.make_repository('repo', shared=True) |
2925 | reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
2926 | repo.controldir) |
2927 | - self.assertRaises(errors.NoBindLocation, reconfiguration.apply) |
2928 | + self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply) |
2929 | branch = self.make_branch('branch') |
2930 | reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
2931 | repo.controldir, 'branch') |
2932 | @@ -364,7 +364,7 @@ |
2933 | |
2934 | def test_use_shared_to_use_shared(self): |
2935 | tree = self.make_repository_tree() |
2936 | - self.assertRaises(errors.AlreadyUsingShared, |
2937 | + self.assertRaises(reconfigure.AlreadyUsingShared, |
2938 | reconfigure.Reconfigure.to_use_shared, tree.controldir) |
2939 | |
2940 | def test_use_shared_to_standalone(self): |
2941 | @@ -389,7 +389,7 @@ |
2942 | |
2943 | def test_standalone_to_standalone(self): |
2944 | tree = self.make_branch_and_tree('tree') |
2945 | - self.assertRaises(errors.AlreadyStandalone, |
2946 | + self.assertRaises(reconfigure.AlreadyStandalone, |
2947 | reconfigure.Reconfigure.to_standalone, tree.controldir) |
2948 | |
2949 | def make_unsynced_branch_reconfiguration(self): |
2950 | @@ -401,7 +401,7 @@ |
2951 | |
2952 | def test_unsynced_branch_to_lightweight_checkout_unforced(self): |
2953 | reconfiguration = self.make_unsynced_branch_reconfiguration() |
2954 | - self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply) |
2955 | + self.assertRaises(reconfigure.UnsyncedBranches, reconfiguration.apply) |
2956 | |
2957 | def test_unsynced_branch_to_lightweight_checkout_forced(self): |
2958 | reconfiguration = self.make_unsynced_branch_reconfiguration() |
2959 | @@ -428,21 +428,21 @@ |
2960 | |
2961 | def test_make_with_trees_already_with_trees(self): |
2962 | repo = self.make_repository_with_without_trees(True) |
2963 | - e = self.assertRaises(errors.AlreadyWithTrees, |
2964 | + e = self.assertRaises(reconfiure.AlreadyWithTrees, |
2965 | reconfigure.Reconfigure.set_repository_trees, repo.controldir, True) |
2966 | self.assertContainsRe(str(e), |
2967 | r"Shared repository '.*' already creates working trees.") |
2968 | |
2969 | def test_make_without_trees_already_no_trees(self): |
2970 | repo = self.make_repository_with_without_trees(False) |
2971 | - e = self.assertRaises(errors.AlreadyWithNoTrees, |
2972 | + e = self.assertRaises(reconfigure.AlreadyWithNoTrees, |
2973 | reconfigure.Reconfigure.set_repository_trees, repo.controldir, False) |
2974 | self.assertContainsRe(str(e), |
2975 | r"Shared repository '.*' already doesn't create working trees.") |
2976 | |
2977 | def test_repository_tree_reconfiguration_not_supported(self): |
2978 | tree = self.make_branch_and_tree('tree') |
2979 | - e = self.assertRaises(errors.ReconfigurationNotSupported, |
2980 | + e = self.assertRaises(reconfigure.ReconfigurationNotSupported, |
2981 | reconfigure.Reconfigure.set_repository_trees, tree.controldir, None) |
2982 | self.assertContainsRe(str(e), |
2983 | r"Requested reconfiguration of '.*' is not supported.") |
2984 | |
2985 | === modified file 'breezy/tests/test_rules.py' |
2986 | --- breezy/tests/test_rules.py 2017-05-21 18:10:28 +0000 |
2987 | +++ breezy/tests/test_rules.py 2017-07-24 01:10:54 +0000 |
2988 | @@ -19,12 +19,18 @@ |
2989 | import sys |
2990 | |
2991 | from breezy import ( |
2992 | - errors, |
2993 | rules, |
2994 | tests, |
2995 | ) |
2996 | |
2997 | |
2998 | +class ErrorTests(tests.TestCase): |
2999 | + |
3000 | + def test_unknown_rules(self): |
3001 | + err = rules.UnknownRules(['foo', 'bar']) |
3002 | + self.assertEqual("Unknown rules detected: foo, bar.", str(err)) |
3003 | + |
3004 | + |
3005 | class TestIniBasedRulesSearcher(tests.TestCase): |
3006 | |
3007 | def make_searcher(self, text): |
3008 | @@ -36,8 +42,8 @@ |
3009 | return rules._IniBasedRulesSearcher(lines) |
3010 | |
3011 | def test_unknown_namespace(self): |
3012 | - self.assertRaises(errors.UnknownRules, rules._IniBasedRulesSearcher, |
3013 | - ["[junk]", "foo=bar"]) |
3014 | + self.assertRaises(rules.UnknownRules, rules._IniBasedRulesSearcher, |
3015 | + ["[junk]", "foo=bar"]) |
3016 | |
3017 | def test_get_items_file_missing(self): |
3018 | rs = self.make_searcher(None) |
3019 | |
3020 | === modified file 'breezy/tests/test_version_info.py' |
3021 | --- breezy/tests/test_version_info.py 2017-06-10 00:17:06 +0000 |
3022 | +++ breezy/tests/test_version_info.py 2017-07-24 01:10:54 +0000 |
3023 | @@ -21,7 +21,6 @@ |
3024 | import sys |
3025 | |
3026 | from .. import ( |
3027 | - errors, |
3028 | registry, |
3029 | tests, |
3030 | version_info_formats, |
3031 | @@ -32,7 +31,11 @@ |
3032 | from . import TestCaseWithTransport |
3033 | from ..rio import read_stanzas |
3034 | |
3035 | -from ..version_info_formats.format_custom import CustomVersionInfoBuilder |
3036 | +from ..version_info_formats.format_custom import ( |
3037 | + CustomVersionInfoBuilder, |
3038 | + MissingTemplateVariable, |
3039 | + NoTemplate, |
3040 | + ) |
3041 | from ..version_info_formats.format_rio import RioVersionInfoBuilder |
3042 | from ..version_info_formats.format_python import PythonVersionInfoBuilder |
3043 | |
3044 | @@ -346,8 +349,7 @@ |
3045 | builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, |
3046 | template='{revno} revid: {revision_id}') |
3047 | # revision_id is not available yet |
3048 | - self.assertRaises(errors.MissingTemplateVariable, |
3049 | - builder.generate, sio) |
3050 | + self.assertRaises(MissingTemplateVariable, builder.generate, sio) |
3051 | |
3052 | def test_custom_dotted_revno(self): |
3053 | sio = BytesIO() |
3054 | @@ -398,7 +400,7 @@ |
3055 | def test_custom_without_template(self): |
3056 | builder = CustomVersionInfoBuilder(None) |
3057 | sio = BytesIO() |
3058 | - self.assertRaises(errors.NoTemplate, builder.generate, sio) |
3059 | + self.assertRaises(NoTemplate, builder.generate, sio) |
3060 | |
3061 | |
3062 | class TestBuilder(version_info_formats.VersionInfoBuilder): |
3063 | |
3064 | === modified file 'breezy/version_info_formats/format_custom.py' |
3065 | --- breezy/version_info_formats/format_custom.py 2017-06-14 23:29:06 +0000 |
3066 | +++ breezy/version_info_formats/format_custom.py 2017-07-24 01:10:54 +0000 |
3067 | @@ -30,6 +30,19 @@ |
3068 | ) |
3069 | |
3070 | |
3071 | +class MissingTemplateVariable(errors.BzrError): |
3072 | + |
3073 | + _fmt = 'Variable {%(name)s} is not available.' |
3074 | + |
3075 | + def __init__(self, name): |
3076 | + self.name = name |
3077 | + |
3078 | + |
3079 | +class NoTemplate(errors.BzrError): |
3080 | + |
3081 | + _fmt = 'No template specified.' |
3082 | + |
3083 | + |
3084 | class Template(object): |
3085 | """A simple template engine. |
3086 |
Okay, couple of notes inline but nothing unexpected on the moves.