Merge lp:~jelmer/brz/move-bzr-tests into lp:brz/3.1

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/move-bzr-tests
Merge into: lp:brz/3.1
Diff against target: 1192 lines (+239/-198)
29 files modified
breezy/bzr/bundle/serializer/v4.py (+1/-1)
breezy/bzr/chk_serializer.py (+3/-2)
breezy/bzr/dirstate.py (+1/-1)
breezy/bzr/groupcompress.py (+7/-5)
breezy/bzr/inventory.py (+12/-3)
breezy/bzr/knit.py (+12/-10)
breezy/bzr/serializer.py (+22/-1)
breezy/bzr/tests/__init__.py (+1/-0)
breezy/bzr/tests/per_versionedfile.py (+7/-5)
breezy/bzr/tests/test_inv.py (+10/-0)
breezy/bzr/tests/test_versionedfile.py (+10/-0)
breezy/bzr/tests/test_workingtree.py (+33/-0)
breezy/bzr/tests/test_xml.py (+6/-5)
breezy/bzr/versionedfile.py (+29/-12)
breezy/bzr/vf_repository.py (+1/-1)
breezy/bzr/weave.py (+3/-2)
breezy/bzr/workingtree.py (+12/-2)
breezy/bzr/xml5.py (+1/-2)
breezy/bzr/xml_serializer.py (+7/-7)
breezy/errors.py (+0/-101)
breezy/git/annotate.py (+1/-1)
breezy/merge_directive.py (+11/-1)
breezy/tests/per_workingtree/test_add.py (+2/-2)
breezy/tests/per_workingtree/test_read_working_inventory.py (+2/-2)
breezy/tests/test_conflicts.py (+2/-1)
breezy/tests/test_errors.py (+0/-19)
breezy/tests/test_shelf.py (+1/-4)
breezy/tests/test_transform.py (+6/-5)
breezy/transform.py (+36/-3)
To merge this branch: bzr merge lp:~jelmer/brz/move-bzr-tests
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+386406@code.launchpad.net

Commit message

Move some more tests to breezy.bzr.

Description of the change

