Merge lp:~jelmer/brz/move-errors-more into lp:brz

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
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.
Revision history for this message
Martin Packman (gz) wrote :

Okay, couple of notes inline but nothing unexpected on the moves.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/branch.py'
--- breezy/branch.py 2017-07-15 13:23:08 +0000
+++ breezy/branch.py 2017-07-24 01:10:54 +0000
@@ -59,6 +59,17 @@
59from .trace import mutter, mutter_callsite, note, is_quiet59from .trace import mutter, mutter_callsite, note, is_quiet
6060
6161
62class UnstackableBranchFormat(errors.BzrError):
63
64 _fmt = ("The branch '%(url)s'(%(format)s) is not a stackable format. "
65 "You will need to upgrade the branch to permit branch stacking.")
66
67 def __init__(self, format, url):
68 errors.BzrError.__init__(self)
69 self.format = format
70 self.url = url
71
72
62class Branch(controldir.ControlComponent):73class Branch(controldir.ControlComponent):
63 """Branch holding a history of revisions.74 """Branch holding a history of revisions.
6475
@@ -816,7 +827,7 @@
816 stacking.827 stacking.
817 """828 """
818 if not self._format.supports_stacking():829 if not self._format.supports_stacking():
819 raise errors.UnstackableBranchFormat(self._format, self.user_url)830 raise UnstackableBranchFormat(self._format, self.user_url)
820 # XXX: Changing from one fallback repository to another does not check831 # XXX: Changing from one fallback repository to another does not check
821 # that all the data you need is present in the new fallback.832 # that all the data you need is present in the new fallback.
822 # Possibly it should.833 # Possibly it should.
@@ -824,7 +835,7 @@
824 if not url:835 if not url:
825 try:836 try:
826 old_url = self.get_stacked_on_url()837 old_url = self.get_stacked_on_url()
827 except (errors.NotStacked, errors.UnstackableBranchFormat,838 except (errors.NotStacked, UnstackableBranchFormat,
828 errors.UnstackableRepositoryFormat):839 errors.UnstackableRepositoryFormat):
829 return840 return
830 self._unstack()841 self._unstack()
831842
=== modified file 'breezy/builtins.py'
--- breezy/builtins.py 2017-07-24 01:07:36 +0000
+++ breezy/builtins.py 2017-07-24 01:10:54 +0000
@@ -60,7 +60,7 @@
60from breezy.bzr import (60from breezy.bzr import (
61 btree_index,61 btree_index,
62 )62 )
63from breezy.branch import Branch63from breezy.branch import Branch, UnstackableBranchFormat
64from breezy.conflicts import ConflictList64from breezy.conflicts import ConflictList
65from breezy.transport import memory65from breezy.transport import memory
66from breezy.revisionspec import RevisionSpec, RevisionInfo66from breezy.revisionspec import RevisionSpec, RevisionInfo
@@ -1524,7 +1524,7 @@
1524 try:1524 try:
1525 note(gettext('Created new stacked branch referring to %s.') %1525 note(gettext('Created new stacked branch referring to %s.') %
1526 branch.get_stacked_on_url())1526 branch.get_stacked_on_url())
1527 except (errors.NotStacked, errors.UnstackableBranchFormat,1527 except (errors.NotStacked, UnstackableBranchFormat,
1528 errors.UnstackableRepositoryFormat) as e:1528 errors.UnstackableRepositoryFormat) as e:
1529 note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())1529 note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1530 if bind:1530 if bind:
15311531
=== modified file 'breezy/bzr/_dirstate_helpers_py.py'
--- breezy/bzr/_dirstate_helpers_py.py 2017-06-11 13:48:12 +0000
+++ breezy/bzr/_dirstate_helpers_py.py 2017-07-24 01:10:54 +0000
@@ -24,8 +24,7 @@
2424
25# We cannot import the dirstate module, because it loads this module25# We cannot import the dirstate module, because it loads this module
26# All we really need is the IN_MEMORY_MODIFIED constant26# All we really need is the IN_MEMORY_MODIFIED constant
27from breezy import errors27from .dirstate import DirState, DirstateCorrupt
28from .dirstate import DirState
29from ..sixish import (28from ..sixish import (
30 range,29 range,
31 )30 )
@@ -229,7 +228,7 @@
229 # Remove the last blank entry228 # Remove the last blank entry
230 trailing = fields.pop()229 trailing = fields.pop()
231 if trailing != b'':230 if trailing != b'':
232 raise errors.DirstateCorrupt(state,231 raise DirstateCorrupt(state,
233 'trailing garbage: %r' % (trailing,))232 'trailing garbage: %r' % (trailing,))
234 # consider turning fields into a tuple.233 # consider turning fields into a tuple.
235234
@@ -248,7 +247,7 @@
248 field_count = len(fields)247 field_count = len(fields)
249 # this checks our adjustment, and also catches file too short.248 # this checks our adjustment, and also catches file too short.
250 if field_count - cur != expected_field_count:249 if field_count - cur != expected_field_count:
251 raise errors.DirstateCorrupt(state,250 raise DirstateCorrupt(state,
252 'field count incorrect %s != %s, entry_size=%s, '\251 'field count incorrect %s != %s, entry_size=%s, '\
253 'num_entries=%s fields=%r' % (252 'num_entries=%s fields=%r' % (
254 field_count - cur, expected_field_count, entry_size,253 field_count - cur, expected_field_count, entry_size,
255254
=== modified file 'breezy/bzr/_dirstate_helpers_pyx.pyx'
--- breezy/bzr/_dirstate_helpers_pyx.pyx 2017-06-10 21:59:15 +0000
+++ breezy/bzr/_dirstate_helpers_pyx.pyx 2017-07-24 01:10:54 +0000
@@ -28,8 +28,8 @@
28import stat28import stat
29import sys29import sys
3030
31from .. import cache_utf8, errors, osutils31from .. import cache_utf8, osutils
32from .dirstate import DirState32from .dirstate import DirState, DirstateCorrupt
33from ..osutils import parent_directories, pathjoin, splitpath33from ..osutils import parent_directories, pathjoin, splitpath
3434
3535
@@ -561,7 +561,7 @@
561 self.cur_cstr = <char*>memchr(next, c'\0', self.end_cstr - next)561 self.cur_cstr = <char*>memchr(next, c'\0', self.end_cstr - next)
562 if self.cur_cstr == NULL:562 if self.cur_cstr == NULL:
563 extra_len = self.end_cstr - next563 extra_len = self.end_cstr - next
564 raise errors.DirstateCorrupt(self.state,564 raise DirstateCorrupt(self.state,
565 'failed to find trailing NULL (\\0).'565 'failed to find trailing NULL (\\0).'
566 ' Trailing garbage: %r'566 ' Trailing garbage: %r'
567 % safe_string_from_size(next, extra_len))567 % safe_string_from_size(next, extra_len))
@@ -720,7 +720,7 @@
720 # marker.720 # marker.
721 trailing = self.get_next(&cur_size)721 trailing = self.get_next(&cur_size)
722 if cur_size != 1 or trailing[0] != c'\n':722 if cur_size != 1 or trailing[0] != c'\n':
723 raise errors.DirstateCorrupt(self.state,723 raise DirstateCorrupt(self.state,
724 'Bad parse, we expected to end on \\n, not: %d %s: %s'724 'Bad parse, we expected to end on \\n, not: %d %s: %s'
725 % (cur_size, safe_string_from_size(trailing, cur_size),725 % (cur_size, safe_string_from_size(trailing, cur_size),
726 ret))726 ret))
@@ -767,7 +767,7 @@
767 PyList_Append(current_block, entry)767 PyList_Append(current_block, entry)
768 entry_count = entry_count + 1768 entry_count = entry_count + 1
769 if entry_count != expected_entry_count:769 if entry_count != expected_entry_count:
770 raise errors.DirstateCorrupt(self.state,770 raise DirstateCorrupt(self.state,
771 'We read the wrong number of entries.'771 'We read the wrong number of entries.'
772 ' We expected to read %s, but read %s'772 ' We expected to read %s, but read %s'
773 % (expected_entry_count, entry_count))773 % (expected_entry_count, entry_count))
@@ -1326,7 +1326,7 @@
1326 parent_entry = self.state._get_entry(self.target_index,1326 parent_entry = self.state._get_entry(self.target_index,
1327 path_utf8=entry[0][0])1327 path_utf8=entry[0][0])
1328 if parent_entry is None:1328 if parent_entry is None:
1329 raise errors.DirstateCorrupt(self.state,1329 raise DirstateCorrupt(self.state,
1330 "We could not find the parent entry in index %d"1330 "We could not find the parent entry in index %d"
1331 " for the entry: %s"1331 " for the entry: %s"
1332 % (self.target_index, entry[0]))1332 % (self.target_index, entry[0]))
13331333
=== modified file 'breezy/bzr/branch.py'
--- breezy/bzr/branch.py 2017-06-14 23:29:06 +0000
+++ breezy/bzr/branch.py 2017-07-24 01:10:54 +0000
@@ -42,6 +42,7 @@
42 BranchFormat,42 BranchFormat,
43 BranchWriteLockResult,43 BranchWriteLockResult,
44 format_registry,44 format_registry,
45 UnstackableBranchFormat,
45 )46 )
46from ..decorators import (47from ..decorators import (
47 needs_read_lock,48 needs_read_lock,
@@ -260,7 +261,7 @@
260 return None261 return None
261262
262 def get_stacked_on_url(self):263 def get_stacked_on_url(self):
263 raise errors.UnstackableBranchFormat(self._format, self.user_url)264 raise UnstackableBranchFormat(self._format, self.user_url)
264265
265 def set_push_location(self, location):266 def set_push_location(self, location):
266 """See Branch.set_push_location."""267 """See Branch.set_push_location."""
@@ -409,7 +410,7 @@
409 try:410 try:
410 url = self.get_stacked_on_url()411 url = self.get_stacked_on_url()
411 except (errors.UnstackableRepositoryFormat, errors.NotStacked,412 except (errors.UnstackableRepositoryFormat, errors.NotStacked,
412 errors.UnstackableBranchFormat):413 UnstackableBranchFormat):
413 pass414 pass
414 else:415 else:
415 for hook in Branch.hooks['transform_fallback_location']:416 for hook in Branch.hooks['transform_fallback_location']:
@@ -650,7 +651,7 @@
650 """651 """
651652
652 def get_stacked_on_url(self):653 def get_stacked_on_url(self):
653 raise errors.UnstackableBranchFormat(self._format, self.user_url)654 raise UnstackableBranchFormat(self._format, self.user_url)
654655
655656
656class BranchFormatMetadir(bzrdir.BzrFormat, BranchFormat):657class BranchFormatMetadir(bzrdir.BzrFormat, BranchFormat):
657658
=== modified file 'breezy/bzr/bzrdir.py'
--- breezy/bzr/bzrdir.py 2017-07-21 14:18:24 +0000
+++ breezy/bzr/bzrdir.py 2017-07-24 01:10:54 +0000
@@ -33,6 +33,7 @@
33lazy_import(globals(), """33lazy_import(globals(), """
34import breezy34import breezy
35from breezy import (35from breezy import (
36 branch as _mod_branch,
36 cleanup,37 cleanup,
37 fetch,38 fetch,
38 graph,39 graph,
@@ -85,6 +86,14 @@
85 self.feature = feature86 self.feature = feature
8687
8788
89class FeatureAlreadyRegistered(errors.BzrError):
90
91 _fmt = 'The feature %(feature)s has already been registered.'
92
93 def __init__(self, feature):
94 self.feature = feature
95
96
88class BzrDir(controldir.ControlDir):97class BzrDir(controldir.ControlDir):
89 """A .bzr control diretory.98 """A .bzr control diretory.
9099
@@ -177,7 +186,7 @@
177 if preserve_stacking:186 if preserve_stacking:
178 try:187 try:
179 stacked_on = local_branch.get_stacked_on_url()188 stacked_on = local_branch.get_stacked_on_url()
180 except (errors.UnstackableBranchFormat,189 except (_mod_branch.UnstackableBranchFormat,
181 errors.UnstackableRepositoryFormat,190 errors.UnstackableRepositoryFormat,
182 errors.NotStacked):191 errors.NotStacked):
183 pass192 pass
@@ -1856,7 +1865,7 @@
1856 stack_on = self._get_full_stack_on()1865 stack_on = self._get_full_stack_on()
1857 try:1866 try:
1858 branch.set_stacked_on_url(stack_on)1867 branch.set_stacked_on_url(stack_on)
1859 except (errors.UnstackableBranchFormat,1868 except (_mod_branch.UnstackableBranchFormat,
1860 errors.UnstackableRepositoryFormat):1869 errors.UnstackableRepositoryFormat):
1861 if self._require_stacking:1870 if self._require_stacking:
1862 raise1871 raise
18631872
=== modified file 'breezy/bzr/dirstate.py'
--- breezy/bzr/dirstate.py 2017-06-14 23:29:06 +0000
+++ breezy/bzr/dirstate.py 2017-07-24 01:10:54 +0000
@@ -258,6 +258,16 @@
258ERROR_DIRECTORY = 267258ERROR_DIRECTORY = 267
259259
260260
261class DirstateCorrupt(errors.BzrError):
262
263 _fmt = "The dirstate file (%(state)s) appears to be corrupt: %(msg)s"
264
265 def __init__(self, state, msg):
266 errors.BzrError.__init__(self)
267 self.state = state
268 self.msg = msg
269
270
261class SHA1Provider(object):271class SHA1Provider(object):
262 """An interface for getting sha1s of a file."""272 """An interface for getting sha1s of a file."""
263273
@@ -3583,7 +3593,7 @@
3583 # update the source details variable to be the real3593 # update the source details variable to be the real
3584 # location.3594 # location.
3585 if old_entry == (None, None):3595 if old_entry == (None, None):
3586 raise errors.CorruptDirstate(self.state._filename,3596 raise DirstateCorrupt(self.state._filename,
3587 "entry '%s/%s' is considered renamed from %r"3597 "entry '%s/%s' is considered renamed from %r"
3588 " but source does not exist\n"3598 " but source does not exist\n"
3589 "entry: %s" % (entry[0][0], entry[0][1], old_path, entry))3599 "entry: %s" % (entry[0][0], entry[0][1], old_path, entry))
35903600
=== modified file 'breezy/bzr/groupcompress.py'
--- breezy/bzr/groupcompress.py 2017-06-11 13:48:12 +0000
+++ breezy/bzr/groupcompress.py 2017-07-24 01:10:54 +0000
@@ -27,7 +27,6 @@
27 annotate,27 annotate,
28 config,28 config,
29 debug,29 debug,
30 errors,
31 graph as _mod_graph,30 graph as _mod_graph,
32 osutils,31 osutils,
33 static_tuple,32 static_tuple,
@@ -42,6 +41,9 @@
42from breezy.i18n import gettext41from breezy.i18n import gettext
43""")42""")
4443
44from .. import (
45 errors,
46 )
45from .btree_index import BTreeBuilder47from .btree_index import BTreeBuilder
46from ..lru_cache import LRUSizeCache48from ..lru_cache import LRUSizeCache
47from ..sixish import (49from ..sixish import (
@@ -92,6 +94,18 @@
92 return present_keys94 return present_keys
9395
9496
97class DecompressCorruption(errors.BzrError):
98
99 _fmt = "Corruption while decompressing repository file%(orig_error)s"
100
101 def __init__(self, orig_error=None):
102 if orig_error is not None:
103 self.orig_error = ", %s" % (orig_error,)
104 else:
105 self.orig_error = ""
106 errors.BzrError.__init__(self)
107
108
95# The max zlib window size is 32kB, so if we set 'max_size' output of the109# The max zlib window size is 32kB, so if we set 'max_size' output of the
96# decompressor to the requested bytes + 32kB, then we should guarantee110# decompressor to the requested bytes + 32kB, then we should guarantee
97# num_bytes coming out.111# num_bytes coming out.
@@ -457,7 +471,7 @@
457 try:471 try:
458 self._manager._prepare_for_extract()472 self._manager._prepare_for_extract()
459 except zlib.error as value:473 except zlib.error as value:
460 raise errors.DecompressCorruption("zlib: " + str(value))474 raise DecompressCorruption("zlib: " + str(value))
461 block = self._manager._block475 block = self._manager._block
462 self._bytes = block.extract(self.key, self._start, self._end)476 self._bytes = block.extract(self.key, self._start, self._end)
463 # There are code paths that first extract as fulltext, and then477 # There are code paths that first extract as fulltext, and then
464478
=== modified file 'breezy/bzr/index.py'
--- breezy/bzr/index.py 2017-06-11 13:48:12 +0000
+++ breezy/bzr/index.py 2017-07-24 01:10:54 +0000
@@ -28,7 +28,6 @@
2828
29from bisect import bisect_right29from bisect import bisect_right
30import re30import re
31import sys
3231
33from ..lazy_import import lazy_import32from ..lazy_import import lazy_import
34lazy_import(globals(), """33lazy_import(globals(), """
@@ -56,6 +55,62 @@
56_SIGNATURE = b"Bazaar Graph Index 1\n"55_SIGNATURE = b"Bazaar Graph Index 1\n"
5756
5857
58class BadIndexFormatSignature(errors.BzrError):
59
60 _fmt = "%(value)s is not an index of type %(_type)s."
61
62 def __init__(self, value, _type):
63 errors.BzrError.__init__(self)
64 self.value = value
65 self._type = _type
66
67
68class BadIndexData(errors.BzrError):
69
70 _fmt = "Error in data for index %(value)s."
71
72 def __init__(self, value):
73 errors.BzrError.__init__(self)
74 self.value = value
75
76
77class BadIndexDuplicateKey(errors.BzrError):
78
79 _fmt = "The key '%(key)s' is already in index '%(index)s'."
80
81 def __init__(self, key, index):
82 errors.BzrError.__init__(self)
83 self.key = key
84 self.index = index
85
86
87class BadIndexKey(errors.BzrError):
88
89 _fmt = "The key '%(key)s' is not a valid key."
90
91 def __init__(self, key):
92 errors.BzrError.__init__(self)
93 self.key = key
94
95
96class BadIndexOptions(errors.BzrError):
97
98 _fmt = "Could not parse options for index %(value)s."
99
100 def __init__(self, value):
101 errors.BzrError.__init__(self)
102 self.value = value
103
104
105class BadIndexValue(errors.BzrError):
106
107 _fmt = "The value '%(value)s' is not a valid value."
108
109 def __init__(self, value):
110 errors.BzrError.__init__(self)
111 self.value = value
112
113
59_whitespace_re = re.compile(b'[\t\n\x0b\x0c\r\x00 ]')114_whitespace_re = re.compile(b'[\t\n\x0b\x0c\r\x00 ]')
60_newline_null_re = re.compile(b'[\n\0]')115_newline_null_re = re.compile(b'[\n\0]')
61116
@@ -112,12 +167,12 @@
112 def _check_key(self, key):167 def _check_key(self, key):
113 """Raise BadIndexKey if key is not a valid key for this index."""168 """Raise BadIndexKey if key is not a valid key for this index."""
114 if type(key) not in (tuple, StaticTuple):169 if type(key) not in (tuple, StaticTuple):
115 raise errors.BadIndexKey(key)170 raise BadIndexKey(key)
116 if self._key_length != len(key):171 if self._key_length != len(key):
117 raise errors.BadIndexKey(key)172 raise BadIndexKey(key)
118 for element in key:173 for element in key:
119 if not element or _whitespace_re.search(element) is not None:174 if not element or _whitespace_re.search(element) is not None:
120 raise errors.BadIndexKey(element)175 raise BadIndexKey(element)
121176
122 def _external_references(self):177 def _external_references(self):
123 """Return references that are not present in this index.178 """Return references that are not present in this index.
@@ -201,9 +256,9 @@
201 as_st = StaticTuple.from_sequence256 as_st = StaticTuple.from_sequence
202 self._check_key(key)257 self._check_key(key)
203 if _newline_null_re.search(value) is not None:258 if _newline_null_re.search(value) is not None:
204 raise errors.BadIndexValue(value)259 raise BadIndexValue(value)
205 if len(references) != self.reference_lists:260 if len(references) != self.reference_lists:
206 raise errors.BadIndexValue(references)261 raise BadIndexValue(references)
207 node_refs = []262 node_refs = []
208 absent_references = []263 absent_references = []
209 for reference_list in references:264 for reference_list in references:
@@ -232,7 +287,7 @@
232 (node_refs,287 (node_refs,
233 absent_references) = self._check_key_ref_value(key, references, value)288 absent_references) = self._check_key_ref_value(key, references, value)
234 if key in self._nodes and self._nodes[key][0] != 'a':289 if key in self._nodes and self._nodes[key][0] != 'a':
235 raise errors.BadIndexDuplicateKey(key, self)290 raise BadIndexDuplicateKey(key, self)
236 for reference in absent_references:291 for reference in absent_references:
237 # There may be duplicates, but I don't think it is worth worrying292 # There may be duplicates, but I don't think it is worth worrying
238 # about293 # about
@@ -492,7 +547,7 @@
492 # cache the keys for quick set intersections547 # cache the keys for quick set intersections
493 if trailers != 1:548 if trailers != 1:
494 # there must be one line - the empty trailer line.549 # there must be one line - the empty trailer line.
495 raise errors.BadIndexData(self)550 raise BadIndexData(self)
496551
497 def clear_cache(self):552 def clear_cache(self):
498 """Clear out any cached/memoized values.553 """Clear out any cached/memoized values.
@@ -558,28 +613,28 @@
558 def _read_prefix(self, stream):613 def _read_prefix(self, stream):
559 signature = stream.read(len(self._signature()))614 signature = stream.read(len(self._signature()))
560 if not signature == self._signature():615 if not signature == self._signature():
561 raise errors.BadIndexFormatSignature(self._name, GraphIndex)616 raise BadIndexFormatSignature(self._name, GraphIndex)
562 options_line = stream.readline()617 options_line = stream.readline()
563 if not options_line.startswith(_OPTION_NODE_REFS):618 if not options_line.startswith(_OPTION_NODE_REFS):
564 raise errors.BadIndexOptions(self)619 raise BadIndexOptions(self)
565 try:620 try:
566 self.node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):-1])621 self.node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):-1])
567 except ValueError:622 except ValueError:
568 raise errors.BadIndexOptions(self)623 raise BadIndexOptions(self)
569 options_line = stream.readline()624 options_line = stream.readline()
570 if not options_line.startswith(_OPTION_KEY_ELEMENTS):625 if not options_line.startswith(_OPTION_KEY_ELEMENTS):
571 raise errors.BadIndexOptions(self)626 raise BadIndexOptions(self)
572 try:627 try:
573 self._key_length = int(options_line[len(_OPTION_KEY_ELEMENTS):-1])628 self._key_length = int(options_line[len(_OPTION_KEY_ELEMENTS):-1])
574 except ValueError:629 except ValueError:
575 raise errors.BadIndexOptions(self)630 raise BadIndexOptions(self)
576 options_line = stream.readline()631 options_line = stream.readline()
577 if not options_line.startswith(_OPTION_LEN):632 if not options_line.startswith(_OPTION_LEN):
578 raise errors.BadIndexOptions(self)633 raise BadIndexOptions(self)
579 try:634 try:
580 self._key_count = int(options_line[len(_OPTION_LEN):-1])635 self._key_count = int(options_line[len(_OPTION_LEN):-1])
581 except ValueError:636 except ValueError:
582 raise errors.BadIndexOptions(self)637 raise BadIndexOptions(self)
583638
584 def _resolve_references(self, references):639 def _resolve_references(self, references):
585 """Return the resolved key references for references.640 """Return the resolved key references for references.
@@ -906,29 +961,29 @@
906 """961 """
907 signature = bytes[0:len(self._signature())]962 signature = bytes[0:len(self._signature())]
908 if not signature == self._signature():963 if not signature == self._signature():
909 raise errors.BadIndexFormatSignature(self._name, GraphIndex)964 raise BadIndexFormatSignature(self._name, GraphIndex)
910 lines = bytes[len(self._signature()):].splitlines()965 lines = bytes[len(self._signature()):].splitlines()
911 options_line = lines[0]966 options_line = lines[0]
912 if not options_line.startswith(_OPTION_NODE_REFS):967 if not options_line.startswith(_OPTION_NODE_REFS):
913 raise errors.BadIndexOptions(self)968 raise BadIndexOptions(self)
914 try:969 try:
915 self.node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):])970 self.node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):])
916 except ValueError:971 except ValueError:
917 raise errors.BadIndexOptions(self)972 raise BadIndexOptions(self)
918 options_line = lines[1]973 options_line = lines[1]
919 if not options_line.startswith(_OPTION_KEY_ELEMENTS):974 if not options_line.startswith(_OPTION_KEY_ELEMENTS):
920 raise errors.BadIndexOptions(self)975 raise BadIndexOptions(self)
921 try:976 try:
922 self._key_length = int(options_line[len(_OPTION_KEY_ELEMENTS):])977 self._key_length = int(options_line[len(_OPTION_KEY_ELEMENTS):])
923 except ValueError:978 except ValueError:
924 raise errors.BadIndexOptions(self)979 raise BadIndexOptions(self)
925 options_line = lines[2]980 options_line = lines[2]
926 if not options_line.startswith(_OPTION_LEN):981 if not options_line.startswith(_OPTION_LEN):
927 raise errors.BadIndexOptions(self)982 raise BadIndexOptions(self)
928 try:983 try:
929 self._key_count = int(options_line[len(_OPTION_LEN):])984 self._key_count = int(options_line[len(_OPTION_LEN):])
930 except ValueError:985 except ValueError:
931 raise errors.BadIndexOptions(self)986 raise BadIndexOptions(self)
932 # calculate the bytes we have processed987 # calculate the bytes we have processed
933 header_end = (len(signature) + len(lines[0]) + len(lines[1]) +988 header_end = (len(signature) + len(lines[0]) + len(lines[1]) +
934 len(lines[2]) + 3)989 len(lines[2]) + 3)
@@ -1087,7 +1142,7 @@
1087 continue1142 continue
1088 elements = line.split('\0')1143 elements = line.split('\0')
1089 if len(elements) != self._expected_elements:1144 if len(elements) != self._expected_elements:
1090 raise errors.BadIndexData(self)1145 raise BadIndexData(self)
1091 # keys are tuples. Each element is a string that may occur many1146 # keys are tuples. Each element is a string that may occur many
1092 # times, so we intern them to save space. AB, RC, 2008071147 # times, so we intern them to save space. AB, RC, 200807
1093 key = tuple([intern(element) for element in elements[:self._key_length]])1148 key = tuple([intern(element) for element in elements[:self._key_length]])
@@ -1739,11 +1794,11 @@
1739 for node in an_iter:1794 for node in an_iter:
1740 # cross checks1795 # cross checks
1741 if node[1][:self.prefix_len] != self.prefix:1796 if node[1][:self.prefix_len] != self.prefix:
1742 raise errors.BadIndexData(self)1797 raise BadIndexData(self)
1743 for ref_list in node[3]:1798 for ref_list in node[3]:
1744 for ref_node in ref_list:1799 for ref_node in ref_list:
1745 if ref_node[:self.prefix_len] != self.prefix:1800 if ref_node[:self.prefix_len] != self.prefix:
1746 raise errors.BadIndexData(self)1801 raise BadIndexData(self)
1747 yield node[0], node[1][self.prefix_len:], node[2], (1802 yield node[0], node[1][self.prefix_len:], node[2], (
1748 tuple(tuple(ref_node[self.prefix_len:] for ref_node in ref_list)1803 tuple(tuple(ref_node[self.prefix_len:] for ref_node in ref_list)
1749 for ref_list in node[3]))1804 for ref_list in node[3]))
@@ -1807,9 +1862,9 @@
1807def _sanity_check_key(index_or_builder, key):1862def _sanity_check_key(index_or_builder, key):
1808 """Raise BadIndexKey if key cannot be used for prefix matching."""1863 """Raise BadIndexKey if key cannot be used for prefix matching."""
1809 if key[0] is None:1864 if key[0] is None:
1810 raise errors.BadIndexKey(key)1865 raise BadIndexKey(key)
1811 if len(key) != index_or_builder._key_length:1866 if len(key) != index_or_builder._key_length:
1812 raise errors.BadIndexKey(key)1867 raise BadIndexKey(key)
18131868
18141869
1815def _iter_entries_prefix(index_or_builder, nodes_by_key, keys):1870def _iter_entries_prefix(index_or_builder, nodes_by_key, keys):
18161871
=== modified file 'breezy/bzr/remote.py'
--- breezy/bzr/remote.py 2017-06-22 01:06:22 +0000
+++ breezy/bzr/remote.py 2017-07-24 01:10:54 +0000
@@ -3362,7 +3362,7 @@
3362 # the vfs branch.3362 # the vfs branch.
3363 try:3363 try:
3364 fallback_url = self.get_stacked_on_url()3364 fallback_url = self.get_stacked_on_url()
3365 except (errors.NotStacked, errors.UnstackableBranchFormat,3365 except (errors.NotStacked, branch.UnstackableBranchFormat,
3366 errors.UnstackableRepositoryFormat) as e:3366 errors.UnstackableRepositoryFormat) as e:
3367 return3367 return
3368 self._is_stacked = True3368 self._is_stacked = True
@@ -4234,7 +4234,7 @@
4234no_context_error_translators.register('TipChangeRejected',4234no_context_error_translators.register('TipChangeRejected',
4235 lambda err: errors.TipChangeRejected(err.error_args[0].decode('utf8')))4235 lambda err: errors.TipChangeRejected(err.error_args[0].decode('utf8')))
4236no_context_error_translators.register('UnstackableBranchFormat',4236no_context_error_translators.register('UnstackableBranchFormat',
4237 lambda err: errors.UnstackableBranchFormat(*err.error_args))4237 lambda err: branch.UnstackableBranchFormat(*err.error_args))
4238no_context_error_translators.register('UnstackableRepositoryFormat',4238no_context_error_translators.register('UnstackableRepositoryFormat',
4239 lambda err: errors.UnstackableRepositoryFormat(*err.error_args))4239 lambda err: errors.UnstackableRepositoryFormat(*err.error_args))
4240no_context_error_translators.register('FileExists',4240no_context_error_translators.register('FileExists',
42414241
=== modified file 'breezy/bzr/smart/request.py'
--- breezy/bzr/smart/request.py 2017-07-21 13:51:15 +0000
+++ breezy/bzr/smart/request.py 2017-07-24 01:10:54 +0000
@@ -36,6 +36,7 @@
36import threading36import threading
3737
38from ... import (38from ... import (
39 branch as _mod_branch,
39 debug,40 debug,
40 errors,41 errors,
41 osutils,42 osutils,
@@ -430,7 +431,7 @@
430 return ('RevisionNotPresent', err.revision_id, err.file_id)431 return ('RevisionNotPresent', err.revision_id, err.file_id)
431 elif isinstance(err, errors.UnstackableRepositoryFormat):432 elif isinstance(err, errors.UnstackableRepositoryFormat):
432 return (('UnstackableRepositoryFormat', str(err.format), err.url))433 return (('UnstackableRepositoryFormat', str(err.format), err.url))
433 elif isinstance(err, errors.UnstackableBranchFormat):434 elif isinstance(err, _mod_branch.UnstackableBranchFormat):
434 return ('UnstackableBranchFormat', str(err.format), err.url)435 return ('UnstackableBranchFormat', str(err.format), err.url)
435 elif isinstance(err, errors.NotStacked):436 elif isinstance(err, errors.NotStacked):
436 return ('NotStacked',)437 return ('NotStacked',)
437438
=== modified file 'breezy/commit.py'
--- breezy/commit.py 2017-06-20 22:54:06 +0000
+++ breezy/commit.py 2017-07-24 01:10:54 +0000
@@ -60,7 +60,7 @@
60from .branch import Branch60from .branch import Branch
61from .cleanup import OperationWithCleanups61from .cleanup import OperationWithCleanups
62import breezy.config62import breezy.config
63from .errors import (BzrError, PointlessCommit,63from .errors import (BzrError,
64 ConflictsInTree,64 ConflictsInTree,
65 StrictCommitFailed65 StrictCommitFailed
66 )66 )
@@ -75,6 +75,30 @@
75from .i18n import gettext75from .i18n import gettext
7676
7777
78class PointlessCommit(BzrError):
79
80 _fmt = "No changes to commit"
81
82
83class CannotCommitSelectedFileMerge(BzrError):
84
85 _fmt = 'Selected-file commit of merges is not supported yet:'\
86 ' files %(files_str)s'
87
88 def __init__(self, files):
89 files_str = ', '.join(files)
90 BzrError.__init__(self, files=files, files_str=files_str)
91
92
93class ExcludesUnsupported(BzrError):
94
95 _fmt = ('Excluding paths during commit is not supported by '
96 'repository at %(repository)r.')
97
98 def __init__(self, repository):
99 BzrError.__init__(self, repository=repository)
100
101
78def filter_excluded(iter_changes, exclude):102def filter_excluded(iter_changes, exclude):
79 """Filter exclude filenames.103 """Filter exclude filenames.
80104
81105
=== modified file 'breezy/controldir.py'
--- breezy/controldir.py 2017-07-15 13:23:08 +0000
+++ breezy/controldir.py 2017-07-24 01:10:54 +0000
@@ -29,7 +29,6 @@
29import textwrap29import textwrap
3030
31from breezy import (31from breezy import (
32 errors,
33 hooks,32 hooks,
34 revision as _mod_revision,33 revision as _mod_revision,
35 transport as _mod_transport,34 transport as _mod_transport,
@@ -45,7 +44,18 @@
45from breezy.i18n import gettext44from breezy.i18n import gettext
46""")45""")
4746
48from . import registry47from . import (
48 errors,
49 registry,
50 )
51
52
53class MustHaveWorkingTree(errors.BzrError):
54
55 _fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
56
57 def __init__(self, format, url):
58 errors.BzrError.__init__(self, format=format, url=url)
4959
5060
51class ControlComponent(object):61class ControlComponent(object):
5262
=== modified file 'breezy/directory_service.py'
--- breezy/directory_service.py 2017-06-11 00:27:48 +0000
+++ breezy/directory_service.py 2017-07-24 01:10:54 +0000
@@ -36,6 +36,26 @@
36""")36""")
3737
3838
39class DirectoryLookupFailure(errors.BzrError):
40 """Base type for lookup errors."""
41
42
43class InvalidLocationAlias(DirectoryLookupFailure):
44
45 _fmt = '"%(alias_name)s" is not a valid location alias.'
46
47 def __init__(self, alias_name):
48 DirectoryLookupFailure.__init__(self, alias_name=alias_name)
49
50
51class UnsetLocationAlias(DirectoryLookupFailure):
52
53 _fmt = 'No %(alias_name)s location assigned.'
54
55 def __init__(self, alias_name):
56 DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
57
58
39class DirectoryServiceRegistry(registry.Registry):59class DirectoryServiceRegistry(registry.Registry):
40 """This object maintains and uses a list of directory services.60 """This object maintains and uses a list of directory services.
4161
@@ -99,11 +119,11 @@
99 try:119 try:
100 method = self.branch_aliases.get(name[1:])120 method = self.branch_aliases.get(name[1:])
101 except KeyError:121 except KeyError:
102 raise errors.InvalidLocationAlias(url)122 raise InvalidLocationAlias(url)
103 else:123 else:
104 result = method(branch)124 result = method(branch)
105 if result is None:125 if result is None:
106 raise errors.UnsetLocationAlias(url)126 raise UnsetLocationAlias(url)
107 if extra is not None:127 if extra is not None:
108 result = urlutils.join(result, extra)128 result = urlutils.join(result, extra)
109 return result129 return result
110130
=== modified file 'breezy/errors.py'
--- breezy/errors.py 2017-07-24 01:07:36 +0000
+++ breezy/errors.py 2017-07-24 01:10:54 +0000
@@ -162,16 +162,6 @@
162 self.msg = msg162 self.msg = msg
163163
164164
165class DirstateCorrupt(BzrError):
166
167 _fmt = "The dirstate file (%(state)s) appears to be corrupt: %(msg)s"
168
169 def __init__(self, state, msg):
170 BzrError.__init__(self)
171 self.state = state
172 self.msg = msg
173
174
175class IncompatibleVersion(BzrError):165class IncompatibleVersion(BzrError):
176166
177 _fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\167 _fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\
@@ -323,62 +313,6 @@
323 self.not_locked = not_locked313 self.not_locked = not_locked
324314
325315
326class BadIndexFormatSignature(BzrError):
327
328 _fmt = "%(value)s is not an index of type %(_type)s."
329
330 def __init__(self, value, _type):
331 BzrError.__init__(self)
332 self.value = value
333 self._type = _type
334
335
336class BadIndexData(BzrError):
337
338 _fmt = "Error in data for index %(value)s."
339
340 def __init__(self, value):
341 BzrError.__init__(self)
342 self.value = value
343
344
345class BadIndexDuplicateKey(BzrError):
346
347 _fmt = "The key '%(key)s' is already in index '%(index)s'."
348
349 def __init__(self, key, index):
350 BzrError.__init__(self)
351 self.key = key
352 self.index = index
353
354
355class BadIndexKey(BzrError):
356
357 _fmt = "The key '%(key)s' is not a valid key."
358
359 def __init__(self, key):
360 BzrError.__init__(self)
361 self.key = key
362
363
364class BadIndexOptions(BzrError):
365
366 _fmt = "Could not parse options for index %(value)s."
367
368 def __init__(self, value):
369 BzrError.__init__(self)
370 self.value = value
371
372
373class BadIndexValue(BzrError):
374
375 _fmt = "The value '%(value)s' is not a valid value."
376
377 def __init__(self, value):
378 BzrError.__init__(self)
379 self.value = value
380
381
382class StrictCommitFailed(BzrError):316class StrictCommitFailed(BzrError):
383317
384 _fmt = "Commit refused because there are unknown files in the tree"318 _fmt = "Commit refused because there are unknown files in the tree"
@@ -482,16 +416,6 @@
482 self.key = key416 self.key = key
483417
484418
485class UnknownHook(BzrError):
486
487 _fmt = "The %(type)s hook '%(hook)s' is unknown in this version of breezy."
488
489 def __init__(self, hook_type, hook_name):
490 BzrError.__init__(self)
491 self.type = hook_type
492 self.hook = hook_name
493
494
495class UnsupportedProtocol(PathError):419class UnsupportedProtocol(PathError):
496420
497 _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'421 _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
@@ -500,17 +424,6 @@
500 PathError.__init__(self, url, extra=extra)424 PathError.__init__(self, url, extra=extra)
501425
502426
503class UnstackableBranchFormat(BzrError):
504
505 _fmt = ("The branch '%(url)s'(%(format)s) is not a stackable format. "
506 "You will need to upgrade the branch to permit branch stacking.")
507
508 def __init__(self, format, url):
509 BzrError.__init__(self)
510 self.format = format
511 self.url = url
512
513
514class UnstackableLocationError(BzrError):427class UnstackableLocationError(BzrError):
515428
516 _fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."429 _fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
@@ -1018,36 +931,6 @@
1018 self.lock_token = lock_token931 self.lock_token = lock_token
1019932
1020933
1021class PointlessCommit(BzrError):
1022
1023 _fmt = "No changes to commit"
1024
1025
1026class CannotCommitSelectedFileMerge(BzrError):
1027
1028 _fmt = 'Selected-file commit of merges is not supported yet:'\
1029 ' files %(files_str)s'
1030
1031 def __init__(self, files):
1032 files_str = ', '.join(files)
1033 BzrError.__init__(self, files=files, files_str=files_str)
1034
1035
1036class ExcludesUnsupported(BzrError):
1037
1038 _fmt = ('Excluding paths during commit is not supported by '
1039 'repository at %(repository)r.')
1040
1041 def __init__(self, repository):
1042 BzrError.__init__(self, repository=repository)
1043
1044
1045class BadCommitMessageEncoding(BzrError):
1046
1047 _fmt = 'The specified commit message contains characters unsupported by '\
1048 'the current encoding.'
1049
1050
1051class UpgradeReadonly(BzrError):934class UpgradeReadonly(BzrError):
1052935
1053 _fmt = "Upgrade URL cannot work with readonly URLs."936 _fmt = "Upgrade URL cannot work with readonly URLs."
@@ -1062,11 +945,6 @@
1062 self.format = format945 self.format = format
1063946
1064947
1065class StrictCommitFailed(Exception):
1066
1067 _fmt = "Commit refused because there are unknowns in the tree."
1068
1069
1070class NoSuchRevision(InternalBzrError):948class NoSuchRevision(InternalBzrError):
1071949
1072 _fmt = "%(branch)s has no revision %(revision)s"950 _fmt = "%(branch)s has no revision %(revision)s"
@@ -1992,17 +1870,6 @@
1992 _fmt = "Format error in conflict listings"1870 _fmt = "Format error in conflict listings"
19931871
19941872
1995class CorruptDirstate(BzrError):
1996
1997 _fmt = ("Inconsistency in dirstate file %(dirstate_path)s.\n"
1998 "Error: %(description)s")
1999
2000 def __init__(self, dirstate_path, description):
2001 BzrError.__init__(self)
2002 self.dirstate_path = dirstate_path
2003 self.description = description
2004
2005
2006class CorruptRepository(BzrError):1873class CorruptRepository(BzrError):
20071874
2008 _fmt = ("An error has been detected in the repository %(repo_path)s.\n"1875 _fmt = ("An error has been detected in the repository %(repo_path)s.\n"
@@ -2492,79 +2359,6 @@
2492 self.reason = reason2359 self.reason = reason
24932360
24942361
2495class BzrDirError(BzrError):
2496
2497 def __init__(self, controldir):
2498 from . import urlutils
2499 display_url = urlutils.unescape_for_display(controldir.user_url,
2500 'ascii')
2501 BzrError.__init__(self, controldir=controldir, display_url=display_url)
2502
2503
2504class UnsyncedBranches(BzrDirError):
2505
2506 _fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2507 " brz help sync-for-reconfigure.")
2508
2509 def __init__(self, controldir, target_branch):
2510 BzrError.__init__(self, controldir)
2511 from . import urlutils
2512 self.target_url = urlutils.unescape_for_display(target_branch.base,
2513 'ascii')
2514
2515
2516class AlreadyBranch(BzrDirError):
2517
2518 _fmt = "'%(display_url)s' is already a branch."
2519
2520
2521class AlreadyTree(BzrDirError):
2522
2523 _fmt = "'%(display_url)s' is already a tree."
2524
2525
2526class AlreadyCheckout(BzrDirError):
2527
2528 _fmt = "'%(display_url)s' is already a checkout."
2529
2530
2531class AlreadyLightweightCheckout(BzrDirError):
2532
2533 _fmt = "'%(display_url)s' is already a lightweight checkout."
2534
2535
2536class AlreadyUsingShared(BzrDirError):
2537
2538 _fmt = "'%(display_url)s' is already using a shared repository."
2539
2540
2541class AlreadyStandalone(BzrDirError):
2542
2543 _fmt = "'%(display_url)s' is already standalone."
2544
2545
2546class AlreadyWithTrees(BzrDirError):
2547
2548 _fmt = ("Shared repository '%(display_url)s' already creates "
2549 "working trees.")
2550
2551
2552class AlreadyWithNoTrees(BzrDirError):
2553
2554 _fmt = ("Shared repository '%(display_url)s' already doesn't create "
2555 "working trees.")
2556
2557
2558class ReconfigurationNotSupported(BzrDirError):
2559
2560 _fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2561
2562
2563class NoBindLocation(BzrDirError):
2564
2565 _fmt = "No location could be found to bind to at %(display_url)s."
2566
2567
2568class UncommittedChanges(BzrError):2362class UncommittedChanges(BzrError):
25692363
2570 _fmt = ('Working tree "%(display_url)s" has uncommitted changes'2364 _fmt = ('Working tree "%(display_url)s" has uncommitted changes'
@@ -2605,19 +2399,6 @@
2605 ' (See brz shelve --list).%(more)s')2399 ' (See brz shelve --list).%(more)s')
26062400
26072401
2608class MissingTemplateVariable(BzrError):
2609
2610 _fmt = 'Variable {%(name)s} is not available.'
2611
2612 def __init__(self, name):
2613 self.name = name
2614
2615
2616class NoTemplate(BzrError):
2617
2618 _fmt = 'No template specified.'
2619
2620
2621class UnableCreateSymlink(BzrError):2402class UnableCreateSymlink(BzrError):
26222403
2623 _fmt = 'Unable to create symlink %(path_str)son this platform'2404 _fmt = 'Unable to create symlink %(path_str)son this platform'
@@ -2633,15 +2414,6 @@
2633 self.path_str = path_str2414 self.path_str = path_str
26342415
26352416
2636class UnsupportedTimezoneFormat(BzrError):
2637
2638 _fmt = ('Unsupported timezone format "%(timezone)s", '
2639 'options are "utc", "original", "local".')
2640
2641 def __init__(self, timezone):
2642 self.timezone = timezone
2643
2644
2645class UnableEncodePath(BzrError):2417class UnableEncodePath(BzrError):
26462418
2647 _fmt = ('Unable to encode %(kind)s path %(path)r in '2419 _fmt = ('Unable to encode %(kind)s path %(path)r in '
@@ -2662,28 +2434,6 @@
2662 BzrError.__init__(self, alias_name=alias_name)2434 BzrError.__init__(self, alias_name=alias_name)
26632435
26642436
2665class DirectoryLookupFailure(BzrError):
2666 """Base type for lookup errors."""
2667
2668 pass
2669
2670
2671class InvalidLocationAlias(DirectoryLookupFailure):
2672
2673 _fmt = '"%(alias_name)s" is not a valid location alias.'
2674
2675 def __init__(self, alias_name):
2676 DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2677
2678
2679class UnsetLocationAlias(DirectoryLookupFailure):
2680
2681 _fmt = 'No %(alias_name)s location assigned.'
2682
2683 def __init__(self, alias_name):
2684 DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2685
2686
2687class CannotBindAddress(BzrError):2437class CannotBindAddress(BzrError):
26882438
2689 _fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'2439 _fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
@@ -2694,14 +2444,6 @@
2694 orig_error=repr(orig_error.args))2444 orig_error=repr(orig_error.args))
26952445
26962446
2697class UnknownRules(BzrError):
2698
2699 _fmt = ('Unknown rules detected: %(unknowns_str)s.')
2700
2701 def __init__(self, unknowns):
2702 BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2703
2704
2705class TipChangeRejected(BzrError):2447class TipChangeRejected(BzrError):
2706 """A pre_change_branch_tip hook function may raise this to cleanly and2448 """A pre_change_branch_tip hook function may raise this to cleanly and
2707 explicitly abort a change to a branch tip.2449 explicitly abort a change to a branch tip.
@@ -2713,18 +2455,6 @@
2713 self.msg = msg2455 self.msg = msg
27142456
27152457
2716class DecompressCorruption(BzrError):
2717
2718 _fmt = "Corruption while decompressing repository file%(orig_error)s"
2719
2720 def __init__(self, orig_error=None):
2721 if orig_error is not None:
2722 self.orig_error = ", %s" % (orig_error,)
2723 else:
2724 self.orig_error = ""
2725 BzrError.__init__(self)
2726
2727
2728class JailBreak(BzrError):2458class JailBreak(BzrError):
27292459
2730 _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."2460 _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
@@ -2738,14 +2468,6 @@
2738 _fmt = 'The user aborted the operation.'2468 _fmt = 'The user aborted the operation.'
27392469
27402470
2741class MustHaveWorkingTree(BzrError):
2742
2743 _fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
2744
2745 def __init__(self, format, url):
2746 BzrError.__init__(self, format=format, url=url)
2747
2748
2749class UnresumableWriteGroup(BzrError):2471class UnresumableWriteGroup(BzrError):
27502472
2751 _fmt = ("Repository %(repository)s cannot resume write group "2473 _fmt = ("Repository %(repository)s cannot resume write group "
@@ -2822,14 +2544,6 @@
2822 self.format = format2544 self.format = format
28232545
28242546
2825class FeatureAlreadyRegistered(BzrError):
2826
2827 _fmt = 'The feature %(feature)s has already been registered.'
2828
2829 def __init__(self, feature):
2830 self.feature = feature
2831
2832
2833class ChangesAlreadyStored(BzrCommandError):2547class ChangesAlreadyStored(BzrCommandError):
28342548
2835 _fmt = ('Cannot store uncommitted changes because this branch already'2549 _fmt = ('Cannot store uncommitted changes because this branch already'
28362550
=== modified file 'breezy/hooks.py'
--- breezy/hooks.py 2017-06-11 20:15:04 +0000
+++ breezy/hooks.py 2017-07-24 01:10:54 +0000
@@ -19,6 +19,7 @@
19from __future__ import absolute_import19from __future__ import absolute_import
2020
21from . import (21from . import (
22 errors,
22 registry,23 registry,
23 )24 )
24from .lazy_import import lazy_import25from .lazy_import import lazy_import
@@ -27,13 +28,22 @@
2728
28from breezy import (29from breezy import (
29 _format_version_tuple,30 _format_version_tuple,
30 errors,
31 pyutils,31 pyutils,
32 )32 )
33from breezy.i18n import gettext33from breezy.i18n import gettext
34""")34""")
3535
3636
37class UnknownHook(errors.BzrError):
38
39 _fmt = "The %(type)s hook '%(hook)s' is unknown in this version of breezy."
40
41 def __init__(self, hook_type, hook_name):
42 errors.BzrError.__init__(self)
43 self.type = hook_type
44 self.hook = hook_name
45
46
37class KnownHooksRegistry(registry.Registry):47class KnownHooksRegistry(registry.Registry):
38 # known_hooks registry contains48 # known_hooks registry contains
39 # tuple of (module, member name) which is the hook point49 # tuple of (module, member name) which is the hook point
@@ -204,7 +214,7 @@
204 try:214 try:
205 hook = self[hook_name]215 hook = self[hook_name]
206 except KeyError:216 except KeyError:
207 raise errors.UnknownHook(self.__class__.__name__, hook_name)217 raise UnknownHook(self.__class__.__name__, hook_name)
208 try:218 try:
209 hook_lazy = getattr(hook, "hook_lazy")219 hook_lazy = getattr(hook, "hook_lazy")
210 except AttributeError:220 except AttributeError:
@@ -229,7 +239,7 @@
229 try:239 try:
230 hook = self[hook_name]240 hook = self[hook_name]
231 except KeyError:241 except KeyError:
232 raise errors.UnknownHook(self.__class__.__name__, hook_name)242 raise UnknownHook(self.__class__.__name__, hook_name)
233 try:243 try:
234 # list hooks, old-style, not yet deprecated but less useful.244 # list hooks, old-style, not yet deprecated but less useful.
235 hook.append(a_callable)245 hook.append(a_callable)
@@ -247,7 +257,7 @@
247 try:257 try:
248 hook = self[hook_name]258 hook = self[hook_name]
249 except KeyError:259 except KeyError:
250 raise errors.UnknownHook(self.__class__.__name__, hook_name)260 raise UnknownHook(self.__class__.__name__, hook_name)
251 try:261 try:
252 uninstall = getattr(hook, "uninstall")262 uninstall = getattr(hook, "uninstall")
253 except AttributeError:263 except AttributeError:
254264
=== modified file 'breezy/info.py'
--- breezy/info.py 2017-07-15 13:23:08 +0000
+++ breezy/info.py 2017-07-24 01:10:54 +0000
@@ -22,6 +22,7 @@
22import sys22import sys
2323
24from . import (24from . import (
25 branch as _mod_branch,
25 controldir,26 controldir,
26 errors,27 errors,
27 hooks as _mod_hooks,28 hooks as _mod_hooks,
@@ -162,7 +163,7 @@
162 locs.add_url('submit branch', branch.get_submit_branch())163 locs.add_url('submit branch', branch.get_submit_branch())
163 try:164 try:
164 locs.add_url('stacked on', branch.get_stacked_on_url())165 locs.add_url('stacked on', branch.get_stacked_on_url())
165 except (errors.UnstackableBranchFormat, errors.UnstackableRepositoryFormat,166 except (_mod_branch.UnstackableBranchFormat, errors.UnstackableRepositoryFormat,
166 errors.NotStacked):167 errors.NotStacked):
167 pass168 pass
168 return locs169 return locs
169170
=== modified file 'breezy/msgeditor.py'
--- breezy/msgeditor.py 2017-05-22 00:56:52 +0000
+++ breezy/msgeditor.py 2017-07-24 01:10:54 +0000
@@ -31,13 +31,19 @@
31 transport,31 transport,
32 ui,32 ui,
33 )33 )
34from .errors import BzrError, BadCommitMessageEncoding34from .errors import BzrError
35from .hooks import Hooks35from .hooks import Hooks
36from .sixish import (36from .sixish import (
37 StringIO,37 StringIO,
38 )38 )
3939
4040
41class BadCommitMessageEncoding(BzrError):
42
43 _fmt = 'The specified commit message contains characters unsupported by '\
44 'the current encoding.'
45
46
41def _get_editor():47def _get_editor():
42 """Return a sequence of possible editor binaries for the current platform"""48 """Return a sequence of possible editor binaries for the current platform"""
43 try:49 try:
4450
=== modified file 'breezy/osutils.py'
--- breezy/osutils.py 2017-06-15 23:20:39 +0000
+++ breezy/osutils.py 2017-07-24 01:10:54 +0000
@@ -47,7 +47,6 @@
4747
48from breezy import (48from breezy import (
49 config,49 config,
50 errors,
51 trace,50 trace,
52 win32utils,51 win32utils,
53 )52 )
@@ -66,7 +65,10 @@
6665
6766
68import breezy67import breezy
69from . import _fs_enc68from . import (
69 _fs_enc,
70 errors,
71 )
7072
7173
72# Cross platform wall-clock time functionality with decent resolution.74# Cross platform wall-clock time functionality with decent resolution.
@@ -89,6 +91,15 @@
89O_NOINHERIT = getattr(os, 'O_NOINHERIT', 0)91O_NOINHERIT = getattr(os, 'O_NOINHERIT', 0)
9092
9193
94class UnsupportedTimezoneFormat(errors.BzrError):
95
96 _fmt = ('Unsupported timezone format "%(timezone)s", '
97 'options are "utc", "original", "local".')
98
99 def __init__(self, timezone):
100 self.timezone = timezone
101
102
92def get_unicode_argv():103def get_unicode_argv():
93 if PY3:104 if PY3:
94 return sys.argv[1:]105 return sys.argv[1:]
@@ -899,7 +910,7 @@
899 tt = time.localtime(t)910 tt = time.localtime(t)
900 offset = local_time_offset(t)911 offset = local_time_offset(t)
901 else:912 else:
902 raise errors.UnsupportedTimezoneFormat(timezone)913 raise UnsupportedTimezoneFormat(timezone)
903 if date_fmt is None:914 if date_fmt is None:
904 date_fmt = "%a %Y-%m-%d %H:%M:%S"915 date_fmt = "%a %Y-%m-%d %H:%M:%S"
905 if show_offset:916 if show_offset:
906917
=== modified file 'breezy/plugins/weave_fmt/bzrdir.py'
--- breezy/plugins/weave_fmt/bzrdir.py 2017-06-11 20:33:20 +0000
+++ breezy/plugins/weave_fmt/bzrdir.py 2017-07-24 01:10:54 +0000
@@ -26,15 +26,19 @@
26from ...controldir import (26from ...controldir import (
27 ControlDir,27 ControlDir,
28 Converter,28 Converter,
29 MustHaveWorkingTree,
29 format_registry,30 format_registry,
30 )31 )
32from ... import (
33 errors,
34 )
31from ...lazy_import import lazy_import35from ...lazy_import import lazy_import
32lazy_import(globals(), """36lazy_import(globals(), """
33import os37import os
34import warnings38import warnings
3539
36from breezy import (40from breezy import (
37 errors,41 branch as _mod_branch,,
38 graph,42 graph,
39 lockable_files,43 lockable_files,
40 lockdir,44 lockdir,
@@ -903,10 +907,10 @@
903 "source branch %r is not within %r with branch %r" %907 "source branch %r is not within %r with branch %r" %
904 (source_branch, self, my_branch))908 (source_branch, self, my_branch))
905 if stacked:909 if stacked:
906 raise errors.UnstackableBranchFormat(910 raise _mod_branch.UnstackableBranchFormat(
907 self._format, self.root_transport.base)911 self._format, self.root_transport.base)
908 if not create_tree_if_local:912 if not create_tree_if_local:
909 raise errors.MustHaveWorkingTree(913 raise MustHaveWorkingTree(
910 self._format, self.root_transport.base)914 self._format, self.root_transport.base)
911 from .workingtree import WorkingTreeFormat2915 from .workingtree import WorkingTreeFormat2
912 self._make_tail(url)916 self._make_tail(url)
913917
=== modified file 'breezy/push.py'
--- breezy/push.py 2017-06-11 00:27:48 +0000
+++ breezy/push.py 2017-07-24 01:10:54 +0000
@@ -19,6 +19,7 @@
19from __future__ import absolute_import19from __future__ import absolute_import
2020
21from . import (21from . import (
22 branch as _mod_branch,
22 controldir,23 controldir,
23 errors,24 errors,
24 revision as _mod_revision,25 revision as _mod_revision,
@@ -125,7 +126,7 @@
125 # TODO: Some more useful message about what was copied126 # TODO: Some more useful message about what was copied
126 try:127 try:
127 push_result.stacked_on = br_to.get_stacked_on_url()128 push_result.stacked_on = br_to.get_stacked_on_url()
128 except (errors.UnstackableBranchFormat,129 except (_mod_branch.UnstackableBranchFormat,
129 errors.UnstackableRepositoryFormat,130 errors.UnstackableRepositoryFormat,
130 errors.NotStacked):131 errors.NotStacked):
131 push_result.stacked_on = None132 push_result.stacked_on = None
132133
=== modified file 'breezy/reconfigure.py'
--- breezy/reconfigure.py 2017-06-11 00:27:48 +0000
+++ breezy/reconfigure.py 2017-07-24 01:10:54 +0000
@@ -37,6 +37,79 @@
37# assumptions about what kind of change will be done.37# assumptions about what kind of change will be done.
3838
3939
40class BzrDirError(errors.BzrError):
41
42 def __init__(self, controldir):
43 display_url = urlutils.unescape_for_display(controldir.user_url,
44 'ascii')
45 errors.BzrError.__init__(self, controldir=controldir,
46 display_url=display_url)
47
48
49class NoBindLocation(BzrDirError):
50
51 _fmt = "No location could be found to bind to at %(display_url)s."
52
53
54class UnsyncedBranches(BzrDirError):
55
56 _fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
57 " brz help sync-for-reconfigure.")
58
59 def __init__(self, controldir, target_branch):
60 BzrError.__init__(self, controldir)
61 from . import urlutils
62 self.target_url = urlutils.unescape_for_display(target_branch.base,
63 'ascii')
64
65
66class AlreadyBranch(BzrDirError):
67
68 _fmt = "'%(display_url)s' is already a branch."
69
70
71class AlreadyTree(BzrDirError):
72
73 _fmt = "'%(display_url)s' is already a tree."
74
75
76class AlreadyCheckout(BzrDirError):
77
78 _fmt = "'%(display_url)s' is already a checkout."
79
80
81class AlreadyLightweightCheckout(BzrDirError):
82
83 _fmt = "'%(display_url)s' is already a lightweight checkout."
84
85
86class AlreadyUsingShared(BzrDirError):
87
88 _fmt = "'%(display_url)s' is already using a shared repository."
89
90
91class AlreadyStandalone(BzrDirError):
92
93 _fmt = "'%(display_url)s' is already standalone."
94
95
96class AlreadyWithTrees(BzrDirError):
97
98 _fmt = ("Shared repository '%(display_url)s' already creates "
99 "working trees.")
100
101
102class AlreadyWithNoTrees(BzrDirError):
103
104 _fmt = ("Shared repository '%(display_url)s' already doesn't create "
105 "working trees.")
106
107
108class ReconfigurationNotSupported(BzrDirError):
109
110 _fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
111
112
40class ReconfigureStackedOn(object):113class ReconfigureStackedOn(object):
41 """Reconfigures a branch to be stacked on another branch."""114 """Reconfigures a branch to be stacked on another branch."""
42115
@@ -120,13 +193,13 @@
120 """Return a Reconfiguration to convert this controldir into a branch193 """Return a Reconfiguration to convert this controldir into a branch
121194
122 :param controldir: The controldir to reconfigure195 :param controldir: The controldir to reconfigure
123 :raise errors.AlreadyBranch: if controldir is already a branch196 :raise AlreadyBranch: if controldir is already a branch
124 """197 """
125 reconfiguration = Reconfigure(controldir)198 reconfiguration = Reconfigure(controldir)
126 reconfiguration._plan_changes(want_tree=False, want_branch=True,199 reconfiguration._plan_changes(want_tree=False, want_branch=True,
127 want_bound=False, want_reference=False)200 want_bound=False, want_reference=False)
128 if not reconfiguration.changes_planned():201 if not reconfiguration.changes_planned():
129 raise errors.AlreadyBranch(controldir)202 raise AlreadyBranch(controldir)
130 return reconfiguration203 return reconfiguration
131204
132 @staticmethod205 @staticmethod
@@ -134,13 +207,13 @@
134 """Return a Reconfiguration to convert this controldir into a tree207 """Return a Reconfiguration to convert this controldir into a tree
135208
136 :param controldir: The controldir to reconfigure209 :param controldir: The controldir to reconfigure
137 :raise errors.AlreadyTree: if controldir is already a tree210 :raise AlreadyTree: if controldir is already a tree
138 """211 """
139 reconfiguration = Reconfigure(controldir)212 reconfiguration = Reconfigure(controldir)
140 reconfiguration._plan_changes(want_tree=True, want_branch=True,213 reconfiguration._plan_changes(want_tree=True, want_branch=True,
141 want_bound=False, want_reference=False)214 want_bound=False, want_reference=False)
142 if not reconfiguration.changes_planned():215 if not reconfiguration.changes_planned():
143 raise errors.AlreadyTree(controldir)216 raise AlreadyTree(controldir)
144 return reconfiguration217 return reconfiguration
145218
146 @staticmethod219 @staticmethod
@@ -149,13 +222,13 @@
149222
150 :param controldir: The controldir to reconfigure223 :param controldir: The controldir to reconfigure
151 :param bound_location: The location the checkout should be bound to.224 :param bound_location: The location the checkout should be bound to.
152 :raise errors.AlreadyCheckout: if controldir is already a checkout225 :raise AlreadyCheckout: if controldir is already a checkout
153 """226 """
154 reconfiguration = Reconfigure(controldir, bound_location)227 reconfiguration = Reconfigure(controldir, bound_location)
155 reconfiguration._plan_changes(want_tree=True, want_branch=True,228 reconfiguration._plan_changes(want_tree=True, want_branch=True,
156 want_bound=True, want_reference=False)229 want_bound=True, want_reference=False)
157 if not reconfiguration.changes_planned():230 if not reconfiguration.changes_planned():
158 raise errors.AlreadyCheckout(controldir)231 raise AlreadyCheckout(controldir)
159 return reconfiguration232 return reconfiguration
160233
161 @classmethod234 @classmethod
@@ -164,14 +237,14 @@
164237
165 :param controldir: The controldir to reconfigure238 :param controldir: The controldir to reconfigure
166 :param bound_location: The location the checkout should be bound to.239 :param bound_location: The location the checkout should be bound to.
167 :raise errors.AlreadyLightweightCheckout: if controldir is already a240 :raise AlreadyLightweightCheckout: if controldir is already a
168 lightweight checkout241 lightweight checkout
169 """242 """
170 reconfiguration = klass(controldir, reference_location)243 reconfiguration = klass(controldir, reference_location)
171 reconfiguration._plan_changes(want_tree=True, want_branch=False,244 reconfiguration._plan_changes(want_tree=True, want_branch=False,
172 want_bound=False, want_reference=True)245 want_bound=False, want_reference=True)
173 if not reconfiguration.changes_planned():246 if not reconfiguration.changes_planned():
174 raise errors.AlreadyLightweightCheckout(controldir)247 raise AlreadyLightweightCheckout(controldir)
175 return reconfiguration248 return reconfiguration
176249
177 @classmethod250 @classmethod
@@ -180,7 +253,7 @@
180 reconfiguration = klass(controldir)253 reconfiguration = klass(controldir)
181 reconfiguration._set_use_shared(use_shared=True)254 reconfiguration._set_use_shared(use_shared=True)
182 if not reconfiguration.changes_planned():255 if not reconfiguration.changes_planned():
183 raise errors.AlreadyUsingShared(controldir)256 raise AlreadyUsingShared(controldir)
184 return reconfiguration257 return reconfiguration
185258
186 @classmethod259 @classmethod
@@ -189,7 +262,7 @@
189 reconfiguration = klass(controldir)262 reconfiguration = klass(controldir)
190 reconfiguration._set_use_shared(use_shared=False)263 reconfiguration._set_use_shared(use_shared=False)
191 if not reconfiguration.changes_planned():264 if not reconfiguration.changes_planned():
192 raise errors.AlreadyStandalone(controldir)265 raise AlreadyStandalone(controldir)
193 return reconfiguration266 return reconfiguration
194267
195 @classmethod268 @classmethod
@@ -197,12 +270,12 @@
197 """Adjust a repository's working tree presence default"""270 """Adjust a repository's working tree presence default"""
198 reconfiguration = klass(controldir)271 reconfiguration = klass(controldir)
199 if not reconfiguration.repository.is_shared():272 if not reconfiguration.repository.is_shared():
200 raise errors.ReconfigurationNotSupported(reconfiguration.controldir)273 raise ReconfigurationNotSupported(reconfiguration.controldir)
201 if with_trees and reconfiguration.repository.make_working_trees():274 if with_trees and reconfiguration.repository.make_working_trees():
202 raise errors.AlreadyWithTrees(controldir)275 raise AlreadyWithTrees(controldir)
203 elif (not with_trees276 elif (not with_trees
204 and not reconfiguration.repository.make_working_trees()):277 and not reconfiguration.repository.make_working_trees()):
205 raise errors.AlreadyWithNoTrees(controldir)278 raise AlreadyWithNoTrees(controldir)
206 else:279 else:
207 reconfiguration._repository_trees = with_trees280 reconfiguration._repository_trees = with_trees
208 return reconfiguration281 return reconfiguration
@@ -211,9 +284,9 @@
211 want_reference):284 want_reference):
212 """Determine which changes are needed to assume the configuration"""285 """Determine which changes are needed to assume the configuration"""
213 if not want_branch and not want_reference:286 if not want_branch and not want_reference:
214 raise errors.ReconfigurationNotSupported(self.controldir)287 raise ReconfigurationNotSupported(self.controldir)
215 if want_branch and want_reference:288 if want_branch and want_reference:
216 raise errors.ReconfigurationNotSupported(self.controldir)289 raise ReconfigurationNotSupported(self.controldir)
217 if self.repository is None:290 if self.repository is None:
218 if not want_reference:291 if not want_reference:
219 self._create_repository = True292 self._create_repository = True
@@ -302,7 +375,7 @@
302 return parent375 return parent
303 elif self.referenced_branch is not None:376 elif self.referenced_branch is not None:
304 return self.referenced_branch.base377 return self.referenced_branch.base
305 raise errors.NoBindLocation(self.controldir)378 raise NoBindLocation(self.controldir)
306379
307 def apply(self, force=False):380 def apply(self, force=False):
308 """Apply the reconfiguration381 """Apply the reconfiguration
@@ -311,7 +384,7 @@
311 destroy local changes.384 destroy local changes.
312 :raise errors.UncommittedChanges: if the local tree is to be destroyed385 :raise errors.UncommittedChanges: if the local tree is to be destroyed
313 but contains uncommitted changes.386 but contains uncommitted changes.
314 :raise errors.NoBindLocation: if no bind location was specified and387 :raise NoBindLocation: if no bind location was specified and
315 none could be autodetected.388 none could be autodetected.
316 """389 """
317 if not force:390 if not force:
318391
=== modified file 'breezy/rules.py'
--- breezy/rules.py 2017-05-22 00:56:52 +0000
+++ breezy/rules.py 2017-07-24 01:10:54 +0000
@@ -43,6 +43,14 @@
43_per_user_searcher = None43_per_user_searcher = None
4444
4545
46class UnknownRules(errors.BzrError):
47
48 _fmt = ('Unknown rules detected: %(unknowns_str)s.')
49
50 def __init__(self, unknowns):
51 errors.BzrError.__init__(self, unknowns_str=", ".join(unknowns))
52
53
46class _RulesSearcher(object):54class _RulesSearcher(object):
47 """An object that provides rule-based preferences."""55 """An object that provides rule-based preferences."""
4856
4957
=== modified file 'breezy/tests/blackbox/test_push.py'
--- breezy/tests/blackbox/test_push.py 2017-06-10 16:40:42 +0000
+++ breezy/tests/blackbox/test_push.py 2017-07-24 01:10:54 +0000
@@ -561,7 +561,7 @@
561 self.make_branch('from', format='pack-0.92')561 self.make_branch('from', format='pack-0.92')
562 out, err = self.run_bzr('push -d from to')562 out, err = self.run_bzr('push -d from to')
563 b = branch.Branch.open('to')563 b = branch.Branch.open('to')
564 self.assertRaises(errors.UnstackableBranchFormat, b.get_stacked_on_url)564 self.assertRaises(branch.UnstackableBranchFormat, b.get_stacked_on_url)
565565
566 def test_push_doesnt_create_broken_branch(self):566 def test_push_doesnt_create_broken_branch(self):
567 """Pushing a new standalone branch works even when there's a default567 """Pushing a new standalone branch works even when there's a default
568568
=== modified file 'breezy/tests/per_branch/test_create_clone.py'
--- breezy/tests/per_branch/test_create_clone.py 2017-06-11 14:07:05 +0000
+++ breezy/tests/per_branch/test_create_clone.py 2017-07-24 01:10:54 +0000
@@ -101,7 +101,7 @@
101 try:101 try:
102 result = tree.branch.create_clone_on_transport(target_transport,102 result = tree.branch.create_clone_on_transport(target_transport,
103 stacked_on=trunk.base)103 stacked_on=trunk.base)
104 except errors.UnstackableBranchFormat:104 except branch.UnstackableBranchFormat:
105 if not trunk.repository._format.supports_full_versioned_files:105 if not trunk.repository._format.supports_full_versioned_files:
106 raise tests.TestNotApplicable("can not stack on format")106 raise tests.TestNotApplicable("can not stack on format")
107 raise107 raise
@@ -142,7 +142,7 @@
142 try:142 try:
143 result = tree.branch.create_clone_on_transport(target_transport,143 result = tree.branch.create_clone_on_transport(target_transport,
144 stacked_on=trunk.base)144 stacked_on=trunk.base)
145 except errors.UnstackableBranchFormat:145 except branch.UnstackableBranchFormat:
146 if not trunk.repository._format.supports_full_versioned_files:146 if not trunk.repository._format.supports_full_versioned_files:
147 raise tests.TestNotApplicable("can not stack on format")147 raise tests.TestNotApplicable("can not stack on format")
148 raise148 raise
149149
=== modified file 'breezy/tests/per_branch/test_sprout.py'
--- breezy/tests/per_branch/test_sprout.py 2017-06-11 14:07:05 +0000
+++ breezy/tests/per_branch/test_sprout.py 2017-07-24 01:10:54 +0000
@@ -209,7 +209,7 @@
209 dir = source.controldir.sprout(target_transport.base,209 dir = source.controldir.sprout(target_transport.base,
210 source.last_revision(), possible_transports=[target_transport],210 source.last_revision(), possible_transports=[target_transport],
211 source_branch=source, stacked=True)211 source_branch=source, stacked=True)
212 except errors.UnstackableBranchFormat:212 except _mod_branch.UnstackableBranchFormat:
213 if not self.branch_format.supports_stacking():213 if not self.branch_format.supports_stacking():
214 raise tests.TestNotApplicable(214 raise tests.TestNotApplicable(
215 "Format doesn't auto stack successfully.")215 "Format doesn't auto stack successfully.")
216216
=== modified file 'breezy/tests/per_branch/test_stacking.py'
--- breezy/tests/per_branch/test_stacking.py 2017-06-10 00:52:37 +0000
+++ breezy/tests/per_branch/test_stacking.py 2017-07-24 01:10:54 +0000
@@ -28,7 +28,7 @@
2828
2929
30unstackable_format_errors = (30unstackable_format_errors = (
31 errors.UnstackableBranchFormat,31 branch.UnstackableBranchFormat,
32 errors.UnstackableRepositoryFormat,32 errors.UnstackableRepositoryFormat,
33 )33 )
3434
@@ -309,14 +309,14 @@
309 cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked',309 cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked',
310 preserve_stacking=False)310 preserve_stacking=False)
311 unstacked_branch = cloned_unstacked_bzrdir.open_branch()311 unstacked_branch = cloned_unstacked_bzrdir.open_branch()
312 self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat),312 self.assertRaises((errors.NotStacked, branch.UnstackableBranchFormat),
313 unstacked_branch.get_stacked_on_url)313 unstacked_branch.get_stacked_on_url)
314314
315 def test_no_op_preserve_stacking(self):315 def test_no_op_preserve_stacking(self):
316 """With no stacking, preserve_stacking should be a no-op."""316 """With no stacking, preserve_stacking should be a no-op."""
317 branch = self.make_branch('source')317 branch = self.make_branch('source')
318 cloned_bzrdir = branch.controldir.clone('cloned', preserve_stacking=True)318 cloned_bzrdir = branch.controldir.clone('cloned', preserve_stacking=True)
319 self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat),319 self.assertRaises((errors.NotStacked, branch.UnstackableBranchFormat),
320 cloned_bzrdir.open_branch().get_stacked_on_url)320 cloned_bzrdir.open_branch().get_stacked_on_url)
321321
322 def make_stacked_on_matching(self, source):322 def make_stacked_on_matching(self, source):
@@ -344,7 +344,7 @@
344 self.assertEqual('../stack-on', target.get_stacked_on_url())344 self.assertEqual('../stack-on', target.get_stacked_on_url())
345 else:345 else:
346 self.assertRaises(346 self.assertRaises(
347 errors.UnstackableBranchFormat, target.get_stacked_on_url)347 branch.UnstackableBranchFormat, target.get_stacked_on_url)
348348
349 def test_clone_stacking_policy_handling(self):349 def test_clone_stacking_policy_handling(self):
350 """Obey policy where possible, ignore otherwise."""350 """Obey policy where possible, ignore otherwise."""
@@ -361,7 +361,7 @@
361 self.assertEqual('../stack-on', target.get_stacked_on_url())361 self.assertEqual('../stack-on', target.get_stacked_on_url())
362 else:362 else:
363 self.assertRaises(363 self.assertRaises(
364 errors.UnstackableBranchFormat, target.get_stacked_on_url)364 branch.UnstackableBranchFormat, target.get_stacked_on_url)
365365
366 def test_sprout_to_smart_server_stacking_policy_handling(self):366 def test_sprout_to_smart_server_stacking_policy_handling(self):
367 """Obey policy where possible, ignore otherwise."""367 """Obey policy where possible, ignore otherwise."""
@@ -379,7 +379,7 @@
379 self.assertEqual('../stack-on', target.get_stacked_on_url())379 self.assertEqual('../stack-on', target.get_stacked_on_url())
380 else:380 else:
381 self.assertRaises(381 self.assertRaises(
382 errors.UnstackableBranchFormat, target.get_stacked_on_url)382 branch.UnstackableBranchFormat, target.get_stacked_on_url)
383383
384 def prepare_stacked_on_fetch(self):384 def prepare_stacked_on_fetch(self):
385 stack_on = self.make_branch_and_tree('stack-on')385 stack_on = self.make_branch_and_tree('stack-on')
386386
=== modified file 'breezy/tests/per_controldir/test_controldir.py'
--- breezy/tests/per_controldir/test_controldir.py 2017-06-11 14:07:05 +0000
+++ breezy/tests/per_controldir/test_controldir.py 2017-07-24 01:10:54 +0000
@@ -18,6 +18,7 @@
1818
19import breezy.branch19import breezy.branch
20from breezy import (20from breezy import (
21 branch as _mod_branch,
21 check,22 check,
22 controldir,23 controldir,
23 errors,24 errors,
@@ -428,7 +429,7 @@
428 try:429 try:
429 child = branch.controldir.clone_on_transport(child_transport,430 child = branch.controldir.clone_on_transport(child_transport,
430 stacked_on=branch.base)431 stacked_on=branch.base)
431 except (errors.UnstackableBranchFormat,432 except (_mod_branch.UnstackableBranchFormat,
432 errors.UnstackableRepositoryFormat):433 errors.UnstackableRepositoryFormat):
433 raise TestNotApplicable("branch or repository format does "434 raise TestNotApplicable("branch or repository format does "
434 "not support stacking")435 "not support stacking")
@@ -995,7 +996,7 @@
995 try:996 try:
996 target = dir.sprout(self.get_url('target'),997 target = dir.sprout(self.get_url('target'),
997 create_tree_if_local=False)998 create_tree_if_local=False)
998 except errors.MustHaveWorkingTree:999 except controldir.MustHaveWorkingTree:
999 raise TestNotApplicable("control dir format requires working tree")1000 raise TestNotApplicable("control dir format requires working tree")
1000 self.assertPathDoesNotExist('target/foo')1001 self.assertPathDoesNotExist('target/foo')
1001 self.assertEqual(tree.branch.last_revision(),1002 self.assertEqual(tree.branch.last_revision(),
10021003
=== modified file 'breezy/tests/per_foreign_vcs/test_branch.py'
--- breezy/tests/per_foreign_vcs/test_branch.py 2017-06-10 00:52:37 +0000
+++ breezy/tests/per_foreign_vcs/test_branch.py 2017-07-24 01:10:54 +0000
@@ -17,10 +17,11 @@
1717
18"""Tests specific to Branch implementations that use foreign VCS'es."""18"""Tests specific to Branch implementations that use foreign VCS'es."""
1919
2020from breezy.branch import (
21 UnstackableBranchFormat,
22 )
21from breezy.errors import (23from breezy.errors import (
22 IncompatibleFormat,24 IncompatibleFormat,
23 UnstackableBranchFormat,
24 )25 )
25from breezy.revision import (26from breezy.revision import (
26 NULL_REVISION,27 NULL_REVISION,
2728
=== modified file 'breezy/tests/per_workingtree/test_commit.py'
--- breezy/tests/per_workingtree/test_commit.py 2017-06-20 00:26:58 +0000
+++ breezy/tests/per_workingtree/test_commit.py 2017-07-24 01:10:54 +0000
@@ -29,6 +29,11 @@
29 transport as _mod_transport,29 transport as _mod_transport,
30 ui,30 ui,
31 )31 )
32from breezy.commit import (
33 CannotCommitSelectedFileMerge,
34 ExcludesUnsupported,
35 PointlessCommit,
36 )
32from breezy.tests.per_workingtree import TestCaseWithWorkingTree37from breezy.tests.per_workingtree import TestCaseWithWorkingTree
33from breezy.tests.testui import ProgressRecordingUIFactory38from breezy.tests.testui import ProgressRecordingUIFactory
3439
@@ -149,9 +154,9 @@
149 wt2.commit('change_right')154 wt2.commit('change_right')
150 wt.merge_from_branch(wt2.branch)155 wt.merge_from_branch(wt2.branch)
151 try:156 try:
152 self.assertRaises(errors.CannotCommitSelectedFileMerge,157 self.assertRaises(CannotCommitSelectedFileMerge,
153 wt.commit, 'test', exclude=['foo'])158 wt.commit, 'test', exclude=['foo'])
154 except errors.ExcludesUnsupported:159 except ExcludesUnsupported:
155 raise tests.TestNotApplicable("excludes not supported by this "160 raise tests.TestNotApplicable("excludes not supported by this "
156 "repository format")161 "repository format")
157162
@@ -162,9 +167,9 @@
162 tree.commit('setup test')167 tree.commit('setup test')
163 self.build_tree_contents([('a', 'new contents for "a"\n')])168 self.build_tree_contents([('a', 'new contents for "a"\n')])
164 try:169 try:
165 self.assertRaises(errors.PointlessCommit, tree.commit, 'test',170 self.assertRaises(PointlessCommit, tree.commit, 'test',
166 exclude=['a'], allow_pointless=False)171 exclude=['a'], allow_pointless=False)
167 except errors.ExcludesUnsupported:172 except ExcludesUnsupported:
168 raise tests.TestNotApplicable("excludes not supported by this "173 raise tests.TestNotApplicable("excludes not supported by this "
169 "repository format")174 "repository format")
170175
@@ -174,7 +179,7 @@
174 tree.smart_add(['.'])179 tree.smart_add(['.'])
175 try:180 try:
176 tree.commit('test', exclude=['b', 'c'])181 tree.commit('test', exclude=['b', 'c'])
177 except errors.ExcludesUnsupported:182 except ExcludesUnsupported:
178 raise tests.TestNotApplicable("excludes not supported by this "183 raise tests.TestNotApplicable("excludes not supported by this "
179 "repository format")184 "repository format")
180 # If b was excluded it will still be 'added' in status.185 # If b was excluded it will still be 'added' in status.
@@ -458,7 +463,7 @@
458 rev_id = tree.commit('added reference')463 rev_id = tree.commit('added reference')
459 child_revid = subtree.last_revision()464 child_revid = subtree.last_revision()
460 # now do a no-op commit with allow_pointless=False465 # now do a no-op commit with allow_pointless=False
461 self.assertRaises(errors.PointlessCommit, tree.commit, '',466 self.assertRaises(PointlessCommit, tree.commit, '',
462 allow_pointless=False)467 allow_pointless=False)
463 self.assertEqual(child_revid, subtree.last_revision())468 self.assertEqual(child_revid, subtree.last_revision())
464 self.assertEqual(rev_id, tree.last_revision())469 self.assertEqual(rev_id, tree.last_revision())
465470
=== modified file 'breezy/tests/test__dirstate_helpers.py'
--- breezy/tests/test__dirstate_helpers.py 2017-06-10 12:50:32 +0000
+++ breezy/tests/test__dirstate_helpers.py 2017-07-24 01:10:54 +0000
@@ -21,7 +21,6 @@
21import time21import time
2222
23from .. import (23from .. import (
24 errors,
25 osutils,24 osutils,
26 tests,25 tests,
27 )26 )
@@ -724,7 +723,7 @@
724 finally:723 finally:
725 f.close()724 f.close()
726 state.lock_read()725 state.lock_read()
727 e = self.assertRaises(errors.DirstateCorrupt,726 e = self.assertRaises(dirstate.DirstateCorrupt,
728 state._read_dirblocks_if_needed)727 state._read_dirblocks_if_needed)
729 # Make sure we mention the bogus characters in the error728 # Make sure we mention the bogus characters in the error
730 self.assertContainsRe(str(e), 'bogus')729 self.assertContainsRe(str(e), 'bogus')
731730
=== modified file 'breezy/tests/test_branch.py'
--- breezy/tests/test_branch.py 2017-06-10 16:40:42 +0000
+++ breezy/tests/test_branch.py 2017-07-24 01:10:54 +0000
@@ -44,6 +44,18 @@
44 )44 )
4545
4646
47class ErrorTests(tests.TestCase):
48
49 def test_unstackable_branch_format(self):
50 format = u'foo'
51 url = "/foo"
52 error = _mod_branch.UnstackableBranchFormat(format, url)
53 self.assertEqualDiff(
54 "The branch '/foo'(foo) is not a stackable format. "
55 "You will need to upgrade the branch to permit branch stacking.",
56 str(error))
57
58
47class TestDefaultFormat(tests.TestCase):59class TestDefaultFormat(tests.TestCase):
4860
49 def test_default_format(self):61 def test_default_format(self):
@@ -356,12 +368,12 @@
356368
357 def test_set_stacked_on_url_errors(self):369 def test_set_stacked_on_url_errors(self):
358 branch = self.make_branch('a', format=self.get_format_name())370 branch = self.make_branch('a', format=self.get_format_name())
359 self.assertRaises(errors.UnstackableBranchFormat,371 self.assertRaises(_mod_branch.UnstackableBranchFormat,
360 branch.set_stacked_on_url, None)372 branch.set_stacked_on_url, None)
361373
362 def test_default_stacked_location(self):374 def test_default_stacked_location(self):
363 branch = self.make_branch('a', format=self.get_format_name())375 branch = self.make_branch('a', format=self.get_format_name())
364 self.assertRaises(errors.UnstackableBranchFormat, branch.get_stacked_on_url)376 self.assertRaises(_mod_branch.UnstackableBranchFormat, branch.get_stacked_on_url)
365377
366378
367class TestBranch7(TestBranch67, tests.TestCaseWithTransport):379class TestBranch7(TestBranch67, tests.TestCaseWithTransport):
368380
=== modified file 'breezy/tests/test_bzrdir.py'
--- breezy/tests/test_bzrdir.py 2017-07-14 20:49:41 +0000
+++ breezy/tests/test_bzrdir.py 2017-07-24 01:10:54 +0000
@@ -560,14 +560,14 @@
560 child_branch, new_child_transport = self.prepare_default_stacking(560 child_branch, new_child_transport = self.prepare_default_stacking(
561 child_format='pack-0.92')561 child_format='pack-0.92')
562 new_child = child_branch.controldir.clone_on_transport(new_child_transport)562 new_child = child_branch.controldir.clone_on_transport(new_child_transport)
563 self.assertRaises(errors.UnstackableBranchFormat,563 self.assertRaises(branch.UnstackableBranchFormat,
564 new_child.open_branch().get_stacked_on_url)564 new_child.open_branch().get_stacked_on_url)
565565
566 def test_sprout_ignores_policy_for_unsupported_formats(self):566 def test_sprout_ignores_policy_for_unsupported_formats(self):
567 child_branch, new_child_transport = self.prepare_default_stacking(567 child_branch, new_child_transport = self.prepare_default_stacking(
568 child_format='pack-0.92')568 child_format='pack-0.92')
569 new_child = child_branch.controldir.sprout(new_child_transport.base)569 new_child = child_branch.controldir.sprout(new_child_transport.base)
570 self.assertRaises(errors.UnstackableBranchFormat,570 self.assertRaises(branch.UnstackableBranchFormat,
571 new_child.open_branch().get_stacked_on_url)571 new_child.open_branch().get_stacked_on_url)
572572
573 def test_sprout_upgrades_format_if_stacked_specified(self):573 def test_sprout_upgrades_format_if_stacked_specified(self):
@@ -1556,7 +1556,7 @@
1556 # a feature can only be registered once1556 # a feature can only be registered once
1557 self.addCleanup(SampleBzrFormat.unregister_feature, "nested-trees")1557 self.addCleanup(SampleBzrFormat.unregister_feature, "nested-trees")
1558 SampleBzrFormat.register_feature("nested-trees")1558 SampleBzrFormat.register_feature("nested-trees")
1559 self.assertRaises(errors.FeatureAlreadyRegistered,1559 self.assertRaises(bzrdir.FeatureAlreadyRegistered,
1560 SampleBzrFormat.register_feature, "nested-trees")1560 SampleBzrFormat.register_feature, "nested-trees")
15611561
1562 def test_feature_with_space(self):1562 def test_feature_with_space(self):
15631563
=== modified file 'breezy/tests/test_commit.py'
--- breezy/tests/test_commit.py 2017-07-04 20:03:11 +0000
+++ breezy/tests/test_commit.py 2017-07-24 01:10:54 +0000
@@ -26,12 +26,13 @@
26from ..branch import Branch26from ..branch import Branch
27from ..bzr.bzrdir import BzrDirMetaFormat127from ..bzr.bzrdir import BzrDirMetaFormat1
28from ..commit import (28from ..commit import (
29 CannotCommitSelectedFileMerge,
29 Commit,30 Commit,
30 NullCommitReporter,31 NullCommitReporter,
32 PointlessCommit,
31 filter_excluded,33 filter_excluded,
32 )34 )
33from ..errors import (35from ..errors import (
34 PointlessCommit,
35 BzrError,36 BzrError,
36 LockContention,37 LockContention,
37 )38 )
@@ -763,7 +764,7 @@
763 tree.add_parent_tree_id('example')764 tree.add_parent_tree_id('example')
764 self.build_tree(['foo/bar', 'foo/baz'])765 self.build_tree(['foo/bar', 'foo/baz'])
765 tree.add(['bar', 'baz'])766 tree.add(['bar', 'baz'])
766 err = self.assertRaises(errors.CannotCommitSelectedFileMerge,767 err = self.assertRaises(CannotCommitSelectedFileMerge,
767 tree.commit, 'commit 2', specific_files=['bar', 'baz'])768 tree.commit, 'commit 2', specific_files=['bar', 'baz'])
768 self.assertEqual(['bar', 'baz'], err.files)769 self.assertEqual(['bar', 'baz'], err.files)
769 self.assertEqual('Selected-file commit of merges is not supported'770 self.assertEqual('Selected-file commit of merges is not supported'
770771
=== modified file 'breezy/tests/test_controldir.py'
--- breezy/tests/test_controldir.py 2017-06-13 10:58:02 +0000
+++ breezy/tests/test_controldir.py 2017-07-24 01:10:54 +0000
@@ -31,6 +31,14 @@
31load_tests = load_tests_apply_scenarios31load_tests = load_tests_apply_scenarios
3232
3333
34class ErrorTests(tests.TestCase):
35
36 def test_must_have_working_tree(self):
37 err = controldir.MustHaveWorkingTree('foo', 'bar')
38 self.assertEqual(str(err), "Branching 'bar'(foo) must create a"
39 " working tree.")
40
41
34class SampleComponentFormat(controldir.ControlComponentFormat):42class SampleComponentFormat(controldir.ControlComponentFormat):
3543
36 def get_format_string(self):44 def get_format_string(self):
3745
=== modified file 'breezy/tests/test_directory_service.py'
--- breezy/tests/test_directory_service.py 2017-06-10 00:17:06 +0000
+++ breezy/tests/test_directory_service.py 2017-07-24 01:10:54 +0000
@@ -17,13 +17,14 @@
17"""Test directory service implementation"""17"""Test directory service implementation"""
1818
19from .. import (19from .. import (
20 errors,
21 transport,20 transport,
22 urlutils,21 urlutils,
23 )22 )
24from ..directory_service import (23from ..directory_service import (
25 AliasDirectory,24 AliasDirectory,
26 DirectoryServiceRegistry,25 DirectoryServiceRegistry,
26 InvalidLocationAlias,
27 UnsetLocationAlias,
27 directories,28 directories,
28 )29 )
29from . import TestCase, TestCaseWithTransport30from . import TestCase, TestCaseWithTransport
@@ -101,13 +102,13 @@
101 directories.dereference(':this/arg'))102 directories.dereference(':this/arg'))
102103
103 def test_lookup_badname(self):104 def test_lookup_badname(self):
104 e = self.assertRaises(errors.InvalidLocationAlias,105 e = self.assertRaises(InvalidLocationAlias,
105 directories.dereference, ':booga')106 directories.dereference, ':booga')
106 self.assertEqual('":booga" is not a valid location alias.',107 self.assertEqual('":booga" is not a valid location alias.',
107 str(e))108 str(e))
108109
109 def test_lookup_badvalue(self):110 def test_lookup_badvalue(self):
110 e = self.assertRaises(errors.UnsetLocationAlias,111 e = self.assertRaises(UnsetLocationAlias,
111 directories.dereference, ':parent')112 directories.dereference, ':parent')
112 self.assertEqual('No parent location assigned.', str(e))113 self.assertEqual('No parent location assigned.', str(e))
113114
114115
=== modified file 'breezy/tests/test_dirstate.py'
--- breezy/tests/test_dirstate.py 2017-06-11 01:22:16 +0000
+++ breezy/tests/test_dirstate.py 2017-07-24 01:10:54 +0000
@@ -54,6 +54,16 @@
54# set_path_id setting id when state is in memory modified54# set_path_id setting id when state is in memory modified
5555
5656
57class ErrorTests(tests.TestCase):
58
59 def test_dirstate_corrupt(self):
60 error = dirstate.DirstateCorrupt('.bzr/checkout/dirstate',
61 'trailing garbage: "x"')
62 self.assertEqualDiff("The dirstate file (.bzr/checkout/dirstate)"
63 " appears to be corrupt: trailing garbage: \"x\"",
64 str(error))
65
66
57load_tests = load_tests_apply_scenarios67load_tests = load_tests_apply_scenarios
5868
5969
6070
=== modified file 'breezy/tests/test_errors.py'
--- breezy/tests/test_errors.py 2017-07-24 01:07:36 +0000
+++ breezy/tests/test_errors.py 2017-07-24 01:10:54 +0000
@@ -63,20 +63,6 @@
63 "^Filename b?'bad/filen\\\\xe5me' is not valid in your current"63 "^Filename b?'bad/filen\\\\xe5me' is not valid in your current"
64 " filesystem encoding UTF-8$")64 " filesystem encoding UTF-8$")
6565
66 def test_corrupt_dirstate(self):
67 error = errors.CorruptDirstate('path/to/dirstate', 'the reason why')
68 self.assertEqualDiff(
69 "Inconsistency in dirstate file path/to/dirstate.\n"
70 "Error: the reason why",
71 str(error))
72
73 def test_dirstate_corrupt(self):
74 error = errors.DirstateCorrupt('.bzr/checkout/dirstate',
75 'trailing garbage: "x"')
76 self.assertEqualDiff("The dirstate file (.bzr/checkout/dirstate)"
77 " appears to be corrupt: trailing garbage: \"x\"",
78 str(error))
79
80 def test_duplicate_file_id(self):66 def test_duplicate_file_id(self):
81 error = errors.DuplicateFileId('a_file_id', 'foo')67 error = errors.DuplicateFileId('a_file_id', 'foo')
82 self.assertEqualDiff('File id {a_file_id} already exists in inventory'68 self.assertEqualDiff('File id {a_file_id} already exists in inventory'
@@ -239,25 +225,6 @@
239 "('key',) which is encoded as 'fulltext'.",225 "('key',) which is encoded as 'fulltext'.",
240 str(error))226 str(error))
241227
242 def test_unknown_hook(self):
243 error = errors.UnknownHook("branch", "foo")
244 self.assertEqualDiff("The branch hook 'foo' is unknown in this version"
245 " of breezy.",
246 str(error))
247 error = errors.UnknownHook("tree", "bar")
248 self.assertEqualDiff("The tree hook 'bar' is unknown in this version"
249 " of breezy.",
250 str(error))
251
252 def test_unstackable_branch_format(self):
253 format = u'foo'
254 url = "/foo"
255 error = errors.UnstackableBranchFormat(format, url)
256 self.assertEqualDiff(
257 "The branch '/foo'(foo) is not a stackable format. "
258 "You will need to upgrade the branch to permit branch stacking.",
259 str(error))
260
261 def test_unstackable_location(self):228 def test_unstackable_location(self):
262 error = errors.UnstackableLocationError('foo', 'bar')229 error = errors.UnstackableLocationError('foo', 'bar')
263 self.assertEqualDiff("The branch 'foo' cannot be stacked on 'bar'.",230 self.assertEqualDiff("The branch 'foo' cannot be stacked on 'bar'.",
@@ -501,10 +468,6 @@
501 err = errors.UnknownFormatError('bar', kind='foo')468 err = errors.UnknownFormatError('bar', kind='foo')
502 self.assertEqual("Unknown foo format: 'bar'", str(err))469 self.assertEqual("Unknown foo format: 'bar'", str(err))
503470
504 def test_unknown_rules(self):
505 err = errors.UnknownRules(['foo', 'bar'])
506 self.assertEqual("Unknown rules detected: foo, bar.", str(err))
507
508 def test_tip_change_rejected(self):471 def test_tip_change_rejected(self):
509 err = errors.TipChangeRejected(u'Unicode message\N{INTERROBANG}')472 err = errors.TipChangeRejected(u'Unicode message\N{INTERROBANG}')
510 self.assertEqual(473 self.assertEqual(
@@ -538,11 +501,6 @@
538 finally:501 finally:
539 del err502 del err
540503
541 def test_must_have_working_tree(self):
542 err = errors.MustHaveWorkingTree('foo', 'bar')
543 self.assertEqual(str(err), "Branching 'bar'(foo) must create a"
544 " working tree.")
545
546 def test_unresumable_write_group(self):504 def test_unresumable_write_group(self):
547 repo = "dummy repo"505 repo = "dummy repo"
548 wg_tokens = ['token']506 wg_tokens = ['token']
549507
=== modified file 'breezy/tests/test_hooks.py'
--- breezy/tests/test_hooks.py 2017-05-30 19:16:23 +0000
+++ breezy/tests/test_hooks.py 2017-07-24 01:10:54 +0000
@@ -26,12 +26,26 @@
26from ..hooks import (26from ..hooks import (
27 HookPoint,27 HookPoint,
28 Hooks,28 Hooks,
29 UnknownHook,
29 install_lazy_named_hook,30 install_lazy_named_hook,
30 known_hooks,31 known_hooks,
31 known_hooks_key_to_object,32 known_hooks_key_to_object,
32 )33 )
3334
3435
36class TestErrors(tests.TestCase):
37
38 def test_unknown_hook(self):
39 error = UnknownHook("branch", "foo")
40 self.assertEqualDiff("The branch hook 'foo' is unknown in this version"
41 " of breezy.",
42 str(error))
43 error = UnknownHook("tree", "bar")
44 self.assertEqualDiff("The tree hook 'bar' is unknown in this version"
45 " of breezy.",
46 str(error))
47
48
35class TestHooks(tests.TestCase):49class TestHooks(tests.TestCase):
3650
37 def test_docs(self):51 def test_docs(self):
@@ -76,7 +90,7 @@
7690
77 def test_install_named_hook_raises_unknown_hook(self):91 def test_install_named_hook_raises_unknown_hook(self):
78 hooks = Hooks("breezy.tests.test_hooks", "some_hooks")92 hooks = Hooks("breezy.tests.test_hooks", "some_hooks")
79 self.assertRaises(errors.UnknownHook, hooks.install_named_hook, 'silly',93 self.assertRaises(UnknownHook, hooks.install_named_hook, 'silly',
80 None, "")94 None, "")
8195
82 def test_install_named_hook_appends_known_hook(self):96 def test_install_named_hook_appends_known_hook(self):
@@ -118,8 +132,7 @@
118132
119 def test_uninstall_named_hook_raises_unknown_hook(self):133 def test_uninstall_named_hook_raises_unknown_hook(self):
120 hooks = Hooks("breezy.tests.test_hooks", "some_hooks")134 hooks = Hooks("breezy.tests.test_hooks", "some_hooks")
121 self.assertRaises(errors.UnknownHook, hooks.uninstall_named_hook,135 self.assertRaises(UnknownHook, hooks.uninstall_named_hook, 'silly', "")
122 'silly', "")
123136
124 def test_uninstall_named_hook_old_style(self):137 def test_uninstall_named_hook_old_style(self):
125 hooks = Hooks("breezy.tests.test_hooks", "some_hooks")138 hooks = Hooks("breezy.tests.test_hooks", "some_hooks")
126139
=== modified file 'breezy/tests/test_index.py'
--- breezy/tests/test_index.py 2017-06-08 23:30:31 +0000
+++ breezy/tests/test_index.py 2017-07-24 01:10:54 +0000
@@ -22,14 +22,14 @@
22 transport,22 transport,
23 )23 )
24from ..bzr import (24from ..bzr import (
25 index,25 index as _mod_index,
26 )26 )
2727
2828
29class TestGraphIndexBuilder(tests.TestCaseWithMemoryTransport):29class TestGraphIndexBuilder(tests.TestCaseWithMemoryTransport):
3030
31 def test_build_index_empty(self):31 def test_build_index_empty(self):
32 builder = index.GraphIndexBuilder()32 builder = _mod_index.GraphIndexBuilder()
33 stream = builder.finish()33 stream = builder.finish()
34 contents = stream.read()34 contents = stream.read()
35 self.assertEqual(35 self.assertEqual(
@@ -37,7 +37,7 @@
37 contents)37 contents)
3838
39 def test_build_index_empty_two_element_keys(self):39 def test_build_index_empty_two_element_keys(self):
40 builder = index.GraphIndexBuilder(key_elements=2)40 builder = _mod_index.GraphIndexBuilder(key_elements=2)
41 stream = builder.finish()41 stream = builder.finish()
42 contents = stream.read()42 contents = stream.read()
43 self.assertEqual(43 self.assertEqual(
@@ -45,7 +45,7 @@
45 contents)45 contents)
4646
47 def test_build_index_one_reference_list_empty(self):47 def test_build_index_one_reference_list_empty(self):
48 builder = index.GraphIndexBuilder(reference_lists=1)48 builder = _mod_index.GraphIndexBuilder(reference_lists=1)
49 stream = builder.finish()49 stream = builder.finish()
50 contents = stream.read()50 contents = stream.read()
51 self.assertEqual(51 self.assertEqual(
@@ -53,7 +53,7 @@
53 contents)53 contents)
5454
55 def test_build_index_two_reference_list_empty(self):55 def test_build_index_two_reference_list_empty(self):
56 builder = index.GraphIndexBuilder(reference_lists=2)56 builder = _mod_index.GraphIndexBuilder(reference_lists=2)
57 stream = builder.finish()57 stream = builder.finish()
58 contents = stream.read()58 contents = stream.read()
59 self.assertEqual(59 self.assertEqual(
@@ -61,7 +61,7 @@
61 contents)61 contents)
6262
63 def test_build_index_one_node_no_refs(self):63 def test_build_index_one_node_no_refs(self):
64 builder = index.GraphIndexBuilder()64 builder = _mod_index.GraphIndexBuilder()
65 builder.add_node(('akey', ), 'data')65 builder.add_node(('akey', ), 'data')
66 stream = builder.finish()66 stream = builder.finish()
67 contents = stream.read()67 contents = stream.read()
@@ -70,7 +70,7 @@
70 "akey\x00\x00\x00data\n\n", contents)70 "akey\x00\x00\x00data\n\n", contents)
7171
72 def test_build_index_one_node_no_refs_accepts_empty_reflist(self):72 def test_build_index_one_node_no_refs_accepts_empty_reflist(self):
73 builder = index.GraphIndexBuilder()73 builder = _mod_index.GraphIndexBuilder()
74 builder.add_node(('akey', ), 'data', ())74 builder.add_node(('akey', ), 'data', ())
75 stream = builder.finish()75 stream = builder.finish()
76 contents = stream.read()76 contents = stream.read()
@@ -82,7 +82,7 @@
82 # multipart keys are separated by \x00 - because they are fixed length,82 # multipart keys are separated by \x00 - because they are fixed length,
83 # not variable this does not cause any issues, and seems clearer to the83 # not variable this does not cause any issues, and seems clearer to the
84 # author.84 # author.
85 builder = index.GraphIndexBuilder(key_elements=2)85 builder = _mod_index.GraphIndexBuilder(key_elements=2)
86 builder.add_node(('akey', 'secondpart'), 'data')86 builder.add_node(('akey', 'secondpart'), 'data')
87 stream = builder.finish()87 stream = builder.finish()
88 contents = stream.read()88 contents = stream.read()
@@ -91,7 +91,7 @@
91 "akey\x00secondpart\x00\x00\x00data\n\n", contents)91 "akey\x00secondpart\x00\x00\x00data\n\n", contents)
9292
93 def test_add_node_empty_value(self):93 def test_add_node_empty_value(self):
94 builder = index.GraphIndexBuilder()94 builder = _mod_index.GraphIndexBuilder()
95 builder.add_node(('akey', ), '')95 builder.add_node(('akey', ), '')
96 stream = builder.finish()96 stream = builder.finish()
97 contents = stream.read()97 contents = stream.read()
@@ -101,7 +101,7 @@
101101
102 def test_build_index_nodes_sorted(self):102 def test_build_index_nodes_sorted(self):
103 # the highest sorted node comes first.103 # the highest sorted node comes first.
104 builder = index.GraphIndexBuilder()104 builder = _mod_index.GraphIndexBuilder()
105 # use three to have a good chance of glitching dictionary hash105 # use three to have a good chance of glitching dictionary hash
106 # lookups etc. Insert in randomish order that is not correct106 # lookups etc. Insert in randomish order that is not correct
107 # and not the reverse of the correct order.107 # and not the reverse of the correct order.
@@ -119,7 +119,7 @@
119119
120 def test_build_index_2_element_key_nodes_sorted(self):120 def test_build_index_2_element_key_nodes_sorted(self):
121 # multiple element keys are sorted first-key, second-key.121 # multiple element keys are sorted first-key, second-key.
122 builder = index.GraphIndexBuilder(key_elements=2)122 builder = _mod_index.GraphIndexBuilder(key_elements=2)
123 # use three values of each key element, to have a good chance of123 # use three values of each key element, to have a good chance of
124 # glitching dictionary hash lookups etc. Insert in randomish order that124 # glitching dictionary hash lookups etc. Insert in randomish order that
125 # is not correct and not the reverse of the correct order.125 # is not correct and not the reverse of the correct order.
@@ -148,7 +148,7 @@
148 "\n", contents)148 "\n", contents)
149149
150 def test_build_index_reference_lists_are_included_one(self):150 def test_build_index_reference_lists_are_included_one(self):
151 builder = index.GraphIndexBuilder(reference_lists=1)151 builder = _mod_index.GraphIndexBuilder(reference_lists=1)
152 builder.add_node(('key', ), 'data', ([], ))152 builder.add_node(('key', ), 'data', ([], ))
153 stream = builder.finish()153 stream = builder.finish()
154 contents = stream.read()154 contents = stream.read()
@@ -158,7 +158,7 @@
158 "\n", contents)158 "\n", contents)
159159
160 def test_build_index_reference_lists_with_2_element_keys(self):160 def test_build_index_reference_lists_with_2_element_keys(self):
161 builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2)161 builder = _mod_index.GraphIndexBuilder(reference_lists=1, key_elements=2)
162 builder.add_node(('key', 'key2'), 'data', ([], ))162 builder.add_node(('key', 'key2'), 'data', ([], ))
163 stream = builder.finish()163 stream = builder.finish()
164 contents = stream.read()164 contents = stream.read()
@@ -168,7 +168,7 @@
168 "\n", contents)168 "\n", contents)
169169
170 def test_build_index_reference_lists_are_included_two(self):170 def test_build_index_reference_lists_are_included_two(self):
171 builder = index.GraphIndexBuilder(reference_lists=2)171 builder = _mod_index.GraphIndexBuilder(reference_lists=2)
172 builder.add_node(('key', ), 'data', ([], []))172 builder.add_node(('key', ), 'data', ([], []))
173 stream = builder.finish()173 stream = builder.finish()
174 contents = stream.read()174 contents = stream.read()
@@ -178,12 +178,12 @@
178 "\n", contents)178 "\n", contents)
179179
180 def test_clear_cache(self):180 def test_clear_cache(self):
181 builder = index.GraphIndexBuilder(reference_lists=2)181 builder = _mod_index.GraphIndexBuilder(reference_lists=2)
182 # This is a no-op, but the api should exist182 # This is a no-op, but the api should exist
183 builder.clear_cache()183 builder.clear_cache()
184184
185 def test_node_references_are_byte_offsets(self):185 def test_node_references_are_byte_offsets(self):
186 builder = index.GraphIndexBuilder(reference_lists=1)186 builder = _mod_index.GraphIndexBuilder(reference_lists=1)
187 builder.add_node(('reference', ), 'data', ([], ))187 builder.add_node(('reference', ), 'data', ([], ))
188 builder.add_node(('key', ), 'data', ([('reference', )], ))188 builder.add_node(('key', ), 'data', ([('reference', )], ))
189 stream = builder.finish()189 stream = builder.finish()
@@ -195,7 +195,7 @@
195 "\n", contents)195 "\n", contents)
196196
197 def test_node_references_are_cr_delimited(self):197 def test_node_references_are_cr_delimited(self):
198 builder = index.GraphIndexBuilder(reference_lists=1)198 builder = _mod_index.GraphIndexBuilder(reference_lists=1)
199 builder.add_node(('reference', ), 'data', ([], ))199 builder.add_node(('reference', ), 'data', ([], ))
200 builder.add_node(('reference2', ), 'data', ([], ))200 builder.add_node(('reference2', ), 'data', ([], ))
201 builder.add_node(('key', ), 'data',201 builder.add_node(('key', ), 'data',
@@ -210,7 +210,7 @@
210 "\n", contents)210 "\n", contents)
211211
212 def test_multiple_reference_lists_are_tab_delimited(self):212 def test_multiple_reference_lists_are_tab_delimited(self):
213 builder = index.GraphIndexBuilder(reference_lists=2)213 builder = _mod_index.GraphIndexBuilder(reference_lists=2)
214 builder.add_node(('keference', ), 'data', ([], []))214 builder.add_node(('keference', ), 'data', ([], []))
215 builder.add_node(('rey', ), 'data',215 builder.add_node(('rey', ), 'data',
216 ([('keference', )], [('keference', )]))216 ([('keference', )], [('keference', )]))
@@ -223,7 +223,7 @@
223 "\n", contents)223 "\n", contents)
224224
225 def test_add_node_referencing_missing_key_makes_absent(self):225 def test_add_node_referencing_missing_key_makes_absent(self):
226 builder = index.GraphIndexBuilder(reference_lists=1)226 builder = _mod_index.GraphIndexBuilder(reference_lists=1)
227 builder.add_node(('rey', ), 'data',227 builder.add_node(('rey', ), 'data',
228 ([('beference', ), ('aeference2', )], ))228 ([('beference', ), ('aeference2', )], ))
229 stream = builder.finish()229 stream = builder.finish()
@@ -237,7 +237,7 @@
237237
238 def test_node_references_three_digits(self):238 def test_node_references_three_digits(self):
239 # test the node digit expands as needed.239 # test the node digit expands as needed.
240 builder = index.GraphIndexBuilder(reference_lists=1)240 builder = _mod_index.GraphIndexBuilder(reference_lists=1)
241 references = [(str(val), ) for val in range(8, -1, -1)]241 references = [(str(val), ) for val in range(8, -1, -1)]
242 builder.add_node(('2-key', ), '', (references, ))242 builder.add_node(('2-key', ), '', (references, ))
243 stream = builder.finish()243 stream = builder.finish()
@@ -259,7 +259,7 @@
259 def test_absent_has_no_reference_overhead(self):259 def test_absent_has_no_reference_overhead(self):
260 # the offsets after an absent record should be correct when there are260 # the offsets after an absent record should be correct when there are
261 # >1 reference lists.261 # >1 reference lists.
262 builder = index.GraphIndexBuilder(reference_lists=2)262 builder = _mod_index.GraphIndexBuilder(reference_lists=2)
263 builder.add_node(('parent', ), '', ([('aail', ), ('zther', )], []))263 builder.add_node(('parent', ), '', ([('aail', ), ('zther', )], []))
264 stream = builder.finish()264 stream = builder.finish()
265 contents = stream.read()265 contents = stream.read()
@@ -271,99 +271,99 @@
271 "\n", contents)271 "\n", contents)
272272
273 def test_add_node_bad_key(self):273 def test_add_node_bad_key(self):
274 builder = index.GraphIndexBuilder()274 builder = _mod_index.GraphIndexBuilder()
275 for bad_char in '\t\n\x0b\x0c\r\x00 ':275 for bad_char in '\t\n\x0b\x0c\r\x00 ':
276 self.assertRaises(errors.BadIndexKey, builder.add_node,276 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
277 ('a%skey' % bad_char, ), 'data')277 ('a%skey' % bad_char, ), 'data')
278 self.assertRaises(errors.BadIndexKey, builder.add_node,278 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
279 ('', ), 'data')279 ('', ), 'data')
280 self.assertRaises(errors.BadIndexKey, builder.add_node,280 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
281 'not-a-tuple', 'data')281 'not-a-tuple', 'data')
282 # not enough length282 # not enough length
283 self.assertRaises(errors.BadIndexKey, builder.add_node,283 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
284 (), 'data')284 (), 'data')
285 # too long285 # too long
286 self.assertRaises(errors.BadIndexKey, builder.add_node,286 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
287 ('primary', 'secondary'), 'data')287 ('primary', 'secondary'), 'data')
288 # secondary key elements get checked too:288 # secondary key elements get checked too:
289 builder = index.GraphIndexBuilder(key_elements=2)289 builder = _mod_index.GraphIndexBuilder(key_elements=2)
290 for bad_char in '\t\n\x0b\x0c\r\x00 ':290 for bad_char in '\t\n\x0b\x0c\r\x00 ':
291 self.assertRaises(errors.BadIndexKey, builder.add_node,291 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
292 ('prefix', 'a%skey' % bad_char), 'data')292 ('prefix', 'a%skey' % bad_char), 'data')
293293
294 def test_add_node_bad_data(self):294 def test_add_node_bad_data(self):
295 builder = index.GraphIndexBuilder()295 builder = _mod_index.GraphIndexBuilder()
296 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),296 self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ),
297 'data\naa')297 'data\naa')
298 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),298 self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ),
299 'data\x00aa')299 'data\x00aa')
300300
301 def test_add_node_bad_mismatched_ref_lists_length(self):301 def test_add_node_bad_mismatched_ref_lists_length(self):
302 builder = index.GraphIndexBuilder()302 builder = _mod_index.GraphIndexBuilder()
303 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),303 self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ),
304 'data aa', ([], ))304 'data aa', ([], ))
305 builder = index.GraphIndexBuilder(reference_lists=1)305 builder = _mod_index.GraphIndexBuilder(reference_lists=1)
306 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),306 self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ),
307 'data aa')307 'data aa')
308 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),308 self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ),
309 'data aa', (), )309 'data aa', (), )
310 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),310 self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ),
311 'data aa', ([], []))311 'data aa', ([], []))
312 builder = index.GraphIndexBuilder(reference_lists=2)312 builder = _mod_index.GraphIndexBuilder(reference_lists=2)
313 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),313 self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ),
314 'data aa')314 'data aa')
315 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),315 self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ),
316 'data aa', ([], ))316 'data aa', ([], ))
317 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),317 self.assertRaises(_mod_index.BadIndexValue, builder.add_node, ('akey', ),
318 'data aa', ([], [], []))318 'data aa', ([], [], []))
319319
320 def test_add_node_bad_key_in_reference_lists(self):320 def test_add_node_bad_key_in_reference_lists(self):
321 # first list, first key - trivial321 # first list, first key - trivial
322 builder = index.GraphIndexBuilder(reference_lists=1)322 builder = _mod_index.GraphIndexBuilder(reference_lists=1)
323 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),323 self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ),
324 'data aa', ([('a key', )], ))324 'data aa', ([('a key', )], ))
325 # references keys must be tuples too325 # references keys must be tuples too
326 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),326 self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ),
327 'data aa', (['not-a-tuple'], ))327 'data aa', (['not-a-tuple'], ))
328 # not enough length328 # not enough length
329 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),329 self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ),
330 'data aa', ([()], ))330 'data aa', ([()], ))
331 # too long331 # too long
332 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),332 self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ),
333 'data aa', ([('primary', 'secondary')], ))333 'data aa', ([('primary', 'secondary')], ))
334 # need to check more than the first key in the list334 # need to check more than the first key in the list
335 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),335 self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ),
336 'data aa', ([('agoodkey', ), ('that is a bad key', )], ))336 'data aa', ([('agoodkey', ), ('that is a bad key', )], ))
337 # and if there is more than one list it should be getting checked337 # and if there is more than one list it should be getting checked
338 # too338 # too
339 builder = index.GraphIndexBuilder(reference_lists=2)339 builder = _mod_index.GraphIndexBuilder(reference_lists=2)
340 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),340 self.assertRaises(_mod_index.BadIndexKey, builder.add_node, ('akey', ),
341 'data aa', ([], ['a bad key']))341 'data aa', ([], ['a bad key']))
342342
343 def test_add_duplicate_key(self):343 def test_add_duplicate_key(self):
344 builder = index.GraphIndexBuilder()344 builder = _mod_index.GraphIndexBuilder()
345 builder.add_node(('key', ), 'data')345 builder.add_node(('key', ), 'data')
346 self.assertRaises(errors.BadIndexDuplicateKey,346 self.assertRaises(_mod_index.BadIndexDuplicateKey,
347 builder.add_node, ('key', ), 'data')347 builder.add_node, ('key', ), 'data')
348348
349 def test_add_duplicate_key_2_elements(self):349 def test_add_duplicate_key_2_elements(self):
350 builder = index.GraphIndexBuilder(key_elements=2)350 builder = _mod_index.GraphIndexBuilder(key_elements=2)
351 builder.add_node(('key', 'key'), 'data')351 builder.add_node(('key', 'key'), 'data')
352 self.assertRaises(errors.BadIndexDuplicateKey, builder.add_node,352 self.assertRaises(_mod_index.BadIndexDuplicateKey, builder.add_node,
353 ('key', 'key'), 'data')353 ('key', 'key'), 'data')
354354
355 def test_add_key_after_referencing_key(self):355 def test_add_key_after_referencing_key(self):
356 builder = index.GraphIndexBuilder(reference_lists=1)356 builder = _mod_index.GraphIndexBuilder(reference_lists=1)
357 builder.add_node(('key', ), 'data', ([('reference', )], ))357 builder.add_node(('key', ), 'data', ([('reference', )], ))
358 builder.add_node(('reference', ), 'data', ([],))358 builder.add_node(('reference', ), 'data', ([],))
359359
360 def test_add_key_after_referencing_key_2_elements(self):360 def test_add_key_after_referencing_key_2_elements(self):
361 builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2)361 builder = _mod_index.GraphIndexBuilder(reference_lists=1, key_elements=2)
362 builder.add_node(('k', 'ey'), 'data', ([('reference', 'tokey')], ))362 builder.add_node(('k', 'ey'), 'data', ([('reference', 'tokey')], ))
363 builder.add_node(('reference', 'tokey'), 'data', ([],))363 builder.add_node(('reference', 'tokey'), 'data', ([],))
364364
365 def test_set_optimize(self):365 def test_set_optimize(self):
366 builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2)366 builder = _mod_index.GraphIndexBuilder(reference_lists=1, key_elements=2)
367 builder.set_optimize(for_size=True)367 builder.set_optimize(for_size=True)
368 self.assertTrue(builder._optimize_for_size)368 self.assertTrue(builder._optimize_for_size)
369 builder.set_optimize(for_size=False)369 builder.set_optimize(for_size=False)
@@ -387,24 +387,24 @@
387 return nodes387 return nodes
388388
389 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):389 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):
390 builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements)390 builder = _mod_index.GraphIndexBuilder(ref_lists, key_elements=key_elements)
391 for key, value, references in nodes:391 for key, value, references in nodes:
392 builder.add_node(key, value, references)392 builder.add_node(key, value, references)
393 stream = builder.finish()393 stream = builder.finish()
394 trans = transport.get_transport_from_url('trace+' + self.get_url())394 trans = transport.get_transport_from_url('trace+' + self.get_url())
395 size = trans.put_file('index', stream)395 size = trans.put_file('index', stream)
396 return index.GraphIndex(trans, 'index', size)396 return _mod_index.GraphIndex(trans, 'index', size)
397397
398 def make_index_with_offset(self, ref_lists=0, key_elements=1, nodes=[],398 def make_index_with_offset(self, ref_lists=0, key_elements=1, nodes=[],
399 offset=0):399 offset=0):
400 builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements)400 builder = _mod_index.GraphIndexBuilder(ref_lists, key_elements=key_elements)
401 for key, value, references in nodes:401 for key, value, references in nodes:
402 builder.add_node(key, value, references)402 builder.add_node(key, value, references)
403 content = builder.finish().read()403 content = builder.finish().read()
404 size = len(content)404 size = len(content)
405 trans = self.get_transport()405 trans = self.get_transport()
406 trans.put_bytes('index', (' '*offset) + content)406 trans.put_bytes('index', (' '*offset) + content)
407 return index.GraphIndex(trans, 'index', size, offset=offset)407 return _mod_index.GraphIndex(trans, 'index', size, offset=offset)
408408
409 def test_clear_cache(self):409 def test_clear_cache(self):
410 index = self.make_index()410 index = self.make_index()
@@ -415,7 +415,7 @@
415 def test_open_bad_index_no_error(self):415 def test_open_bad_index_no_error(self):
416 trans = self.get_transport()416 trans = self.get_transport()
417 trans.put_bytes('name', "not an index\n")417 trans.put_bytes('name', "not an index\n")
418 idx = index.GraphIndex(trans, 'name', 13)418 idx = _mod_index.GraphIndex(trans, 'name', 13)
419419
420 def test_with_offset(self):420 def test_with_offset(self):
421 nodes = self.make_nodes(200)421 nodes = self.make_nodes(200)
@@ -838,22 +838,22 @@
838838
839 def test_iter_missing_entry_empty_no_size(self):839 def test_iter_missing_entry_empty_no_size(self):
840 idx = self.make_index()840 idx = self.make_index()
841 idx = index.GraphIndex(idx._transport, 'index', None)841 idx = _mod_index.GraphIndex(idx._transport, 'index', None)
842 self.assertEqual([], list(idx.iter_entries([('a', )])))842 self.assertEqual([], list(idx.iter_entries([('a', )])))
843843
844 def test_iter_key_prefix_1_element_key_None(self):844 def test_iter_key_prefix_1_element_key_None(self):
845 index = self.make_index()845 index = self.make_index()
846 self.assertRaises(errors.BadIndexKey, list,846 self.assertRaises(_mod_index.BadIndexKey, list,
847 index.iter_entries_prefix([(None, )]))847 index.iter_entries_prefix([(None, )]))
848848
849 def test_iter_key_prefix_wrong_length(self):849 def test_iter_key_prefix_wrong_length(self):
850 index = self.make_index()850 index = self.make_index()
851 self.assertRaises(errors.BadIndexKey, list,851 self.assertRaises(_mod_index.BadIndexKey, list,
852 index.iter_entries_prefix([('foo', None)]))852 index.iter_entries_prefix([('foo', None)]))
853 index = self.make_index(key_elements=2)853 index = self.make_index(key_elements=2)
854 self.assertRaises(errors.BadIndexKey, list,854 self.assertRaises(_mod_index.BadIndexKey, list,
855 index.iter_entries_prefix([('foo', )]))855 index.iter_entries_prefix([('foo', )]))
856 self.assertRaises(errors.BadIndexKey, list,856 self.assertRaises(_mod_index.BadIndexKey, list,
857 index.iter_entries_prefix([('foo', None, None)]))857 index.iter_entries_prefix([('foo', None, None)]))
858858
859 def test_iter_key_prefix_1_key_element_no_refs(self):859 def test_iter_key_prefix_1_key_element_no_refs(self):
@@ -935,8 +935,8 @@
935 def test_validate_bad_index_errors(self):935 def test_validate_bad_index_errors(self):
936 trans = self.get_transport()936 trans = self.get_transport()
937 trans.put_bytes('name', "not an index\n")937 trans.put_bytes('name', "not an index\n")
938 idx = index.GraphIndex(trans, 'name', 13)938 idx = _mod_index.GraphIndex(trans, 'name', 13)
939 self.assertRaises(errors.BadIndexFormatSignature, idx.validate)939 self.assertRaises(_mod_index.BadIndexFormatSignature, idx.validate)
940940
941 def test_validate_bad_node_refs(self):941 def test_validate_bad_node_refs(self):
942 idx = self.make_index(2)942 idx = self.make_index(2)
@@ -945,7 +945,7 @@
945 # change the options line to end with a rather than a parseable number945 # change the options line to end with a rather than a parseable number
946 new_content = content[:-2] + 'a\n\n'946 new_content = content[:-2] + 'a\n\n'
947 trans.put_bytes('index', new_content)947 trans.put_bytes('index', new_content)
948 self.assertRaises(errors.BadIndexOptions, idx.validate)948 self.assertRaises(_mod_index.BadIndexOptions, idx.validate)
949949
950 def test_validate_missing_end_line_empty(self):950 def test_validate_missing_end_line_empty(self):
951 index = self.make_index(2)951 index = self.make_index(2)
@@ -953,7 +953,7 @@
953 content = trans.get_bytes('index')953 content = trans.get_bytes('index')
954 # truncate the last byte954 # truncate the last byte
955 trans.put_bytes('index', content[:-1])955 trans.put_bytes('index', content[:-1])
956 self.assertRaises(errors.BadIndexData, index.validate)956 self.assertRaises(_mod_index.BadIndexData, index.validate)
957957
958 def test_validate_missing_end_line_nonempty(self):958 def test_validate_missing_end_line_nonempty(self):
959 index = self.make_index(2, nodes=[(('key', ), '', ([], []))])959 index = self.make_index(2, nodes=[(('key', ), '', ([], []))])
@@ -961,7 +961,7 @@
961 content = trans.get_bytes('index')961 content = trans.get_bytes('index')
962 # truncate the last byte962 # truncate the last byte
963 trans.put_bytes('index', content[:-1])963 trans.put_bytes('index', content[:-1])
964 self.assertRaises(errors.BadIndexData, index.validate)964 self.assertRaises(_mod_index.BadIndexData, index.validate)
965965
966 def test_validate_empty(self):966 def test_validate_empty(self):
967 index = self.make_index()967 index = self.make_index()
@@ -1056,25 +1056,25 @@
1056 self.assertEqual(set(), search_keys)1056 self.assertEqual(set(), search_keys)
10571057
1058 def test_supports_unlimited_cache(self):1058 def test_supports_unlimited_cache(self):
1059 builder = index.GraphIndexBuilder(0, key_elements=1)1059 builder = _mod_index.GraphIndexBuilder(0, key_elements=1)
1060 stream = builder.finish()1060 stream = builder.finish()
1061 trans = self.get_transport()1061 trans = self.get_transport()
1062 size = trans.put_file('index', stream)1062 size = trans.put_file('index', stream)
1063 # It doesn't matter what unlimited_cache does here, just that it can be1063 # It doesn't matter what unlimited_cache does here, just that it can be
1064 # passed1064 # passed
1065 idx = index.GraphIndex(trans, 'index', size, unlimited_cache=True)1065 idx = _mod_index.GraphIndex(trans, 'index', size, unlimited_cache=True)
10661066
10671067
1068class TestCombinedGraphIndex(tests.TestCaseWithMemoryTransport):1068class TestCombinedGraphIndex(tests.TestCaseWithMemoryTransport):
10691069
1070 def make_index(self, name, ref_lists=0, key_elements=1, nodes=[]):1070 def make_index(self, name, ref_lists=0, key_elements=1, nodes=[]):
1071 builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements)1071 builder = _mod_index.GraphIndexBuilder(ref_lists, key_elements=key_elements)
1072 for key, value, references in nodes:1072 for key, value, references in nodes:
1073 builder.add_node(key, value, references)1073 builder.add_node(key, value, references)
1074 stream = builder.finish()1074 stream = builder.finish()
1075 trans = self.get_transport()1075 trans = self.get_transport()
1076 size = trans.put_file(name, stream)1076 size = trans.put_file(name, stream)
1077 return index.GraphIndex(trans, name, size)1077 return _mod_index.GraphIndex(trans, name, size)
10781078
1079 def make_combined_index_with_missing(self, missing=['1', '2']):1079 def make_combined_index_with_missing(self, missing=['1', '2']):
1080 """Create a CombinedGraphIndex which will have missing indexes.1080 """Create a CombinedGraphIndex which will have missing indexes.
@@ -1103,7 +1103,7 @@
1103 reload_counter[1] += 11103 reload_counter[1] += 1
1104 idx._indices[:] = new_indices1104 idx._indices[:] = new_indices
1105 return True1105 return True
1106 idx = index.CombinedGraphIndex([idx1, idx2], reload_func=reload)1106 idx = _mod_index.CombinedGraphIndex([idx1, idx2], reload_func=reload)
1107 trans = self.get_transport()1107 trans = self.get_transport()
1108 for fname in missing:1108 for fname in missing:
1109 trans.delete(fname)1109 trans.delete(fname)
@@ -1111,11 +1111,11 @@
11111111
1112 def test_open_missing_index_no_error(self):1112 def test_open_missing_index_no_error(self):
1113 trans = self.get_transport()1113 trans = self.get_transport()
1114 idx1 = index.GraphIndex(trans, 'missing', 100)1114 idx1 = _mod_index.GraphIndex(trans, 'missing', 100)
1115 idx = index.CombinedGraphIndex([idx1])1115 idx = _mod_index.CombinedGraphIndex([idx1])
11161116
1117 def test_add_index(self):1117 def test_add_index(self):
1118 idx = index.CombinedGraphIndex([])1118 idx = _mod_index.CombinedGraphIndex([])
1119 idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])1119 idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
1120 idx.insert_index(0, idx1)1120 idx.insert_index(0, idx1)
1121 self.assertEqual([(idx1, ('key', ), '')],1121 self.assertEqual([(idx1, ('key', ), '')],
@@ -1136,7 +1136,7 @@
1136 log.append(self._index)1136 log.append(self._index)
1137 return self._index.clear_cache()1137 return self._index.clear_cache()
11381138
1139 idx = index.CombinedGraphIndex([])1139 idx = _mod_index.CombinedGraphIndex([])
1140 idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])1140 idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
1141 idx.insert_index(0, ClearCacheProxy(idx1))1141 idx.insert_index(0, ClearCacheProxy(idx1))
1142 idx2 = self.make_index('name', 0, nodes=[(('key', ), '', ())])1142 idx2 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
@@ -1146,24 +1146,24 @@
1146 self.assertEqual(sorted([idx1, idx2]), sorted(log))1146 self.assertEqual(sorted([idx1, idx2]), sorted(log))
11471147
1148 def test_iter_all_entries_empty(self):1148 def test_iter_all_entries_empty(self):
1149 idx = index.CombinedGraphIndex([])1149 idx = _mod_index.CombinedGraphIndex([])
1150 self.assertEqual([], list(idx.iter_all_entries()))1150 self.assertEqual([], list(idx.iter_all_entries()))
11511151
1152 def test_iter_all_entries_children_empty(self):1152 def test_iter_all_entries_children_empty(self):
1153 idx1 = self.make_index('name')1153 idx1 = self.make_index('name')
1154 idx = index.CombinedGraphIndex([idx1])1154 idx = _mod_index.CombinedGraphIndex([idx1])
1155 self.assertEqual([], list(idx.iter_all_entries()))1155 self.assertEqual([], list(idx.iter_all_entries()))
11561156
1157 def test_iter_all_entries_simple(self):1157 def test_iter_all_entries_simple(self):
1158 idx1 = self.make_index('name', nodes=[(('name', ), 'data', ())])1158 idx1 = self.make_index('name', nodes=[(('name', ), 'data', ())])
1159 idx = index.CombinedGraphIndex([idx1])1159 idx = _mod_index.CombinedGraphIndex([idx1])
1160 self.assertEqual([(idx1, ('name', ), 'data')],1160 self.assertEqual([(idx1, ('name', ), 'data')],
1161 list(idx.iter_all_entries()))1161 list(idx.iter_all_entries()))
11621162
1163 def test_iter_all_entries_two_indices(self):1163 def test_iter_all_entries_two_indices(self):
1164 idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])1164 idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
1165 idx2 = self.make_index('name2', nodes=[(('2', ), '', ())])1165 idx2 = self.make_index('name2', nodes=[(('2', ), '', ())])
1166 idx = index.CombinedGraphIndex([idx1, idx2])1166 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1167 self.assertEqual([(idx1, ('name', ), 'data'),1167 self.assertEqual([(idx1, ('name', ), 'data'),
1168 (idx2, ('2', ), '')],1168 (idx2, ('2', ), '')],
1169 list(idx.iter_all_entries()))1169 list(idx.iter_all_entries()))
@@ -1171,14 +1171,14 @@
1171 def test_iter_entries_two_indices_dup_key(self):1171 def test_iter_entries_two_indices_dup_key(self):
1172 idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])1172 idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
1173 idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])1173 idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])
1174 idx = index.CombinedGraphIndex([idx1, idx2])1174 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1175 self.assertEqual([(idx1, ('name', ), 'data')],1175 self.assertEqual([(idx1, ('name', ), 'data')],
1176 list(idx.iter_entries([('name', )])))1176 list(idx.iter_entries([('name', )])))
11771177
1178 def test_iter_all_entries_two_indices_dup_key(self):1178 def test_iter_all_entries_two_indices_dup_key(self):
1179 idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])1179 idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
1180 idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])1180 idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])
1181 idx = index.CombinedGraphIndex([idx1, idx2])1181 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1182 self.assertEqual([(idx1, ('name', ), 'data')],1182 self.assertEqual([(idx1, ('name', ), 'data')],
1183 list(idx.iter_all_entries()))1183 list(idx.iter_all_entries()))
11841184
@@ -1188,7 +1188,7 @@
1188 idx2 = self.make_index('2', 1, key_elements=2, nodes=[1188 idx2 = self.make_index('2', 1, key_elements=2, nodes=[
1189 (('name', 'fin2'), 'beta', ([], )),1189 (('name', 'fin2'), 'beta', ([], )),
1190 (('ref', 'erence'), 'refdata', ([], ))])1190 (('ref', 'erence'), 'refdata', ([], ))])
1191 idx = index.CombinedGraphIndex([idx1, idx2])1191 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1192 self.assertEqual({(idx1, ('name', 'fin1'), 'data',1192 self.assertEqual({(idx1, ('name', 'fin1'), 'data',
1193 ((('ref', 'erence'),),)),1193 ((('ref', 'erence'),),)),
1194 (idx2, ('ref', 'erence'), 'refdata', ((), ))},1194 (idx2, ('ref', 'erence'), 'refdata', ((), ))},
@@ -1200,19 +1200,19 @@
1200 set(idx.iter_entries_prefix([('name', None)])))1200 set(idx.iter_entries_prefix([('name', None)])))
12011201
1202 def test_iter_nothing_empty(self):1202 def test_iter_nothing_empty(self):
1203 idx = index.CombinedGraphIndex([])1203 idx = _mod_index.CombinedGraphIndex([])
1204 self.assertEqual([], list(idx.iter_entries([])))1204 self.assertEqual([], list(idx.iter_entries([])))
12051205
1206 def test_iter_nothing_children_empty(self):1206 def test_iter_nothing_children_empty(self):
1207 idx1 = self.make_index('name')1207 idx1 = self.make_index('name')
1208 idx = index.CombinedGraphIndex([idx1])1208 idx = _mod_index.CombinedGraphIndex([idx1])
1209 self.assertEqual([], list(idx.iter_entries([])))1209 self.assertEqual([], list(idx.iter_entries([])))
12101210
1211 def test_iter_all_keys(self):1211 def test_iter_all_keys(self):
1212 idx1 = self.make_index('1', 1, nodes=[(('name', ), 'data',1212 idx1 = self.make_index('1', 1, nodes=[(('name', ), 'data',
1213 ([('ref', )], ))])1213 ([('ref', )], ))])
1214 idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ((), ))])1214 idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ((), ))])
1215 idx = index.CombinedGraphIndex([idx1, idx2])1215 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1216 self.assertEqual({(idx1, ('name', ), 'data', ((('ref', ), ), )),1216 self.assertEqual({(idx1, ('name', ), 'data', ((('ref', ), ), )),
1217 (idx2, ('ref', ), 'refdata', ((), ))},1217 (idx2, ('ref', ), 'refdata', ((), ))},
1218 set(idx.iter_entries([('name', ), ('ref', )])))1218 set(idx.iter_entries([('name', ), ('ref', )])))
@@ -1222,41 +1222,41 @@
1222 ([('ref', )], )),1222 ([('ref', )], )),
1223 (('ref', ), 'refdata', ([], ))])1223 (('ref', ), 'refdata', ([], ))])
1224 idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ([], ))])1224 idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ([], ))])
1225 idx = index.CombinedGraphIndex([idx1, idx2])1225 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1226 self.assertEqual({(idx1, ('name', ), 'data', ((('ref',),),)),1226 self.assertEqual({(idx1, ('name', ), 'data', ((('ref',),),)),
1227 (idx1, ('ref', ), 'refdata', ((), ))},1227 (idx1, ('ref', ), 'refdata', ((), ))},
1228 set(idx.iter_entries([('name', ), ('ref', )])))1228 set(idx.iter_entries([('name', ), ('ref', )])))
12291229
1230 def test_iter_missing_entry_empty(self):1230 def test_iter_missing_entry_empty(self):
1231 idx = index.CombinedGraphIndex([])1231 idx = _mod_index.CombinedGraphIndex([])
1232 self.assertEqual([], list(idx.iter_entries([('a', )])))1232 self.assertEqual([], list(idx.iter_entries([('a', )])))
12331233
1234 def test_iter_missing_entry_one_index(self):1234 def test_iter_missing_entry_one_index(self):
1235 idx1 = self.make_index('1')1235 idx1 = self.make_index('1')
1236 idx = index.CombinedGraphIndex([idx1])1236 idx = _mod_index.CombinedGraphIndex([idx1])
1237 self.assertEqual([], list(idx.iter_entries([('a', )])))1237 self.assertEqual([], list(idx.iter_entries([('a', )])))
12381238
1239 def test_iter_missing_entry_two_index(self):1239 def test_iter_missing_entry_two_index(self):
1240 idx1 = self.make_index('1')1240 idx1 = self.make_index('1')
1241 idx2 = self.make_index('2')1241 idx2 = self.make_index('2')
1242 idx = index.CombinedGraphIndex([idx1, idx2])1242 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1243 self.assertEqual([], list(idx.iter_entries([('a', )])))1243 self.assertEqual([], list(idx.iter_entries([('a', )])))
12441244
1245 def test_iter_entry_present_one_index_only(self):1245 def test_iter_entry_present_one_index_only(self):
1246 idx1 = self.make_index('1', nodes=[(('key', ), '', ())])1246 idx1 = self.make_index('1', nodes=[(('key', ), '', ())])
1247 idx2 = self.make_index('2', nodes=[])1247 idx2 = self.make_index('2', nodes=[])
1248 idx = index.CombinedGraphIndex([idx1, idx2])1248 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1249 self.assertEqual([(idx1, ('key', ), '')],1249 self.assertEqual([(idx1, ('key', ), '')],
1250 list(idx.iter_entries([('key', )])))1250 list(idx.iter_entries([('key', )])))
1251 # and in the other direction1251 # and in the other direction
1252 idx = index.CombinedGraphIndex([idx2, idx1])1252 idx = _mod_index.CombinedGraphIndex([idx2, idx1])
1253 self.assertEqual([(idx1, ('key', ), '')],1253 self.assertEqual([(idx1, ('key', ), '')],
1254 list(idx.iter_entries([('key', )])))1254 list(idx.iter_entries([('key', )])))
12551255
1256 def test_key_count_empty(self):1256 def test_key_count_empty(self):
1257 idx1 = self.make_index('1', nodes=[])1257 idx1 = self.make_index('1', nodes=[])
1258 idx2 = self.make_index('2', nodes=[])1258 idx2 = self.make_index('2', nodes=[])
1259 idx = index.CombinedGraphIndex([idx1, idx2])1259 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1260 self.assertEqual(0, idx.key_count())1260 self.assertEqual(0, idx.key_count())
12611261
1262 def test_key_count_sums_index_keys(self):1262 def test_key_count_sums_index_keys(self):
@@ -1264,18 +1264,18 @@
1264 (('1',), '', ()),1264 (('1',), '', ()),
1265 (('2',), '', ())])1265 (('2',), '', ())])
1266 idx2 = self.make_index('2', nodes=[(('1',), '', ())])1266 idx2 = self.make_index('2', nodes=[(('1',), '', ())])
1267 idx = index.CombinedGraphIndex([idx1, idx2])1267 idx = _mod_index.CombinedGraphIndex([idx1, idx2])
1268 self.assertEqual(3, idx.key_count())1268 self.assertEqual(3, idx.key_count())
12691269
1270 def test_validate_bad_child_index_errors(self):1270 def test_validate_bad_child_index_errors(self):
1271 trans = self.get_transport()1271 trans = self.get_transport()
1272 trans.put_bytes('name', "not an index\n")1272 trans.put_bytes('name', "not an index\n")
1273 idx1 = index.GraphIndex(trans, 'name', 13)1273 idx1 = _mod_index.GraphIndex(trans, 'name', 13)
1274 idx = index.CombinedGraphIndex([idx1])1274 idx = _mod_index.CombinedGraphIndex([idx1])
1275 self.assertRaises(errors.BadIndexFormatSignature, idx.validate)1275 self.assertRaises(_mod_index.BadIndexFormatSignature, idx.validate)
12761276
1277 def test_validate_empty(self):1277 def test_validate_empty(self):
1278 idx = index.CombinedGraphIndex([])1278 idx = _mod_index.CombinedGraphIndex([])
1279 idx.validate()1279 idx.validate()
12801280
1281 def test_key_count_reloads(self):1281 def test_key_count_reloads(self):
@@ -1403,7 +1403,7 @@
1403 def test_reorder_after_iter_entries(self):1403 def test_reorder_after_iter_entries(self):
1404 # Four indices: [key1] in idx1, [key2,key3] in idx2, [] in idx3,1404 # Four indices: [key1] in idx1, [key2,key3] in idx2, [] in idx3,
1405 # [key4] in idx4.1405 # [key4] in idx4.
1406 idx = index.CombinedGraphIndex([])1406 idx = _mod_index.CombinedGraphIndex([])
1407 idx.insert_index(0, self.make_index_with_simple_nodes('1'), '1')1407 idx.insert_index(0, self.make_index_with_simple_nodes('1'), '1')
1408 idx.insert_index(1, self.make_index_with_simple_nodes('2'), '2')1408 idx.insert_index(1, self.make_index_with_simple_nodes('2'), '2')
1409 idx.insert_index(2, self.make_index_with_simple_nodes('3'), '3')1409 idx.insert_index(2, self.make_index_with_simple_nodes('3'), '3')
@@ -1420,8 +1420,8 @@
1420 def test_reorder_propagates_to_siblings(self):1420 def test_reorder_propagates_to_siblings(self):
1421 # Two CombinedGraphIndex objects, with the same number of indicies with1421 # Two CombinedGraphIndex objects, with the same number of indicies with
1422 # matching names.1422 # matching names.
1423 cgi1 = index.CombinedGraphIndex([])1423 cgi1 = _mod_index.CombinedGraphIndex([])
1424 cgi2 = index.CombinedGraphIndex([])1424 cgi2 = _mod_index.CombinedGraphIndex([])
1425 cgi1.insert_index(0, self.make_index_with_simple_nodes('1-1'), 'one')1425 cgi1.insert_index(0, self.make_index_with_simple_nodes('1-1'), 'one')
1426 cgi1.insert_index(1, self.make_index_with_simple_nodes('1-2'), 'two')1426 cgi1.insert_index(1, self.make_index_with_simple_nodes('1-2'), 'two')
1427 cgi2.insert_index(0, self.make_index_with_simple_nodes('2-1'), 'one')1427 cgi2.insert_index(0, self.make_index_with_simple_nodes('2-1'), 'one')
@@ -1465,7 +1465,7 @@
1465 (key3, 'value', ([key2],)),1465 (key3, 'value', ([key2],)),
1466 (key4, 'value', ([key3],)),1466 (key4, 'value', ([key3],)),
1467 ])1467 ])
1468 c_index = index.CombinedGraphIndex([index1, index2])1468 c_index = _mod_index.CombinedGraphIndex([index1, index2])
1469 parent_map, missing_keys = c_index.find_ancestry([key1], 0)1469 parent_map, missing_keys = c_index.find_ancestry([key1], 0)
1470 self.assertEqual({key1: ()}, parent_map)1470 self.assertEqual({key1: ()}, parent_map)
1471 self.assertEqual(set(), missing_keys)1471 self.assertEqual(set(), missing_keys)
@@ -1488,7 +1488,7 @@
1488 index2 = self.make_index('34', ref_lists=1, nodes=[1488 index2 = self.make_index('34', ref_lists=1, nodes=[
1489 (key3, 'value', ([key2],)),1489 (key3, 'value', ([key2],)),
1490 ])1490 ])
1491 c_index = index.CombinedGraphIndex([index1, index2])1491 c_index = _mod_index.CombinedGraphIndex([index1, index2])
1492 # Searching for a key which is actually not present at all should1492 # Searching for a key which is actually not present at all should
1493 # eventually converge1493 # eventually converge
1494 parent_map, missing_keys = c_index.find_ancestry([key4], 0)1494 parent_map, missing_keys = c_index.find_ancestry([key4], 0)
@@ -1496,7 +1496,7 @@
1496 self.assertEqual({key4}, missing_keys)1496 self.assertEqual({key4}, missing_keys)
14971497
1498 def test_find_ancestors_no_indexes(self):1498 def test_find_ancestors_no_indexes(self):
1499 c_index = index.CombinedGraphIndex([])1499 c_index = _mod_index.CombinedGraphIndex([])
1500 key1 = ('key-1',)1500 key1 = ('key-1',)
1501 parent_map, missing_keys = c_index.find_ancestry([key1], 0)1501 parent_map, missing_keys = c_index.find_ancestry([key1], 0)
1502 self.assertEqual({}, parent_map)1502 self.assertEqual({}, parent_map)
@@ -1514,7 +1514,7 @@
1514 index2 = self.make_index('34', ref_lists=1, nodes=[1514 index2 = self.make_index('34', ref_lists=1, nodes=[
1515 (key4, 'value', ([key2, key3],)),1515 (key4, 'value', ([key2, key3],)),
1516 ])1516 ])
1517 c_index = index.CombinedGraphIndex([index1, index2])1517 c_index = _mod_index.CombinedGraphIndex([index1, index2])
1518 # Searching for a key which is actually not present at all should1518 # Searching for a key which is actually not present at all should
1519 # eventually converge1519 # eventually converge
1520 parent_map, missing_keys = c_index.find_ancestry([key4], 0)1520 parent_map, missing_keys = c_index.find_ancestry([key4], 0)
@@ -1536,7 +1536,7 @@
1536class TestInMemoryGraphIndex(tests.TestCaseWithMemoryTransport):1536class TestInMemoryGraphIndex(tests.TestCaseWithMemoryTransport):
15371537
1538 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):1538 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):
1539 result = index.InMemoryGraphIndex(ref_lists, key_elements=key_elements)1539 result = _mod_index.InMemoryGraphIndex(ref_lists, key_elements=key_elements)
1540 result.add_nodes(nodes)1540 result.add_nodes(nodes)
1541 return result1541 return result
15421542
@@ -1667,13 +1667,13 @@
16671667
1668 def make_index(self, ref_lists=1, key_elements=2, nodes=[],1668 def make_index(self, ref_lists=1, key_elements=2, nodes=[],
1669 add_callback=False):1669 add_callback=False):
1670 result = index.InMemoryGraphIndex(ref_lists, key_elements=key_elements)1670 result = _mod_index.InMemoryGraphIndex(ref_lists, key_elements=key_elements)
1671 result.add_nodes(nodes)1671 result.add_nodes(nodes)
1672 if add_callback:1672 if add_callback:
1673 add_nodes_callback = result.add_nodes1673 add_nodes_callback = result.add_nodes
1674 else:1674 else:
1675 add_nodes_callback = None1675 add_nodes_callback = None
1676 adapter = index.GraphIndexPrefixAdapter(1676 adapter = _mod_index.GraphIndexPrefixAdapter(
1677 result, ('prefix', ), key_elements - 1,1677 result, ('prefix', ), key_elements - 1,
1678 add_nodes_callback=add_nodes_callback)1678 add_nodes_callback=add_nodes_callback)
1679 return result, adapter1679 return result, adapter
@@ -1698,18 +1698,18 @@
1698 set(index.iter_all_entries()))1698 set(index.iter_all_entries()))
16991699
1700 def test_construct(self):1700 def test_construct(self):
1701 idx = index.InMemoryGraphIndex()1701 idx = _mod_index.InMemoryGraphIndex()
1702 adapter = index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1)1702 adapter = _mod_index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1)
17031703
1704 def test_construct_with_callback(self):1704 def test_construct_with_callback(self):
1705 idx = index.InMemoryGraphIndex()1705 idx = _mod_index.InMemoryGraphIndex()
1706 adapter = index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1,1706 adapter = _mod_index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1,
1707 idx.add_nodes)1707 idx.add_nodes)
17081708
1709 def test_iter_all_entries_cross_prefix_map_errors(self):1709 def test_iter_all_entries_cross_prefix_map_errors(self):
1710 index, adapter = self.make_index(nodes=[1710 index, adapter = self.make_index(nodes=[
1711 (('prefix', 'key1'), 'data1', ((('prefixaltered', 'key2'),),))])1711 (('prefix', 'key1'), 'data1', ((('prefixaltered', 'key2'),),))])
1712 self.assertRaises(errors.BadIndexData, list, adapter.iter_all_entries())1712 self.assertRaises(_mod_index.BadIndexData, list, adapter.iter_all_entries())
17131713
1714 def test_iter_all_entries(self):1714 def test_iter_all_entries(self):
1715 index, adapter = self.make_index(nodes=[1715 index, adapter = self.make_index(nodes=[
17161716
=== modified file 'breezy/tests/test_msgeditor.py'
--- breezy/tests/test_msgeditor.py 2017-06-10 00:17:06 +0000
+++ breezy/tests/test_msgeditor.py 2017-07-24 01:10:54 +0000
@@ -339,7 +339,7 @@
339 self.make_fake_editor(message=char)339 self.make_fake_editor(message=char)
340340
341 working_tree = self.make_uncommitted_tree()341 working_tree = self.make_uncommitted_tree()
342 self.assertRaises(errors.BadCommitMessageEncoding,342 self.assertRaises(msgeditor.BadCommitMessageEncoding,
343 msgeditor.edit_commit_message, '')343 msgeditor.edit_commit_message, '')
344344
345 def test_set_commit_message_no_hooks(self):345 def test_set_commit_message_no_hooks(self):
346346
=== modified file 'breezy/tests/test_osutils.py'
--- breezy/tests/test_osutils.py 2017-06-15 00:39:26 +0000
+++ breezy/tests/test_osutils.py 2017-07-24 01:10:54 +0000
@@ -404,7 +404,7 @@
404 self.assertFormatedDelta('2 seconds in the future', -2)404 self.assertFormatedDelta('2 seconds in the future', -2)
405405
406 def test_format_date(self):406 def test_format_date(self):
407 self.assertRaises(errors.UnsupportedTimezoneFormat,407 self.assertRaises(osutils.UnsupportedTimezoneFormat,
408 osutils.format_date, 0, timezone='foo')408 osutils.format_date, 0, timezone='foo')
409 self.assertIsInstance(osutils.format_date(0), str)409 self.assertIsInstance(osutils.format_date(0), str)
410 self.assertIsInstance(osutils.format_local_date(0), unicode)410 self.assertIsInstance(osutils.format_local_date(0), unicode)
411411
=== modified file 'breezy/tests/test_reconfigure.py'
--- breezy/tests/test_reconfigure.py 2017-06-10 16:40:42 +0000
+++ breezy/tests/test_reconfigure.py 2017-07-24 01:10:54 +0000
@@ -62,7 +62,7 @@
6262
63 def test_branch_to_branch(self):63 def test_branch_to_branch(self):
64 branch = self.make_branch('branch')64 branch = self.make_branch('branch')
65 self.assertRaises(errors.AlreadyBranch,65 self.assertRaises(reconfigure.AlreadyBranch,
66 reconfigure.Reconfigure.to_branch, branch.controldir)66 reconfigure.Reconfigure.to_branch, branch.controldir)
6767
68 def test_repo_to_branch(self):68 def test_repo_to_branch(self):
@@ -142,13 +142,13 @@
142142
143 def test_tree_to_tree(self):143 def test_tree_to_tree(self):
144 tree = self.make_branch_and_tree('tree')144 tree = self.make_branch_and_tree('tree')
145 self.assertRaises(errors.AlreadyTree, reconfigure.Reconfigure.to_tree,145 self.assertRaises(reconfigure.AlreadyTree,
146 tree.controldir)146 reconfigure.Reconfigure.to_tree, tree.controldir)
147147
148 def test_select_bind_location(self):148 def test_select_bind_location(self):
149 branch = self.make_branch('branch')149 branch = self.make_branch('branch')
150 reconfiguration = reconfigure.Reconfigure(branch.controldir)150 reconfiguration = reconfigure.Reconfigure(branch.controldir)
151 self.assertRaises(errors.NoBindLocation,151 self.assertRaises(reconfigure.NoBindLocation,
152 reconfiguration._select_bind_location)152 reconfiguration._select_bind_location)
153 branch.set_parent('http://parent')153 branch.set_parent('http://parent')
154 reconfiguration = reconfigure.Reconfigure(branch.controldir)154 reconfiguration = reconfigure.Reconfigure(branch.controldir)
@@ -189,7 +189,7 @@
189189
190 tree = self.make_branch_and_tree('tree')190 tree = self.make_branch_and_tree('tree')
191 reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir)191 reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir)
192 self.assertRaises(errors.NoBindLocation, reconfiguration.apply)192 self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
193 # setting a parent allows it to become a checkout193 # setting a parent allows it to become a checkout
194 tree.branch.set_parent(parent.base)194 tree.branch.set_parent(parent.base)
195 reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir)195 reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir)
@@ -208,7 +208,7 @@
208 tree = self.make_branch_and_tree('tree')208 tree = self.make_branch_and_tree('tree')
209 reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(209 reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
210 tree.controldir)210 tree.controldir)
211 self.assertRaises(errors.NoBindLocation, reconfiguration.apply)211 self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
212 # setting a parent allows it to become a checkout212 # setting a parent allows it to become a checkout
213 tree.branch.set_parent(parent.base)213 tree.branch.set_parent(parent.base)
214 reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(214 reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
@@ -223,7 +223,7 @@
223 def test_checkout_to_checkout(self):223 def test_checkout_to_checkout(self):
224 parent = self.make_branch('parent')224 parent = self.make_branch('parent')
225 checkout = parent.create_checkout('checkout')225 checkout = parent.create_checkout('checkout')
226 self.assertRaises(errors.AlreadyCheckout,226 self.assertRaises(reconfigure.AlreadyCheckout,
227 reconfigure.Reconfigure.to_checkout, checkout.controldir)227 reconfigure.Reconfigure.to_checkout, checkout.controldir)
228228
229 def make_unsynced_checkout(self):229 def make_unsynced_checkout(self):
@@ -236,7 +236,7 @@
236236
237 def test_unsynced_checkout_to_lightweight(self):237 def test_unsynced_checkout_to_lightweight(self):
238 checkout, parent, reconfiguration = self.make_unsynced_checkout()238 checkout, parent, reconfiguration = self.make_unsynced_checkout()
239 self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply)239 self.assertRaises(reconfigure.UnsyncedBranches, reconfiguration.apply)
240240
241 def test_synced_checkout_to_lightweight(self):241 def test_synced_checkout_to_lightweight(self):
242 checkout, parent, reconfiguration = self.make_unsynced_checkout()242 checkout, parent, reconfiguration = self.make_unsynced_checkout()
@@ -294,7 +294,7 @@
294 def test_lightweight_checkout_to_lightweight_checkout(self):294 def test_lightweight_checkout_to_lightweight_checkout(self):
295 parent = self.make_branch('parent')295 parent = self.make_branch('parent')
296 checkout = parent.create_checkout('checkout', lightweight=True)296 checkout = parent.create_checkout('checkout', lightweight=True)
297 self.assertRaises(errors.AlreadyLightweightCheckout,297 self.assertRaises(reconfigure.AlreadyLightweightCheckout,
298 reconfigure.Reconfigure.to_lightweight_checkout,298 reconfigure.Reconfigure.to_lightweight_checkout,
299 checkout.controldir)299 checkout.controldir)
300300
@@ -308,7 +308,7 @@
308 repo = self.make_repository('repo', shared=True)308 repo = self.make_repository('repo', shared=True)
309 reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(309 reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
310 repo.controldir)310 repo.controldir)
311 self.assertRaises(errors.NoBindLocation, reconfiguration.apply)311 self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
312 branch = self.make_branch('branch')312 branch = self.make_branch('branch')
313 reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(313 reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
314 repo.controldir, 'branch')314 repo.controldir, 'branch')
@@ -364,7 +364,7 @@
364364
365 def test_use_shared_to_use_shared(self):365 def test_use_shared_to_use_shared(self):
366 tree = self.make_repository_tree()366 tree = self.make_repository_tree()
367 self.assertRaises(errors.AlreadyUsingShared,367 self.assertRaises(reconfigure.AlreadyUsingShared,
368 reconfigure.Reconfigure.to_use_shared, tree.controldir)368 reconfigure.Reconfigure.to_use_shared, tree.controldir)
369369
370 def test_use_shared_to_standalone(self):370 def test_use_shared_to_standalone(self):
@@ -389,7 +389,7 @@
389389
390 def test_standalone_to_standalone(self):390 def test_standalone_to_standalone(self):
391 tree = self.make_branch_and_tree('tree')391 tree = self.make_branch_and_tree('tree')
392 self.assertRaises(errors.AlreadyStandalone,392 self.assertRaises(reconfigure.AlreadyStandalone,
393 reconfigure.Reconfigure.to_standalone, tree.controldir)393 reconfigure.Reconfigure.to_standalone, tree.controldir)
394394
395 def make_unsynced_branch_reconfiguration(self):395 def make_unsynced_branch_reconfiguration(self):
@@ -401,7 +401,7 @@
401401
402 def test_unsynced_branch_to_lightweight_checkout_unforced(self):402 def test_unsynced_branch_to_lightweight_checkout_unforced(self):
403 reconfiguration = self.make_unsynced_branch_reconfiguration()403 reconfiguration = self.make_unsynced_branch_reconfiguration()
404 self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply)404 self.assertRaises(reconfigure.UnsyncedBranches, reconfiguration.apply)
405405
406 def test_unsynced_branch_to_lightweight_checkout_forced(self):406 def test_unsynced_branch_to_lightweight_checkout_forced(self):
407 reconfiguration = self.make_unsynced_branch_reconfiguration()407 reconfiguration = self.make_unsynced_branch_reconfiguration()
@@ -428,21 +428,21 @@
428428
429 def test_make_with_trees_already_with_trees(self):429 def test_make_with_trees_already_with_trees(self):
430 repo = self.make_repository_with_without_trees(True)430 repo = self.make_repository_with_without_trees(True)
431 e = self.assertRaises(errors.AlreadyWithTrees,431 e = self.assertRaises(reconfiure.AlreadyWithTrees,
432 reconfigure.Reconfigure.set_repository_trees, repo.controldir, True)432 reconfigure.Reconfigure.set_repository_trees, repo.controldir, True)
433 self.assertContainsRe(str(e),433 self.assertContainsRe(str(e),
434 r"Shared repository '.*' already creates working trees.")434 r"Shared repository '.*' already creates working trees.")
435435
436 def test_make_without_trees_already_no_trees(self):436 def test_make_without_trees_already_no_trees(self):
437 repo = self.make_repository_with_without_trees(False)437 repo = self.make_repository_with_without_trees(False)
438 e = self.assertRaises(errors.AlreadyWithNoTrees,438 e = self.assertRaises(reconfigure.AlreadyWithNoTrees,
439 reconfigure.Reconfigure.set_repository_trees, repo.controldir, False)439 reconfigure.Reconfigure.set_repository_trees, repo.controldir, False)
440 self.assertContainsRe(str(e),440 self.assertContainsRe(str(e),
441 r"Shared repository '.*' already doesn't create working trees.")441 r"Shared repository '.*' already doesn't create working trees.")
442442
443 def test_repository_tree_reconfiguration_not_supported(self):443 def test_repository_tree_reconfiguration_not_supported(self):
444 tree = self.make_branch_and_tree('tree')444 tree = self.make_branch_and_tree('tree')
445 e = self.assertRaises(errors.ReconfigurationNotSupported,445 e = self.assertRaises(reconfigure.ReconfigurationNotSupported,
446 reconfigure.Reconfigure.set_repository_trees, tree.controldir, None)446 reconfigure.Reconfigure.set_repository_trees, tree.controldir, None)
447 self.assertContainsRe(str(e),447 self.assertContainsRe(str(e),
448 r"Requested reconfiguration of '.*' is not supported.")448 r"Requested reconfiguration of '.*' is not supported.")
449449
=== modified file 'breezy/tests/test_rules.py'
--- breezy/tests/test_rules.py 2017-05-21 18:10:28 +0000
+++ breezy/tests/test_rules.py 2017-07-24 01:10:54 +0000
@@ -19,12 +19,18 @@
19import sys19import sys
2020
21from breezy import (21from breezy import (
22 errors,
23 rules,22 rules,
24 tests,23 tests,
25 )24 )
2625
2726
27class ErrorTests(tests.TestCase):
28
29 def test_unknown_rules(self):
30 err = rules.UnknownRules(['foo', 'bar'])
31 self.assertEqual("Unknown rules detected: foo, bar.", str(err))
32
33
28class TestIniBasedRulesSearcher(tests.TestCase):34class TestIniBasedRulesSearcher(tests.TestCase):
2935
30 def make_searcher(self, text):36 def make_searcher(self, text):
@@ -36,8 +42,8 @@
36 return rules._IniBasedRulesSearcher(lines)42 return rules._IniBasedRulesSearcher(lines)
3743
38 def test_unknown_namespace(self):44 def test_unknown_namespace(self):
39 self.assertRaises(errors.UnknownRules, rules._IniBasedRulesSearcher,45 self.assertRaises(rules.UnknownRules, rules._IniBasedRulesSearcher,
40 ["[junk]", "foo=bar"])46 ["[junk]", "foo=bar"])
4147
42 def test_get_items_file_missing(self):48 def test_get_items_file_missing(self):
43 rs = self.make_searcher(None)49 rs = self.make_searcher(None)
4450
=== modified file 'breezy/tests/test_version_info.py'
--- breezy/tests/test_version_info.py 2017-06-10 00:17:06 +0000
+++ breezy/tests/test_version_info.py 2017-07-24 01:10:54 +0000
@@ -21,7 +21,6 @@
21import sys21import sys
2222
23from .. import (23from .. import (
24 errors,
25 registry,24 registry,
26 tests,25 tests,
27 version_info_formats,26 version_info_formats,
@@ -32,7 +31,11 @@
32from . import TestCaseWithTransport31from . import TestCaseWithTransport
33from ..rio import read_stanzas32from ..rio import read_stanzas
3433
35from ..version_info_formats.format_custom import CustomVersionInfoBuilder34from ..version_info_formats.format_custom import (
35 CustomVersionInfoBuilder,
36 MissingTemplateVariable,
37 NoTemplate,
38 )
36from ..version_info_formats.format_rio import RioVersionInfoBuilder39from ..version_info_formats.format_rio import RioVersionInfoBuilder
37from ..version_info_formats.format_python import PythonVersionInfoBuilder40from ..version_info_formats.format_python import PythonVersionInfoBuilder
3841
@@ -346,8 +349,7 @@
346 builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, 349 builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt,
347 template='{revno} revid: {revision_id}')350 template='{revno} revid: {revision_id}')
348 # revision_id is not available yet351 # revision_id is not available yet
349 self.assertRaises(errors.MissingTemplateVariable, 352 self.assertRaises(MissingTemplateVariable, builder.generate, sio)
350 builder.generate, sio)
351353
352 def test_custom_dotted_revno(self):354 def test_custom_dotted_revno(self):
353 sio = BytesIO()355 sio = BytesIO()
@@ -398,7 +400,7 @@
398 def test_custom_without_template(self):400 def test_custom_without_template(self):
399 builder = CustomVersionInfoBuilder(None)401 builder = CustomVersionInfoBuilder(None)
400 sio = BytesIO()402 sio = BytesIO()
401 self.assertRaises(errors.NoTemplate, builder.generate, sio)403 self.assertRaises(NoTemplate, builder.generate, sio)
402404
403405
404class TestBuilder(version_info_formats.VersionInfoBuilder):406class TestBuilder(version_info_formats.VersionInfoBuilder):
405407
=== modified file 'breezy/version_info_formats/format_custom.py'
--- breezy/version_info_formats/format_custom.py 2017-06-14 23:29:06 +0000
+++ breezy/version_info_formats/format_custom.py 2017-07-24 01:10:54 +0000
@@ -30,6 +30,19 @@
30 )30 )
3131
3232
33class MissingTemplateVariable(errors.BzrError):
34
35 _fmt = 'Variable {%(name)s} is not available.'
36
37 def __init__(self, name):
38 self.name = name
39
40
41class NoTemplate(errors.BzrError):
42
43 _fmt = 'No template specified.'
44
45
33class Template(object):46class Template(object):
34 """A simple template engine.47 """A simple template engine.
3548

Subscribers

People subscribed via source and target branches