~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_inventory_delta.py

  • Committer: Andrew Bennetts
  • Date: 2009-07-31 08:31:41 UTC
  • mto: This revision was merged to the branch mainline in revision 4608.
  • Revision ID: andrew.bennetts@canonical.com-20090731083141-cx32g3lqid0tzld7
Make actual non-rich-root inventories (which have implicit root entries with non-None revisions) roundtrip through inventory-deltas correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
/\x00an-id\x00\x00different-version\x00dir
64
64
"""
65
65
 
 
66
# No root entry is included for unversioned roots.
66
67
root_only_unversioned = """format: bzr inventory delta v1 (bzr 1.14)
67
68
parent: null:
68
69
version: entry-version
69
70
versioned_root: false
70
71
tree_references: false
71
 
None\x00/\x00TREE_ROOT\x00\x00null:\x00dir
 
72
None\x00/\x00TREE_ROOT\x00\x00entry-version\x00dir
72
73
"""
73
74
 
74
75
reference_lines = """format: bzr inventory delta v1 (bzr 1.14)
292
293
        old_inv = Inventory(None)
293
294
        new_inv = Inventory(None)
294
295
        root = new_inv.make_entry('directory', '', None, 'TREE_ROOT')
 
296
        # Implicit roots are considered modified in every revision.
 
297
        root.revision = 'entry-version'
295
298
        new_inv.add(root)
296
299
        delta = new_inv._make_delta(old_inv)
297
300
        serializer = inventory_delta.InventoryDeltaSerializer()
298
301
        serializer.require_flags(False, False)
 
302
        serialized_lines = serializer.delta_to_lines(
 
303
            NULL_REVISION, 'entry-version', delta)
299
304
        self.assertEqual(StringIO(root_only_unversioned).readlines(),
300
 
            serializer.delta_to_lines(NULL_REVISION, 'entry-version', delta))
 
305
            serialized_lines)
 
306
        self.assertEqual(
 
307
            (NULL_REVISION, 'entry-version', False, False, delta),
 
308
            serializer.parse_text_bytes(''.join(serialized_lines)))
301
309
 
302
310
    def test_unversioned_non_root_errors(self):
303
311
        old_inv = Inventory(None)
337
345
        serializer.require_flags(versioned_root=False, tree_references=True)
338
346
        err = self.assertRaises(errors.BzrError,
339
347
            serializer.delta_to_lines, NULL_REVISION, 'entry-version', delta)
340
 
        self.assertEqual(str(err), 'Version present for / in TREE_ROOT')
 
348
        self.assertStartsWith(str(err), 'Version present for / in TREE_ROOT')
341
349
 
342
350
    def test_nonrichroot_non_TREE_ROOT_id_errors(self):
343
351
        old_inv = Inventory(None)