Move some more tests to breezy.bzr.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/bzr/bundle/serializer/v4.py'
--- breezy/bzr/bundle/serializer/v4.py 2020-02-09 02:41:42 +0000
+++ breezy/bzr/bundle/serializer/v4.py 2020-06-26 01:36:03 +0000
@@ -690,7 +690,7 @@
690 delta = target_inv._make_delta(parent_inv)690 delta = target_inv._make_delta(parent_inv)
691 self._repository.add_inventory_by_delta(parent_ids[0],691 self._repository.add_inventory_by_delta(parent_ids[0],
692 delta, revision_id, parent_ids)692 delta, revision_id, parent_ids)
693 except errors.UnsupportedInventoryKind:693 except serializer.UnsupportedInventoryKind:
694 raise errors.IncompatibleRevision(repr(self._repository))694 raise errors.IncompatibleRevision(repr(self._repository))
695 inventory_cache[revision_id] = target_inv695 inventory_cache[revision_id] = target_inv
696696
697697
=== modified file 'breezy/bzr/chk_serializer.py'
--- breezy/bzr/chk_serializer.py 2020-01-31 10:39:02 +0000
+++ breezy/bzr/chk_serializer.py 2020-06-26 01:36:03 +0000
@@ -22,6 +22,7 @@
22lazy_import.lazy_import(globals(),22lazy_import.lazy_import(globals(),
23 """23 """
24from breezy.bzr import (24from breezy.bzr import (
25 serializer,
25 xml_serializer,26 xml_serializer,
26 )27 )
27""")28""")
@@ -183,7 +184,7 @@
183 entry_cache=entry_cache,184 entry_cache=entry_cache,
184 return_from_cache=return_from_cache)185 return_from_cache=return_from_cache)
185 except xml_serializer.ParseError as e:186 except xml_serializer.ParseError as e:
186 raise errors.UnexpectedInventoryFormat(e)187 raise serializer.UnexpectedInventoryFormat(e)
187188
188 def read_inventory(self, f, revision_id=None):189 def read_inventory(self, f, revision_id=None):
189 """Read an inventory from a file-like object."""190 """Read an inventory from a file-like object."""
@@ -194,7 +195,7 @@
194 finally:195 finally:
195 f.close()196 f.close()
196 except xml_serializer.ParseError as e:197 except xml_serializer.ParseError as e:
197 raise errors.UnexpectedInventoryFormat(e)198 raise serializer.UnexpectedInventoryFormat(e)
198199
199 def write_inventory_to_lines(self, inv):200 def write_inventory_to_lines(self, inv):
200 """Return a list of lines with the encoded inventory."""201 """Return a list of lines with the encoded inventory."""
201202
=== modified file 'breezy/bzr/dirstate.py'
--- breezy/bzr/dirstate.py 2019-09-21 17:08:09 +0000
+++ breezy/bzr/dirstate.py 2020-06-26 01:36:03 +0000
@@ -531,7 +531,7 @@
531 file_id_entry[0][0], file_id_entry[0][1])531 file_id_entry[0][0], file_id_entry[0][1])
532 kind = DirState._minikind_to_kind[file_id_entry[1][0][0]]532 kind = DirState._minikind_to_kind[file_id_entry[1][0][0]]
533 info = '%s:%s' % (kind, path)533 info = '%s:%s' % (kind, path)
534 raise errors.DuplicateFileId(file_id, info)534 raise inventory.DuplicateFileId(file_id, info)
535 first_key = (dirname, basename, b'')535 first_key = (dirname, basename, b'')
536 block_index, present = self._find_block_index_from_key(first_key)536 block_index, present = self._find_block_index_from_key(first_key)
537 if present:537 if present:
538538
=== modified file 'breezy/bzr/groupcompress.py'
--- breezy/bzr/groupcompress.py 2020-02-09 02:20:11 +0000
+++ breezy/bzr/groupcompress.py 2020-06-26 01:36:03 +0000
@@ -57,8 +57,10 @@
57 adapter_registry,57 adapter_registry,
58 AbsentContentFactory,58 AbsentContentFactory,
59 ChunkedContentFactory,59 ChunkedContentFactory,
60 ExistingContent,
60 FulltextContentFactory,61 FulltextContentFactory,
61 VersionedFilesWithFallbacks,62 VersionedFilesWithFallbacks,
63 UnavailableRepresentation,
62 )64 )
6365
64# Minimum number of uncompressed bytes to try fetch at once when retrieving66# Minimum number of uncompressed bytes to try fetch at once when retrieving
@@ -490,7 +492,7 @@
490 return self._chunks492 return self._chunks
491 else:493 else:
492 return osutils.chunks_to_lines(self._chunks)494 return osutils.chunks_to_lines(self._chunks)
493 raise errors.UnavailableRepresentation(self.key, storage_kind,495 raise UnavailableRepresentation(self.key, storage_kind,
494 self.storage_kind)496 self.storage_kind)
495497
496 def iter_bytes_as(self, storage_kind):498 def iter_bytes_as(self, storage_kind):
@@ -500,7 +502,7 @@
500 return iter(self._chunks)502 return iter(self._chunks)
501 elif storage_kind == 'lines':503 elif storage_kind == 'lines':
502 return iter(osutils.chunks_to_lines(self._chunks))504 return iter(osutils.chunks_to_lines(self._chunks))
503 raise errors.UnavailableRepresentation(self.key, storage_kind,505 raise UnavailableRepresentation(self.key, storage_kind,
504 self.storage_kind)506 self.storage_kind)
505507
506508
@@ -871,7 +873,7 @@
871 """873 """
872 if length == 0: # empty, like a dir entry, etc874 if length == 0: # empty, like a dir entry, etc
873 if nostore_sha == _null_sha1:875 if nostore_sha == _null_sha1:
874 raise errors.ExistingContent()876 raise ExistingContent()
875 return _null_sha1, 0, 0, 'fulltext'877 return _null_sha1, 0, 0, 'fulltext'
876 # we assume someone knew what they were doing when they passed it in878 # we assume someone knew what they were doing when they passed it in
877 if expected_sha is not None:879 if expected_sha is not None:
@@ -880,7 +882,7 @@
880 sha1 = osutils.sha_strings(chunks)882 sha1 = osutils.sha_strings(chunks)
881 if nostore_sha is not None:883 if nostore_sha is not None:
882 if sha1 == nostore_sha:884 if sha1 == nostore_sha:
883 raise errors.ExistingContent()885 raise ExistingContent()
884 if key[-1] is None:886 if key[-1] is None:
885 key = key[:-1] + (b'sha1:' + sha1,)887 key = key[:-1] + (b'sha1:' + sha1,)
886888
@@ -1841,7 +1843,7 @@
1841 continue1843 continue
1842 try:1844 try:
1843 chunks = record.get_bytes_as('chunked')1845 chunks = record.get_bytes_as('chunked')
1844 except errors.UnavailableRepresentation:1846 except UnavailableRepresentation:
1845 adapter_key = record.storage_kind, 'chunked'1847 adapter_key = record.storage_kind, 'chunked'
1846 adapter = get_adapter(adapter_key)1848 adapter = get_adapter(adapter_key)
1847 chunks = adapter.get_bytes(record, 'chunked')1849 chunks = adapter.get_bytes(record, 'chunked')
18481850
=== modified file 'breezy/bzr/inventory.py'
--- breezy/bzr/inventory.py 2020-01-30 16:13:31 +0000
+++ breezy/bzr/inventory.py 2020-06-26 01:36:03 +0000
@@ -59,6 +59,16 @@
59from ..static_tuple import StaticTuple59from ..static_tuple import StaticTuple
6060
6161
62class DuplicateFileId(errors.BzrError):
63
64 _fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
65
66 def __init__(self, file_id, entry):
67 errors.BzrError.__init__(self)
68 self.file_id = file_id
69 self.entry = entry
70
71
62class InventoryEntry(object):72class InventoryEntry(object):
63 """Description of a versioned file.73 """Description of a versioned file.
6474
@@ -1131,7 +1141,7 @@
1131 new_entry = replacement1141 new_entry = replacement
1132 try:1142 try:
1133 self.add(new_entry)1143 self.add(new_entry)
1134 except errors.DuplicateFileId:1144 except DuplicateFileId:
1135 raise errors.InconsistentDelta(new_path, new_entry.file_id,1145 raise errors.InconsistentDelta(new_path, new_entry.file_id,
1136 "New id is already present in target.")1146 "New id is already present in target.")
1137 except AttributeError:1147 except AttributeError:
@@ -1233,8 +1243,7 @@
1233 :return: entry1243 :return: entry
1234 """1244 """
1235 if entry.file_id in self._byid:1245 if entry.file_id in self._byid:
1236 raise errors.DuplicateFileId(entry.file_id,1246 raise DuplicateFileId(entry.file_id, self._byid[entry.file_id])
1237 self._byid[entry.file_id])
1238 if entry.parent_id is None:1247 if entry.parent_id is None:
1239 self.root = entry1248 self.root = entry
1240 else:1249 else:
12411250
=== modified file 'breezy/bzr/knit.py'
--- breezy/bzr/knit.py 2020-01-30 18:07:32 +0000
+++ breezy/bzr/knit.py 2020-06-26 01:36:03 +0000
@@ -107,7 +107,9 @@
107 adapter_registry,107 adapter_registry,
108 ConstantMapper,108 ConstantMapper,
109 ContentFactory,109 ContentFactory,
110 ExistingContent,
110 sort_groupcompress,111 sort_groupcompress,
112 UnavailableRepresentation,
111 VersionedFilesWithFallbacks,113 VersionedFilesWithFallbacks,
112 )114 )
113115
@@ -225,7 +227,7 @@
225227
226 def get_bytes(self, factory, target_storage_kind):228 def get_bytes(self, factory, target_storage_kind):
227 if target_storage_kind != 'knit-ft-gz':229 if target_storage_kind != 'knit-ft-gz':
228 raise errors.UnavailableRepresentation(230 raise UnavailableRepresentation(
229 factory.key, target_storage_kind, factory.storage_kind)231 factory.key, target_storage_kind, factory.storage_kind)
230 annotated_compressed_bytes = factory._raw_record232 annotated_compressed_bytes = factory._raw_record
231 rec, contents = \233 rec, contents = \
@@ -241,7 +243,7 @@
241243
242 def get_bytes(self, factory, target_storage_kind):244 def get_bytes(self, factory, target_storage_kind):
243 if target_storage_kind != 'knit-delta-gz':245 if target_storage_kind != 'knit-delta-gz':
244 raise errors.UnavailableRepresentation(246 raise UnavailableRepresentation(
245 factory.key, target_storage_kind, factory.storage_kind)247 factory.key, target_storage_kind, factory.storage_kind)
246 annotated_compressed_bytes = factory._raw_record248 annotated_compressed_bytes = factory._raw_record
247 rec, contents = \249 rec, contents = \
@@ -266,7 +268,7 @@
266 return b''.join(content.text())268 return b''.join(content.text())
267 elif target_storage_kind in ('chunked', 'lines'):269 elif target_storage_kind in ('chunked', 'lines'):
268 return content.text()270 return content.text()
269 raise errors.UnavailableRepresentation(271 raise UnavailableRepresentation(
270 factory.key, target_storage_kind, factory.storage_kind)272 factory.key, target_storage_kind, factory.storage_kind)
271273
272274
@@ -295,7 +297,7 @@
295 return b''.join(basis_content.text())297 return b''.join(basis_content.text())
296 elif target_storage_kind in ('chunked', 'lines'):298 elif target_storage_kind in ('chunked', 'lines'):
297 return basis_content.text()299 return basis_content.text()
298 raise errors.UnavailableRepresentation(300 raise UnavailableRepresentation(
299 factory.key, target_storage_kind, factory.storage_kind)301 factory.key, target_storage_kind, factory.storage_kind)
300302
301303
@@ -312,7 +314,7 @@
312 return b''.join(content.text())314 return b''.join(content.text())
313 elif target_storage_kind in ('chunked', 'lines'):315 elif target_storage_kind in ('chunked', 'lines'):
314 return content.text()316 return content.text()
315 raise errors.UnavailableRepresentation(317 raise UnavailableRepresentation(
316 factory.key, target_storage_kind, factory.storage_kind)318 factory.key, target_storage_kind, factory.storage_kind)
317319
318320
@@ -340,7 +342,7 @@
340 return b''.join(content.text())342 return b''.join(content.text())
341 elif target_storage_kind in ('chunked', 'lines'):343 elif target_storage_kind in ('chunked', 'lines'):
342 return content.text()344 return content.text()
343 raise errors.UnavailableRepresentation(345 raise UnavailableRepresentation(
344 factory.key, target_storage_kind, factory.storage_kind)346 factory.key, target_storage_kind, factory.storage_kind)
345347
346348
@@ -418,7 +420,7 @@
418 return self._knit.get_lines(self.key[0])420 return self._knit.get_lines(self.key[0])
419 elif storage_kind == 'fulltext':421 elif storage_kind == 'fulltext':
420 return self._knit.get_text(self.key[0])422 return self._knit.get_text(self.key[0])
421 raise errors.UnavailableRepresentation(self.key, storage_kind,423 raise UnavailableRepresentation(self.key, storage_kind,
422 self.storage_kind)424 self.storage_kind)
423425
424 def iter_bytes_as(self, storage_kind):426 def iter_bytes_as(self, storage_kind):
@@ -466,7 +468,7 @@
466 return chunks468 return chunks
467 else:469 else:
468 return b''.join(chunks)470 return b''.join(chunks)
469 raise errors.UnavailableRepresentation(self.key, storage_kind,471 raise UnavailableRepresentation(self.key, storage_kind,
470 self.storage_kind)472 self.storage_kind)
471473
472 def iter_bytes_as(self, storage_kind):474 def iter_bytes_as(self, storage_kind):
@@ -1068,7 +1070,7 @@
1068 # that out.1070 # that out.
1069 digest = sha_string(line_bytes)1071 digest = sha_string(line_bytes)
1070 if nostore_sha == digest:1072 if nostore_sha == digest:
1071 raise errors.ExistingContent1073 raise ExistingContent
10721074
1073 present_parents = []1075 present_parents = []
1074 if parent_texts is None:1076 if parent_texts is None:
@@ -1793,7 +1795,7 @@
1793 try:1795 try:
1794 # Try getting a fulltext directly from the record.1796 # Try getting a fulltext directly from the record.
1795 lines = record.get_bytes_as('lines')1797 lines = record.get_bytes_as('lines')
1796 except errors.UnavailableRepresentation:1798 except UnavailableRepresentation:
1797 adapter_key = record.storage_kind, 'lines'1799 adapter_key = record.storage_kind, 'lines'
1798 adapter = get_adapter(adapter_key)1800 adapter = get_adapter(adapter_key)
1799 lines = adapter.get_bytes(record, 'lines')1801 lines = adapter.get_bytes(record, 'lines')
18001802
=== modified file 'breezy/bzr/serializer.py'
--- breezy/bzr/serializer.py 2020-01-31 10:39:02 +0000
+++ breezy/bzr/serializer.py 2020-06-26 01:36:03 +0000
@@ -18,7 +18,28 @@
1818
19from __future__ import absolute_import19from __future__ import absolute_import
2020
21from .. import registry21from .. import errors, registry
22
23
24class BadInventoryFormat(errors.BzrError):
25
26 _fmt = "Root class for inventory serialization errors"
27
28
29class UnexpectedInventoryFormat(BadInventoryFormat):
30
31 _fmt = "The inventory was not in the expected format:\n %(msg)s"
32
33 def __init__(self, msg):
34 BadInventoryFormat.__init__(self, msg=msg)
35
36
37class UnsupportedInventoryKind(errors.BzrError):
38
39 _fmt = """Unsupported entry kind %(kind)s"""
40
41 def __init__(self, kind):
42 self.kind = kind
2243
2344
24class Serializer(object):45class Serializer(object):
2546
=== modified file 'breezy/bzr/tests/__init__.py'
--- breezy/bzr/tests/__init__.py 2020-06-17 17:41:09 +0000
+++ breezy/bzr/tests/__init__.py 2020-06-26 01:36:03 +0000
@@ -84,6 +84,7 @@
84 'test_versionedfile',84 'test_versionedfile',
85 'test_vf_search',85 'test_vf_search',
86 'test_vfs_ratchet',86 'test_vfs_ratchet',
87 'test_workingtree',
87 'test_workingtree_4',88 'test_workingtree_4',
88 'test_weave',89 'test_weave',
89 'test_xml',90 'test_xml',
9091
=== modified file 'breezy/bzr/tests/per_versionedfile.py'
--- breezy/bzr/tests/per_versionedfile.py 2020-06-12 17:33:41 +0000
+++ breezy/bzr/tests/per_versionedfile.py 2020-06-26 01:36:03 +0000
@@ -61,8 +61,10 @@
61from ..versionedfile import (61from ..versionedfile import (
62 ChunkedContentFactory,62 ChunkedContentFactory,
63 ConstantMapper,63 ConstantMapper,
64 ExistingContent,
64 HashEscapedPrefixMapper,65 HashEscapedPrefixMapper,
65 PrefixMapper,66 PrefixMapper,
67 UnavailableRepresentation,
66 VirtualVersionedFiles,68 VirtualVersionedFiles,
67 make_versioned_files_factory,69 make_versioned_files_factory,
68 )70 )
@@ -306,7 +308,7 @@
306 # we now have a copy of all the lines in the vf.308 # we now have a copy of all the lines in the vf.
307 for sha, (version, lines) in zip(309 for sha, (version, lines) in zip(
308 shas, (empty_text, sample_text_nl, sample_text_no_nl)):310 shas, (empty_text, sample_text_nl, sample_text_no_nl)):
309 self.assertRaises(errors.ExistingContent,311 self.assertRaises(ExistingContent,
310 vf.add_lines, version + b"2", [], lines,312 vf.add_lines, version + b"2", [], lines,
311 nostore_sha=sha)313 nostore_sha=sha)
312 # and no new version should have been added.314 # and no new version should have been added.
@@ -331,7 +333,7 @@
331 raise TestSkipped("add_lines_with_ghosts is optional")333 raise TestSkipped("add_lines_with_ghosts is optional")
332 for sha, (version, lines) in zip(334 for sha, (version, lines) in zip(
333 shas, (empty_text, sample_text_nl, sample_text_no_nl)):335 shas, (empty_text, sample_text_nl, sample_text_no_nl)):
334 self.assertRaises(errors.ExistingContent,336 self.assertRaises(ExistingContent,
335 vf.add_lines_with_ghosts, version + b"2", [], lines,337 vf.add_lines_with_ghosts, version + b"2", [], lines,
336 nostore_sha=sha)338 nostore_sha=sha)
337 # and no new version should have been added.339 # and no new version should have been added.
@@ -1647,10 +1649,10 @@
1647 for sha, (version, lines) in zip(1649 for sha, (version, lines) in zip(
1648 shas, (empty_text, sample_text_nl, sample_text_no_nl)):1650 shas, (empty_text, sample_text_nl, sample_text_no_nl)):
1649 new_key = self.get_simple_key(version + b"2")1651 new_key = self.get_simple_key(version + b"2")
1650 self.assertRaises(errors.ExistingContent,1652 self.assertRaises(ExistingContent,
1651 vf.add_lines, new_key, [], lines,1653 vf.add_lines, new_key, [], lines,
1652 nostore_sha=sha)1654 nostore_sha=sha)
1653 self.assertRaises(errors.ExistingContent,1655 self.assertRaises(ExistingContent,
1654 vf.add_lines, new_key, [], lines,1656 vf.add_lines, new_key, [], lines,
1655 nostore_sha=sha)1657 nostore_sha=sha)
1656 # and no new version should have been added.1658 # and no new version should have been added.
@@ -1985,7 +1987,7 @@
1985 factory.sha1)1987 factory.sha1)
1986 self.assertEqual(parent_map[factory.key], factory.parents)1988 self.assertEqual(parent_map[factory.key], factory.parents)
1987 # currently no stream emits mpdiff1989 # currently no stream emits mpdiff
1988 self.assertRaises(errors.UnavailableRepresentation,1990 self.assertRaises(UnavailableRepresentation,
1989 factory.get_bytes_as, 'mpdiff')1991 factory.get_bytes_as, 'mpdiff')
1990 self.assertIsInstance(factory.get_bytes_as(factory.storage_kind),1992 self.assertIsInstance(factory.get_bytes_as(factory.storage_kind),
1991 bytes)1993 bytes)
19921994
=== modified file 'breezy/bzr/tests/test_inv.py'
--- breezy/bzr/tests/test_inv.py 2020-06-10 21:13:00 +0000
+++ breezy/bzr/tests/test_inv.py 2020-06-26 01:36:03 +0000
@@ -31,6 +31,7 @@
31 )31 )
32from ..inventory import (32from ..inventory import (
33 CHKInventory,33 CHKInventory,
34 DuplicateFileId,
34 Inventory,35 Inventory,
35 ROOT_ID,36 ROOT_ID,
36 InventoryFile,37 InventoryFile,
@@ -1601,3 +1602,12 @@
1601 inv.get_entry(b'thefileid').executable = True1602 inv.get_entry(b'thefileid').executable = True
1602 self.assertFalse(tree.root_inventory.get_entry(1603 self.assertFalse(tree.root_inventory.get_entry(
1603 b'thefileid').executable)1604 b'thefileid').executable)
1605
1606
1607class ErrorTests(TestCase):
1608
1609 def test_duplicate_file_id(self):
1610 error = DuplicateFileId('a_file_id', 'foo')
1611 self.assertEqualDiff(
1612 'File id {a_file_id} already exists in inventory as foo',
1613 str(error))
16041614
=== modified file 'breezy/bzr/tests/test_versionedfile.py'
--- breezy/bzr/tests/test_versionedfile.py 2020-06-10 02:56:53 +0000
+++ breezy/bzr/tests/test_versionedfile.py 2020-06-26 01:36:03 +0000
@@ -137,3 +137,13 @@
137 multiparent.MultiParent([multiparent.NewText([b'first\n'])]),137 multiparent.MultiParent([multiparent.NewText([b'first\n'])]),
138 ]138 ]
139 self.assertEqual(expected_diffs, diffs)139 self.assertEqual(expected_diffs, diffs)
140
141
142class ErrorTests(tests.TestCase):
143
144 def test_unavailable_representation(self):
145 error = versionedfile.UnavailableRepresentation(
146 ('key',), "mpdiff", "fulltext")
147 self.assertEqualDiff("The encoding 'mpdiff' is not available for key "
148 "('key',) which is encoded as 'fulltext'.",
149 str(error))
140150
=== added file 'breezy/bzr/tests/test_workingtree.py'
--- breezy/bzr/tests/test_workingtree.py 1970-01-01 00:00:00 +0000
+++ breezy/bzr/tests/test_workingtree.py 2020-06-26 01:36:03 +0000
@@ -0,0 +1,33 @@
1# Copyright (C) 2007-2012, 2016 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17"""Tests for InventoryWorkingTree"""
18
19from . import TestCase
20
21from ..workingtree import InventoryModified
22
23
24class ErrorTests(TestCase):
25
26 def test_inventory_modified(self):
27 error = InventoryModified("a tree to be repred")
28 self.assertEqualDiff("The current inventory for the tree 'a tree to "
29 "be repred' has been modified, so a clean inventory cannot be "
30 "read without data loss.",
31 str(error))
32
33
034
=== modified file 'breezy/bzr/tests/test_xml.py'
--- breezy/bzr/tests/test_xml.py 2020-06-10 02:56:53 +0000
+++ breezy/bzr/tests/test_xml.py 2020-06-26 01:36:03 +0000
@@ -21,6 +21,7 @@
21 )21 )
22from .. import (22from .. import (
23 inventory,23 inventory,
24 serializer,
24 xml6,25 xml6,
25 xml7,26 xml7,
26 xml8,27 xml8,
@@ -409,10 +410,10 @@
409 """Can't accidentally open a file with wrong serializer"""410 """Can't accidentally open a file with wrong serializer"""
410 s_v6 = breezy.bzr.xml6.serializer_v6411 s_v6 = breezy.bzr.xml6.serializer_v6
411 s_v7 = xml7.serializer_v7412 s_v7 = xml7.serializer_v7
412 self.assertRaises(errors.UnexpectedInventoryFormat,413 self.assertRaises(serializer.UnexpectedInventoryFormat,
413 s_v7.read_inventory_from_lines,414 s_v7.read_inventory_from_lines,
414 breezy.osutils.split_lines(_expected_inv_v5))415 breezy.osutils.split_lines(_expected_inv_v5))
415 self.assertRaises(errors.UnexpectedInventoryFormat,416 self.assertRaises(serializer.UnexpectedInventoryFormat,
416 s_v6.read_inventory_from_lines,417 s_v6.read_inventory_from_lines,
417 breezy.osutils.split_lines(_expected_inv_v7))418 breezy.osutils.split_lines(_expected_inv_v7))
418419
@@ -424,9 +425,9 @@
424 inv.root.revision = b'root-rev'425 inv.root.revision = b'root-rev'
425 inv.add(inventory.TreeReference(b'nested-id', 'nested', b'tree-root-321',426 inv.add(inventory.TreeReference(b'nested-id', 'nested', b'tree-root-321',
426 b'rev-outer', b'rev-inner'))427 b'rev-outer', b'rev-inner'))
427 self.assertRaises(errors.UnsupportedInventoryKind,428 self.assertRaises(serializer.UnsupportedInventoryKind,
428 s_v5.write_inventory_to_lines, inv)429 s_v5.write_inventory_to_lines, inv)
429 self.assertRaises(errors.UnsupportedInventoryKind,430 self.assertRaises(serializer.UnsupportedInventoryKind,
430 s_v6.write_inventory_to_lines, inv)431 s_v6.write_inventory_to_lines, inv)
431 lines = s_v7.write_inventory_to_chunks(inv)432 lines = s_v7.write_inventory_to_chunks(inv)
432 inv2 = s_v7.read_inventory_from_lines(lines)433 inv2 = s_v7.read_inventory_from_lines(lines)
@@ -528,7 +529,7 @@
528 def test_serialization_error(self):529 def test_serialization_error(self):
529 s_v5 = breezy.bzr.xml5.serializer_v5530 s_v5 = breezy.bzr.xml5.serializer_v5
530 e = self.assertRaises(531 e = self.assertRaises(
531 errors.UnexpectedInventoryFormat,532 serializer.UnexpectedInventoryFormat,
532 s_v5.read_inventory_from_lines, [b"<Notquitexml"])533 s_v5.read_inventory_from_lines, [b"<Notquitexml"])
533 self.assertEqual(str(e), "unclosed token: line 1, column 0")534 self.assertEqual(str(e), "unclosed token: line 1, column 0")
534535
535536
=== modified file 'breezy/bzr/versionedfile.py'
--- breezy/bzr/versionedfile.py 2020-06-12 17:33:41 +0000
+++ breezy/bzr/versionedfile.py 2020-06-26 01:36:03 +0000
@@ -71,6 +71,23 @@
71 'breezy.bzr.knit', 'DeltaAnnotatedToFullText')71 'breezy.bzr.knit', 'DeltaAnnotatedToFullText')
7272
7373
74class UnavailableRepresentation(errors.InternalBzrError):
75
76 _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
77 "is encoded as '%(native)s'.")
78
79 def __init__(self, key, wanted, native):
80 errors.InternalBzrError.__init__(self)
81 self.wanted = wanted
82 self.native = native
83 self.key = key
84
85
86class ExistingContent(errors.BzrError):
87
88 _fmt = "The content being inserted is already present."
89
90
74class ContentFactory(object):91class ContentFactory(object):
75 """Abstract interface for insertion and retrieval from a VersionedFile.92 """Abstract interface for insertion and retrieval from a VersionedFile.
7693
@@ -134,8 +151,8 @@
134 if self._chunks_are_lines:151 if self._chunks_are_lines:
135 return self._chunks152 return self._chunks
136 return list(osutils.chunks_to_lines(self._chunks))153 return list(osutils.chunks_to_lines(self._chunks))
137 raise errors.UnavailableRepresentation(self.key, storage_kind,154 raise UnavailableRepresentation(self.key, storage_kind,
138 self.storage_kind)155 self.storage_kind)
139156
140 def iter_bytes_as(self, storage_kind):157 def iter_bytes_as(self, storage_kind):
141 if storage_kind == 'chunked':158 if storage_kind == 'chunked':
@@ -144,8 +161,8 @@
144 if self._chunks_are_lines:161 if self._chunks_are_lines:
145 return iter(self._chunks)162 return iter(self._chunks)
146 return iter(osutils.chunks_to_lines(self._chunks))163 return iter(osutils.chunks_to_lines(self._chunks))
147 raise errors.UnavailableRepresentation(self.key, storage_kind,164 raise UnavailableRepresentation(self.key, storage_kind,
148 self.storage_kind)165 self.storage_kind)
149166
150class FulltextContentFactory(ContentFactory):167class FulltextContentFactory(ContentFactory):
151 """Static data content factory.168 """Static data content factory.
@@ -181,16 +198,16 @@
181 return [self._text]198 return [self._text]
182 elif storage_kind == 'lines':199 elif storage_kind == 'lines':
183 return osutils.split_lines(self._text)200 return osutils.split_lines(self._text)
184 raise errors.UnavailableRepresentation(self.key, storage_kind,201 raise UnavailableRepresentation(self.key, storage_kind,
185 self.storage_kind)202 self.storage_kind)
186203
187 def iter_bytes_as(self, storage_kind):204 def iter_bytes_as(self, storage_kind):
188 if storage_kind == 'chunked':205 if storage_kind == 'chunked':
189 return iter([self._text])206 return iter([self._text])
190 elif storage_kind == 'lines':207 elif storage_kind == 'lines':
191 return iter(osutils.split_lines(self._text))208 return iter(osutils.split_lines(self._text))
192 raise errors.UnavailableRepresentation(self.key, storage_kind,209 raise UnavailableRepresentation(self.key, storage_kind,
193 self.storage_kind)210 self.storage_kind)
194211
195212
196class FileContentFactory(ContentFactory):213class FileContentFactory(ContentFactory):
@@ -213,8 +230,8 @@
213 return list(osutils.file_iterator(self.file))230 return list(osutils.file_iterator(self.file))
214 elif storage_kind == 'lines':231 elif storage_kind == 'lines':
215 return list(self.file.readlines())232 return list(self.file.readlines())
216 raise errors.UnavailableRepresentation(self.key, storage_kind,233 raise UnavailableRepresentation(self.key, storage_kind,
217 self.storage_kind)234 self.storage_kind)
218235
219 def iter_bytes_as(self, storage_kind):236 def iter_bytes_as(self, storage_kind):
220 self.file.seek(0)237 self.file.seek(0)
@@ -222,8 +239,8 @@
222 return osutils.file_iterator(self.file)239 return osutils.file_iterator(self.file)
223 elif storage_kind == 'lines':240 elif storage_kind == 'lines':
224 return self.file241 return self.file
225 raise errors.UnavailableRepresentation(self.key, storage_kind,242 raise UnavailableRepresentation(self.key, storage_kind,
226 self.storage_kind)243 self.storage_kind)
227244
228245
229class AbsentContentFactory(ContentFactory):246class AbsentContentFactory(ContentFactory):
230247
=== modified file 'breezy/bzr/vf_repository.py'
--- breezy/bzr/vf_repository.py 2020-02-09 01:16:06 +0000
+++ breezy/bzr/vf_repository.py 2020-06-26 01:36:03 +0000
@@ -499,7 +499,7 @@
499 file_id, file_obj, heads, nostore_sha,499 file_id, file_obj, heads, nostore_sha,
500 size=(stat_value.st_size if stat_value else None))500 size=(stat_value.st_size if stat_value else None))
501 yield change.path[1], (entry.text_sha1, stat_value)501 yield change.path[1], (entry.text_sha1, stat_value)
502 except errors.ExistingContent:502 except versionedfile.ExistingContent:
503 # No content change against a carry_over parent503 # No content change against a carry_over parent
504 # Perhaps this should also yield a fs hash update?504 # Perhaps this should also yield a fs hash update?
505 carried_over = True505 carried_over = True
506506
=== modified file 'breezy/bzr/weave.py'
--- breezy/bzr/weave.py 2020-06-12 17:33:41 +0000
+++ breezy/bzr/weave.py 2020-06-26 01:36:03 +0000
@@ -81,7 +81,6 @@
81from ..errors import (81from ..errors import (
82 RevisionAlreadyPresent,82 RevisionAlreadyPresent,
83 RevisionNotPresent,83 RevisionNotPresent,
84 UnavailableRepresentation,
85 )84 )
86from ..osutils import dirname, sha, sha_strings, split_lines85from ..osutils import dirname, sha, sha_strings, split_lines
87from ..revision import NULL_REVISION86from ..revision import NULL_REVISION
@@ -93,7 +92,9 @@
93 AbsentContentFactory,92 AbsentContentFactory,
94 adapter_registry,93 adapter_registry,
95 ContentFactory,94 ContentFactory,
95 ExistingContent,
96 sort_groupcompress,96 sort_groupcompress,
97 UnavailableRepresentation,
97 VersionedFile,98 VersionedFile,
98 )99 )
99from .weavefile import _read_weave_v5, write_weave_v5100from .weavefile import _read_weave_v5, write_weave_v5
@@ -488,7 +489,7 @@
488 if not sha1:489 if not sha1:
489 sha1 = sha_strings(lines)490 sha1 = sha_strings(lines)
490 if sha1 == nostore_sha:491 if sha1 == nostore_sha:
491 raise errors.ExistingContent492 raise ExistingContent
492 if version_id is None:493 if version_id is None:
493 version_id = b"sha1:" + sha1494 version_id = b"sha1:" + sha1
494 if version_id in self._name_map:495 if version_id in self._name_map:
495496
=== modified file 'breezy/bzr/workingtree.py'
--- breezy/bzr/workingtree.py 2020-01-30 16:13:31 +0000
+++ breezy/bzr/workingtree.py 2020-06-26 01:36:03 +0000
@@ -62,6 +62,7 @@
62 )62 )
63from breezy.bzr import (63from breezy.bzr import (
64 inventory,64 inventory,
65 serializer,
65 xml5,66 xml5,
66 xml7,67 xml7,
67 )68 )
@@ -101,6 +102,15 @@
101ERROR_PATH_NOT_FOUND = 3 # WindowsError errno code, equivalent to ENOENT102ERROR_PATH_NOT_FOUND = 3 # WindowsError errno code, equivalent to ENOENT
102103
103104
105class InventoryModified(errors.InternalBzrError):
106
107 _fmt = ("The current inventory for the tree %(tree)r has been modified,"
108 " so a clean inventory cannot be read without data loss.")
109
110 def __init__(self, tree):
111 self.tree = tree
112
113
104class InventoryWorkingTree(WorkingTree, MutableInventoryTree):114class InventoryWorkingTree(WorkingTree, MutableInventoryTree):
105 """Base class for working trees that are inventory-oriented.115 """Base class for working trees that are inventory-oriented.
106116
@@ -655,7 +665,7 @@
655 # binary.665 # binary.
656 with self.lock_read():666 with self.lock_read():
657 if self._inventory_is_modified:667 if self._inventory_is_modified:
658 raise errors.InventoryModified(self)668 raise InventoryModified(self)
659 with self._transport.get('inventory') as f:669 with self._transport.get('inventory') as f:
660 result = self._deserialize(f)670 result = self._deserialize(f)
661 self._set_inventory(result, dirty=False)671 self._set_inventory(result, dirty=False)
@@ -812,7 +822,7 @@
812 if inv.revision_id == revision_id:822 if inv.revision_id == revision_id:
813 return InventoryRevisionTree(823 return InventoryRevisionTree(
814 self.branch.repository, inv, revision_id)824 self.branch.repository, inv, revision_id)
815 except errors.BadInventoryFormat:825 except serializer.BadInventoryFormat:
816 pass826 pass
817 # raise if there was no inventory, or if we read the wrong inventory.827 # raise if there was no inventory, or if we read the wrong inventory.
818 raise errors.NoSuchRevisionInTree(self, revision_id)828 raise errors.NoSuchRevisionInTree(self, revision_id)
819829
=== modified file 'breezy/bzr/xml5.py'
--- breezy/bzr/xml5.py 2020-01-31 02:49:47 +0000
+++ breezy/bzr/xml5.py 2020-06-26 01:36:03 +0000
@@ -75,8 +75,7 @@
75 raise errors.BzrError("parent_id {%s} not in inventory"75 raise errors.BzrError("parent_id {%s} not in inventory"
76 % (parent_id,))76 % (parent_id,))
77 if ie.file_id in byid:77 if ie.file_id in byid:
78 raise errors.DuplicateFileId(ie.file_id,78 raise inventory.DuplicateFileId(ie.file_id, byid[ie.file_id])
79 byid[ie.file_id])
80 if ie.name in parent.children:79 if ie.name in parent.children:
81 raise errors.BzrError(80 raise errors.BzrError(
82 "%s is already versioned" % (81 "%s is already versioned" % (
8382
=== modified file 'breezy/bzr/xml_serializer.py'
--- breezy/bzr/xml_serializer.py 2020-01-31 10:39:02 +0000
+++ breezy/bzr/xml_serializer.py 2020-06-26 01:36:03 +0000
@@ -86,7 +86,7 @@
86 entry_cache=entry_cache,86 entry_cache=entry_cache,
87 return_from_cache=return_from_cache)87 return_from_cache=return_from_cache)
88 except ParseError as e:88 except ParseError as e:
89 raise errors.UnexpectedInventoryFormat(str(e))89 raise serializer.UnexpectedInventoryFormat(str(e))
9090
91 def read_inventory(self, f, revision_id=None):91 def read_inventory(self, f, revision_id=None):
92 try:92 try:
@@ -96,7 +96,7 @@
96 finally:96 finally:
97 f.close()97 f.close()
98 except ParseError as e:98 except ParseError as e:
99 raise errors.UnexpectedInventoryFormat(str(e))99 raise serializer.UnexpectedInventoryFormat(str(e))
100100
101 def write_revision_to_string(self, rev):101 def write_revision_to_string(self, rev):
102 return b''.join(self.write_revision_to_lines(rev))102 return b''.join(self.write_revision_to_lines(rev))
@@ -320,7 +320,7 @@
320 ie = inventory.TreeReference(file_id, name, parent_id, revision,320 ie = inventory.TreeReference(file_id, name, parent_id, revision,
321 reference_revision)321 reference_revision)
322 else:322 else:
323 raise errors.UnsupportedInventoryKind(kind)323 raise serializer.UnsupportedInventoryKind(kind)
324 ie.revision = revision324 ie.revision = revision
325 if revision is not None and entry_cache is not None:325 if revision is not None and entry_cache is not None:
326 # We cache a copy() because callers like to mutate objects, and326 # We cache a copy() because callers like to mutate objects, and
@@ -344,11 +344,11 @@
344 encountered344 encountered
345 """345 """
346 if elt.tag != 'inventory':346 if elt.tag != 'inventory':
347 raise errors.UnexpectedInventoryFormat('Root tag is %r' % elt.tag)347 raise serializer.UnexpectedInventoryFormat('Root tag is %r' % elt.tag)
348 format = elt.get('format')348 format = elt.get('format')
349 if ((format is None and format_num is not None) or349 if ((format is None and format_num is not None) or
350 format.encode() != format_num):350 format.encode() != format_num):
351 raise errors.UnexpectedInventoryFormat('Invalid format version %r'351 raise serializer.UnexpectedInventoryFormat('Invalid format version %r'
352 % format)352 % format)
353 revision_id = elt.get('revision_id')353 revision_id = elt.get('revision_id')
354 if revision_id is not None:354 if revision_id is not None:
@@ -422,7 +422,7 @@
422 parent_str))422 parent_str))
423 elif ie.kind == 'tree-reference':423 elif ie.kind == 'tree-reference':
424 if ie.kind not in supported_kinds:424 if ie.kind not in supported_kinds:
425 raise errors.UnsupportedInventoryKind(ie.kind)425 raise serializer.UnsupportedInventoryKind(ie.kind)
426 if not working:426 if not working:
427 append(b'<tree-reference file_id="%s" name="%s"%s '427 append(b'<tree-reference file_id="%s" name="%s"%s '
428 b'revision="%s" reference_revision="%s" />\n' % (428 b'revision="%s" reference_revision="%s" />\n' % (
@@ -437,5 +437,5 @@
437 encode_and_escape(ie.name),437 encode_and_escape(ie.name),
438 parent_str))438 parent_str))
439 else:439 else:
440 raise errors.UnsupportedInventoryKind(ie.kind)440 raise serializer.UnsupportedInventoryKind(ie.kind)
441 append(b'</inventory>\n')441 append(b'</inventory>\n')
442442
=== modified file 'breezy/errors.py'
--- breezy/errors.py 2020-06-21 02:47:58 +0000
+++ breezy/errors.py 2020-06-26 01:36:03 +0000
@@ -250,15 +250,6 @@
250 _fmt = "The branch '%(branch)s' is not stacked."250 _fmt = "The branch '%(branch)s' is not stacked."
251251
252252
253class InventoryModified(InternalBzrError):
254
255 _fmt = ("The current inventory for the tree %(tree)r has been modified,"
256 " so a clean inventory cannot be read without data loss.")
257
258 def __init__(self, tree):
259 self.tree = tree
260
261
262class NoWorkingTree(BzrError):253class NoWorkingTree(BzrError):
263254
264 _fmt = 'No WorkingTree exists for "%(base)s".'255 _fmt = 'No WorkingTree exists for "%(base)s".'
@@ -406,18 +397,6 @@
406 _fmt = 'Permission denied: "%(path)s"%(extra)s'397 _fmt = 'Permission denied: "%(path)s"%(extra)s'
407398
408399
409class UnavailableRepresentation(InternalBzrError):
410
411 _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
412 "is encoded as '%(native)s'.")
413
414 def __init__(self, key, wanted, native):
415 InternalBzrError.__init__(self)
416 self.wanted = wanted
417 self.native = native
418 self.key = key
419
420
421class UnsupportedProtocol(PathError):400class UnsupportedProtocol(PathError):
422401
423 _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'402 _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
@@ -1499,16 +1478,6 @@
1499 self.file_id = file_id1478 self.file_id = file_id
15001479
15011480
1502class DuplicateFileId(BzrError):
1503
1504 _fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1505
1506 def __init__(self, file_id, entry):
1507 BzrError.__init__(self)
1508 self.file_id = file_id
1509 self.entry = entry
1510
1511
1512class DuplicateKey(BzrError):1481class DuplicateKey(BzrError):
15131482
1514 _fmt = "Key %(key)s is already present in map"1483 _fmt = "Key %(key)s is already present in map"
@@ -1522,23 +1491,6 @@
1522 self.prefix = prefix1491 self.prefix = prefix
15231492
15241493
1525class MalformedTransform(InternalBzrError):
1526
1527 _fmt = "Tree transform is malformed %(conflicts)r"
1528
1529
1530class NoFinalPath(BzrError):
1531
1532 _fmt = ("No final name for trans_id %(trans_id)r\n"
1533 "file-id: %(file_id)r\n"
1534 "root trans-id: %(root_trans_id)r\n")
1535
1536 def __init__(self, trans_id, transform):
1537 self.trans_id = trans_id
1538 self.file_id = transform.final_file_id(trans_id)
1539 self.root_trans_id = transform.root
1540
1541
1542class BzrBadParameter(InternalBzrError):1494class BzrBadParameter(InternalBzrError):
15431495
1544 _fmt = "Bad parameter: %(param)r"1496 _fmt = "Bad parameter: %(param)r"
@@ -1556,11 +1508,6 @@
1556 _fmt = "Parameter %(param)s is neither unicode nor utf8."1508 _fmt = "Parameter %(param)s is neither unicode nor utf8."
15571509
15581510
1559class ReusingTransform(BzrError):
1560
1561 _fmt = "Attempt to reuse a transform that has already been applied."
1562
1563
1564class CantMoveRoot(BzrError):1511class CantMoveRoot(BzrError):
15651512
1566 _fmt = "Moving the root directory is not supported at this time"1513 _fmt = "Moving the root directory is not supported at this time"
@@ -1706,12 +1653,6 @@
1706 _fmt = "Diff3 is not installed on this machine."1653 _fmt = "Diff3 is not installed on this machine."
17071654
17081655
1709class ExistingContent(BzrError):
1710 # Added in breezy 0.92, used by VersionedFile.add_lines.
1711
1712 _fmt = "The content being inserted is already present."
1713
1714
1715class ExistingLimbo(BzrError):1656class ExistingLimbo(BzrError):
17161657
1717 _fmt = """This tree contains left-over files from a failed operation.1658 _fmt = """This tree contains left-over files from a failed operation.
@@ -1733,17 +1674,6 @@
1733 BzrError.__init__(self, pending_deletion=pending_deletion)1674 BzrError.__init__(self, pending_deletion=pending_deletion)
17341675
17351676
1736class ImmortalLimbo(BzrError):
1737
1738 _fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
1739 Please examine %(limbo_dir)s to see if it contains any files you wish to
1740 keep, and delete it when you are done."""
1741
1742 def __init__(self, limbo_dir):
1743 BzrError.__init__(self)
1744 self.limbo_dir = limbo_dir
1745
1746
1747class ImmortalPendingDeletion(BzrError):1677class ImmortalPendingDeletion(BzrError):
17481678
1749 _fmt = ("Unable to delete transform temporary directory "1679 _fmt = ("Unable to delete transform temporary directory "
@@ -1970,19 +1900,6 @@
1970 self.other = other1900 self.other = other
19711901
19721902
1973class BadInventoryFormat(BzrError):
1974
1975 _fmt = "Root class for inventory serialization errors"
1976
1977
1978class UnexpectedInventoryFormat(BadInventoryFormat):
1979
1980 _fmt = "The inventory was not in the expected format:\n %(msg)s"
1981
1982 def __init__(self, msg):
1983 BadInventoryFormat.__init__(self, msg=msg)
1984
1985
1986class RootNotRich(BzrError):1903class RootNotRich(BzrError):
19871904
1988 _fmt = """This operation requires rich root data storage"""1905 _fmt = """This operation requires rich root data storage"""
@@ -2045,16 +1962,6 @@
2045 " branch location."1962 " branch location."
20461963
20471964
2048class IllegalMergeDirectivePayload(BzrError):
2049 """A merge directive contained something other than a patch or bundle"""
2050
2051 _fmt = "Bad merge directive payload %(start)r"
2052
2053 def __init__(self, start):
2054 BzrError(self)
2055 self.start = start
2056
2057
2058class PatchVerificationFailed(BzrError):1965class PatchVerificationFailed(BzrError):
2059 """A patch from a merge directive could not be verified"""1966 """A patch from a merge directive could not be verified"""
20601967
@@ -2084,14 +1991,6 @@
2084 self.location = location1991 self.location = location
20851992
20861993
2087class UnsupportedInventoryKind(BzrError):
2088
2089 _fmt = """Unsupported entry kind %(kind)s"""
2090
2091 def __init__(self, kind):
2092 self.kind = kind
2093
2094
2095class BadSubsumeSource(BzrError):1994class BadSubsumeSource(BzrError):
20961995
2097 _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"1996 _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
20981997
=== modified file 'breezy/git/annotate.py'
--- breezy/git/annotate.py 2020-02-09 01:27:02 +0000
+++ breezy/git/annotate.py 2020-06-26 01:36:03 +0000
@@ -23,9 +23,9 @@
23 )23 )
2424
25from .. import osutils25from .. import osutils
26from ..bzr.versionedfile import UnavailableRepresentation
26from ..errors import (27from ..errors import (
27 NoSuchRevision,28 NoSuchRevision,
28 UnavailableRepresentation,
29 )29 )
30from ..graph import Graph30from ..graph import Graph
31from ..revision import (31from ..revision import (
3232
=== modified file 'breezy/merge_directive.py'
--- breezy/merge_directive.py 2020-01-11 17:41:33 +0000
+++ breezy/merge_directive.py 2020-06-26 01:36:03 +0000
@@ -49,6 +49,16 @@
49 )49 )
5050
5151
52class IllegalMergeDirectivePayload(errors.BzrError):
53 """A merge directive contained something other than a patch or bundle"""
54
55 _fmt = "Bad merge directive payload %(start)r"
56
57 def __init__(self, start):
58 errors.BzrError(self)
59 self.start = start
60
61
52class MergeRequestBodyParams(object):62class MergeRequestBodyParams(object):
53 """Parameter object for the merge_request_body hook."""63 """Parameter object for the merge_request_body hook."""
5464
@@ -546,7 +556,7 @@
546 if start.startswith(b'# Begin bundle'):556 if start.startswith(b'# Begin bundle'):
547 bundle = b''.join(line_iter)557 bundle = b''.join(line_iter)
548 else:558 else:
549 raise errors.IllegalMergeDirectivePayload(start)559 raise IllegalMergeDirectivePayload(start)
550 time, timezone = timestamp.parse_patch_date(stanza.get('timestamp'))560 time, timezone = timestamp.parse_patch_date(stanza.get('timestamp'))
551 kwargs = {}561 kwargs = {}
552 for key in ('revision_id', 'testament_sha1', 'target_branch',562 for key in ('revision_id', 'testament_sha1', 'target_branch',
553563
=== modified file 'breezy/tests/per_workingtree/test_add.py'
--- breezy/tests/per_workingtree/test_add.py 2019-06-29 13:16:26 +0000
+++ breezy/tests/per_workingtree/test_add.py 2020-06-26 01:36:03 +0000
@@ -50,8 +50,8 @@
50 self.skipTest("tree does not support setting file ids")50 self.skipTest("tree does not support setting file ids")
51 self.build_tree(['a', 'b'])51 self.build_tree(['a', 'b'])
52 tree.add(['a'])52 tree.add(['a'])
53 self.assertRaises(errors.DuplicateFileId,53 self.assertRaises(
54 tree.add, ['b'], [tree.path2id('a')])54 inventory.DuplicateFileId, tree.add, ['b'], [tree.path2id('a')])
55 # And the entry should not have been added.55 # And the entry should not have been added.
56 self.assertTreeLayout(['', 'a'], tree)56 self.assertTreeLayout(['', 'a'], tree)
5757
5858
=== modified file 'breezy/tests/per_workingtree/test_read_working_inventory.py'
--- breezy/tests/per_workingtree/test_read_working_inventory.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/per_workingtree/test_read_working_inventory.py 2020-06-26 01:36:03 +0000
@@ -20,7 +20,7 @@
20from breezy.bzr import inventory20from breezy.bzr import inventory
21from breezy.tests import TestNotApplicable21from breezy.tests import TestNotApplicable
22from breezy.tests.per_workingtree import TestCaseWithWorkingTree22from breezy.tests.per_workingtree import TestCaseWithWorkingTree
23from breezy.bzr.workingtree import InventoryWorkingTree23from breezy.bzr.workingtree import InventoryWorkingTree, InventoryModified
2424
2525
26class TestReadWorkingInventory(TestCaseWithWorkingTree):26class TestReadWorkingInventory(TestCaseWithWorkingTree):
@@ -49,7 +49,7 @@
49 # OR, the call can be ignored and the changes preserved49 # OR, the call can be ignored and the changes preserved
50 try:50 try:
51 tree.read_working_inventory()51 tree.read_working_inventory()
52 except errors.InventoryModified:52 except InventoryModified:
53 pass53 pass
54 else:54 else:
55 self.assertEqual(b'new-root', tree.path2id(''))55 self.assertEqual(b'new-root', tree.path2id(''))
5656
=== modified file 'breezy/tests/test_conflicts.py'
--- breezy/tests/test_conflicts.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/test_conflicts.py 2020-06-26 01:36:03 +0000
@@ -23,6 +23,7 @@
23 option,23 option,
24 osutils,24 osutils,
25 tests,25 tests,
26 transform,
26 )27 )
27from ..sixish import text_type28from ..sixish import text_type
28from . import (29from . import (
@@ -1077,7 +1078,7 @@
1077 # This is nearly like TestResolveNonDirectoryParent but with branch and1078 # This is nearly like TestResolveNonDirectoryParent but with branch and
1078 # trunk switched. As such it should certainly produce the same1079 # trunk switched. As such it should certainly produce the same
1079 # conflict.1080 # conflict.
1080 self.assertRaises(errors.MalformedTransform,1081 self.assertRaises(transform.MalformedTransform,
1081 self.run_script, """1082 self.run_script, """
1082$ brz init trunk1083$ brz init trunk
1083...1084...
10841085
=== modified file 'breezy/tests/test_errors.py'
--- breezy/tests/test_errors.py 2019-03-04 00:16:27 +0000
+++ breezy/tests/test_errors.py 2020-06-26 01:36:03 +0000
@@ -67,11 +67,6 @@
67 "^Filename b?'bad/filen\\\\xe5me' is not valid in your current"67 "^Filename b?'bad/filen\\\\xe5me' is not valid in your current"
68 " filesystem encoding UTF-8$")68 " filesystem encoding UTF-8$")
6969
70 def test_duplicate_file_id(self):
71 error = errors.DuplicateFileId('a_file_id', 'foo')
72 self.assertEqualDiff('File id {a_file_id} already exists in inventory'
73 ' as foo', str(error))
74
75 def test_duplicate_help_prefix(self):70 def test_duplicate_help_prefix(self):
76 error = errors.DuplicateHelpPrefix('foo')71 error = errors.DuplicateHelpPrefix('foo')
77 self.assertEqualDiff('The prefix foo is in the help search path twice.',72 self.assertEqualDiff('The prefix foo is in the help search path twice.',
@@ -125,13 +120,6 @@
125 self.assertEqual("Invalid range access in path at 12: bad range",120 self.assertEqual("Invalid range access in path at 12: bad range",
126 str(error))121 str(error))
127122
128 def test_inventory_modified(self):
129 error = errors.InventoryModified("a tree to be repred")
130 self.assertEqualDiff("The current inventory for the tree 'a tree to "
131 "be repred' has been modified, so a clean inventory cannot be "
132 "read without data loss.",
133 str(error))
134
135 def test_jail_break(self):123 def test_jail_break(self):
136 error = errors.JailBreak("some url")124 error = errors.JailBreak("some url")
137 self.assertEqualDiff("An attempt to access a url outside the server"125 self.assertEqualDiff("An attempt to access a url outside the server"
@@ -199,13 +187,6 @@
199 "the currently open request.",187 "the currently open request.",
200 str(error))188 str(error))
201189
202 def test_unavailable_representation(self):
203 error = errors.UnavailableRepresentation(
204 ('key',), "mpdiff", "fulltext")
205 self.assertEqualDiff("The encoding 'mpdiff' is not available for key "
206 "('key',) which is encoded as 'fulltext'.",
207 str(error))
208
209 def test_unstackable_location(self):190 def test_unstackable_location(self):
210 error = errors.UnstackableLocationError('foo', 'bar')191 error = errors.UnstackableLocationError('foo', 'bar')
211 self.assertEqualDiff("The branch 'foo' cannot be stacked on 'bar'.",192 self.assertEqualDiff("The branch 'foo' cannot be stacked on 'bar'.",
212193
=== modified file 'breezy/tests/test_shelf.py'
--- breezy/tests/test_shelf.py 2019-09-27 02:48:17 +0000
+++ breezy/tests/test_shelf.py 2020-06-26 01:36:03 +0000
@@ -32,9 +32,6 @@
32 features,32 features,
33 KnownFailure,33 KnownFailure,
34 )34 )
35from ..errors import (
36 MalformedTransform,
37 )
3835
3936
40EMPTY_SHELF = (b"Bazaar pack format 1 (introduced in 0.18)\n"37EMPTY_SHELF = (b"Bazaar pack format 1 (introduced in 0.18)\n"
@@ -254,7 +251,7 @@
254 try:251 try:
255 creator.transform()252 creator.transform()
256 self.check_shelve_creation(creator, tree)253 self.check_shelve_creation(creator, tree)
257 except MalformedTransform:254 except transform.MalformedTransform:
258 raise KnownFailure(255 raise KnownFailure(
259 'shelving directory with ignored file: see bug #611739')256 'shelving directory with ignored file: see bug #611739')
260257
261258
=== modified file 'breezy/tests/test_transform.py'
--- breezy/tests/test_transform.py 2019-09-21 23:05:12 +0000
+++ breezy/tests/test_transform.py 2020-06-26 01:36:03 +0000
@@ -51,11 +51,8 @@
51 DuplicateKey,51 DuplicateKey,
52 ExistingLimbo,52 ExistingLimbo,
53 ExistingPendingDeletion,53 ExistingPendingDeletion,
54 ImmortalLimbo,
55 ImmortalPendingDeletion,54 ImmortalPendingDeletion,
56 LockError,55 LockError,
57 MalformedTransform,
58 ReusingTransform,
59)56)
60from ..osutils import (57from ..osutils import (
61 file_kind,58 file_kind,
@@ -86,6 +83,10 @@
86 resolve_conflicts,83 resolve_conflicts,
87 resolve_checkout,84 resolve_checkout,
88 ROOT_PARENT,85 ROOT_PARENT,
86 ImmortalLimbo,
87 MalformedTransform,
88 NoFinalPath,
89 ReusingTransform,
89 TransformPreview,90 TransformPreview,
90 TreeTransform,91 TreeTransform,
91)92)
@@ -982,7 +983,7 @@
982 self.assertEqual(('missing parent', 'Created directory', 'new-1'),983 self.assertEqual(('missing parent', 'Created directory', 'new-1'),
983 raw_conflicts.pop())984 raw_conflicts.pop())
984 # apply fail since the missing directory doesn't exist985 # apply fail since the missing directory doesn't exist
985 self.assertRaises(errors.NoFinalPath, tt.apply)986 self.assertRaises(NoFinalPath, tt.apply)
986987
987 def test_moving_versioned_directories(self):988 def test_moving_versioned_directories(self):
988 create, root = self.get_transform()989 create, root = self.get_transform()
@@ -2445,7 +2446,7 @@
2445 branch, tt = self.get_branch_and_transform()2446 branch, tt = self.get_branch_and_transform()
2446 parent_id = tt.trans_id_file_id(b'parent-id')2447 parent_id = tt.trans_id_file_id(b'parent-id')
2447 tt.new_file('file', parent_id, [b'contents'], b'file-id')2448 tt.new_file('file', parent_id, [b'contents'], b'file-id')
2448 self.assertRaises(errors.MalformedTransform, tt.commit, branch,2449 self.assertRaises(MalformedTransform, tt.commit, branch,
2449 'message')2450 'message')
24502451
2451 def test_commit_rich_revision_data(self):2452 def test_commit_rich_revision_data(self):
24522453
=== modified file 'breezy/transform.py'
--- breezy/transform.py 2020-02-09 17:10:01 +0000
+++ breezy/transform.py 2020-06-26 01:36:03 +0000
@@ -51,9 +51,9 @@
51 )51 )
52from breezy.i18n import gettext52from breezy.i18n import gettext
53""")53""")
54from .errors import (DuplicateKey, MalformedTransform,54from .errors import (DuplicateKey,
55 ReusingTransform, CantMoveRoot,55 CantMoveRoot,
56 ImmortalLimbo, NoFinalPath)56 BzrError, InternalBzrError)
57from .filters import filtered_output_bytes, ContentFilterContext57from .filters import filtered_output_bytes, ContentFilterContext
58from .mutabletree import MutableTree58from .mutabletree import MutableTree
59from .osutils import (59from .osutils import (
@@ -79,6 +79,39 @@
79ROOT_PARENT = "root-parent"79ROOT_PARENT = "root-parent"
8080
8181
82class NoFinalPath(BzrError):
83
84 _fmt = ("No final name for trans_id %(trans_id)r\n"
85 "file-id: %(file_id)r\n"
86 "root trans-id: %(root_trans_id)r\n")
87
88 def __init__(self, trans_id, transform):
89 self.trans_id = trans_id
90 self.file_id = transform.final_file_id(trans_id)
91 self.root_trans_id = transform.root
92
93
94class ReusingTransform(BzrError):
95
96 _fmt = "Attempt to reuse a transform that has already been applied."
97
98
99class MalformedTransform(InternalBzrError):
100
101 _fmt = "Tree transform is malformed %(conflicts)r"
102
103
104class ImmortalLimbo(BzrError):
105
106 _fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
107 Please examine %(limbo_dir)s to see if it contains any files you wish to
108 keep, and delete it when you are done."""
109
110 def __init__(self, limbo_dir):
111 BzrError.__init__(self)
112 self.limbo_dir = limbo_dir
113
114
82def unique_add(map, key, value):115def unique_add(map, key, value):
83 if key in map:116 if key in map:
84 raise DuplicateKey(key=key)117 raise DuplicateKey(key=key)

Subscribers

People subscribed via source and target branches