373
373
self.assertRaises(errors.OutSideTransaction,
374
374
inv.add_lines, 'foo', [], [])
376
def test_deserialise_sets_root_revision(self):
377
"""We must have a inventory.root.revision
379
Old versions of the XML5 serializer did not set the revision_id for
380
the whole inventory. So we grab the one from the expected text. Which
381
is valid when the api is not being abused.
383
repo = self.make_repository('.',
384
format=bzrdir.format_registry.get('knit')())
385
inv_xml = '<inventory format="5">\n</inventory>\n'
386
inv = repo.deserialise_inventory('test-rev-id', inv_xml)
387
self.assertEqual('test-rev-id', inv.root.revision)
389
def test_deserialise_uses_global_revision_id(self):
390
"""If it is set, then we re-use the global revision id"""
391
repo = self.make_repository('.',
392
format=bzrdir.format_registry.get('knit')())
393
inv_xml = ('<inventory format="5" revision_id="other-rev-id">\n'
395
# Arguably, the deserialise_inventory should detect a mismatch, and
396
# raise an error, rather than silently using one revision_id over the
398
inv = repo.deserialise_inventory('test-rev-id', inv_xml)
399
self.assertEqual('other-rev-id', inv.root.revision)
377
402
class KnitRepositoryStreamTests(test_knit.KnitTests):
378
403
"""Tests for knitrepo._get_stream_as_bytes."""