~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_chk_map.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-07-20 08:56:45 UTC
  • mfrom: (4526.9.23 apply-inventory-delta)
  • Revision ID: pqm@pqm.ubuntu.com-20090720085645-54mtgybxua0yx6hw
(robertc) Add checks for inventory deltas which try to ensure that
        deltas that are not an exact fit are not applied. (Robert
        Collins, bug 397705, bug 367633)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from bzrlib import (
22
22
    chk_map,
 
23
    errors,
23
24
    groupcompress,
24
25
    osutils,
25
26
    tests,
63
64
class TestCaseWithStore(tests.TestCaseWithMemoryTransport):
64
65
 
65
66
    def get_chk_bytes(self):
66
 
        # The easiest way to get a CHK store is a development6 repository and
67
 
        # then work with the chk_bytes attribute directly.
 
67
        # This creates a standalone CHK store.
68
68
        factory = groupcompress.make_pack_factory(False, False, 1)
69
69
        self.chk_bytes = factory(self.get_transport())
70
70
        return self.chk_bytes
466
466
        # updated key.
467
467
        self.assertEqual(new_root, chkmap._root_node._key)
468
468
 
 
469
    def test_apply_new_keys_must_be_new(self):
 
470
        # applying a delta (None, "a", "b") to a map with 'a' in it generates
 
471
        # an error.
 
472
        chk_bytes = self.get_chk_bytes()
 
473
        root_key = CHKMap.from_dict(chk_bytes, {("a",):"b"})
 
474
        chkmap = CHKMap(chk_bytes, root_key)
 
475
        self.assertRaises(errors.InconsistentDelta, chkmap.apply_delta,
 
476
            [(None, ("a",), "b")])
 
477
        # As an error occured, the update should have left us without changing
 
478
        # anything (the root should be unchanged).
 
479
        self.assertEqual(root_key, chkmap._root_node._key)
 
480
 
469
481
    def test_apply_delta_is_deterministic(self):
470
482
        chk_bytes = self.get_chk_bytes()
471
483
        chkmap1 = CHKMap(chk_bytes, None)