~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: John Arbash Meinel
  • Date: 2007-10-19 17:14:33 UTC
  • mto: This revision was merged to the branch mainline in revision 2924.
  • Revision ID: john@arbash-meinel.com-20071019171433-ko3319eemyhpb7kz
Fix bug #152360. The xml5 serializer should be using
the hint it was given about the revision id.
It was accidentally overwriting the revision_id to None when the
data did not hold a valid value.
Add tests that this is done properly, at both the Repository level
and at the xml5 layer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
373
373
        self.assertRaises(errors.OutSideTransaction,
374
374
            inv.add_lines, 'foo', [], [])
375
375
 
 
376
    def test_deserialise_sets_root_revision(self):
 
377
        """We must have a inventory.root.revision
 
378
 
 
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.
 
382
        """
 
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)
 
388
 
 
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'
 
394
                   '</inventory>\n')
 
395
        # Arguably, the deserialise_inventory should detect a mismatch, and
 
396
        # raise an error, rather than silently using one revision_id over the
 
397
        # other.
 
398
        inv = repo.deserialise_inventory('test-rev-id', inv_xml)
 
399
        self.assertEqual('other-rev-id', inv.root.revision)
 
400
 
376
401
 
377
402
class KnitRepositoryStreamTests(test_knit.KnitTests):
378
403
    """Tests for knitrepo._get_stream_as_bytes."""