~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_chk_map.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-15 18:14:51 UTC
  • mto: (4955.4.4 respect-direction)
  • mto: This revision was merged to the branch mainline in revision 4985.
  • Revision ID: v.ladeuil+lp@free.fr-20100115181451-vrlkt09fsyv25idg
Cleanup.

* bzrlib/tests/test_log.py:
(TestGetViewRevisions.test_file_id_for_range): Fix too long lines.

* bzrlib/log.py:
(Logger): Fix typo in doc string.
(_is_obvious_ancestor): Add comment.
(_graph_view_revisions): Add comment.

* bzrlib/builtins.py:
(cmd_log): bzr-gtk provides viz but no glog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""Tests for maps built on a CHK versionedfiles facility."""
18
18
 
 
19
from itertools import izip
 
20
 
19
21
from bzrlib import (
20
22
    chk_map,
21
23
    errors,
224
226
            "      ('ddd',) 'initial ddd content'\n",
225
227
            c_map._dump_tree())
226
228
 
227
 
    def test_root_only_aaa_ddd_16(self):
 
229
    def test_one_deep_map_16(self):
228
230
        c_map = self.make_root_only_aaa_ddd_map(
229
231
                search_key_func=chk_map._search_key_16)
230
232
        # We use 'aaa' and 'ddd' because they happen to map to 'F' when using
465
467
        # updated key.
466
468
        self.assertEqual(new_root, chkmap._root_node._key)
467
469
 
468
 
    def test_apply_delete_to_internal_node(self):
469
 
        # applying a delta should be convert an internal root node to a leaf
470
 
        # node if the delta shrinks the map enough.
471
 
        store = self.get_chk_bytes()
472
 
        chkmap = CHKMap(store, None)
473
 
        # Add three items: 2 small enough to fit in one node, and one huge to
474
 
        # force multiple nodes.
475
 
        chkmap._root_node.set_maximum_size(100)
476
 
        chkmap.map(('small',), 'value')
477
 
        chkmap.map(('little',), 'value')
478
 
        chkmap.map(('very-big',), 'x' * 100)
479
 
        # (Check that we have constructed the scenario we want to test)
480
 
        self.assertIsInstance(chkmap._root_node, InternalNode)
481
 
        # Delete the huge item so that the map fits in one node again.
482
 
        delta = [(('very-big',), None, None)]
483
 
        chkmap.apply_delta(delta)
484
 
        self.assertCanonicalForm(chkmap)
485
 
        self.assertIsInstance(chkmap._root_node, LeafNode)
486
 
 
487
470
    def test_apply_new_keys_must_be_new(self):
488
471
        # applying a delta (None, "a", "b") to a map with 'a' in it generates
489
472
        # an error.
922
905
        # Unmapping the new node will check the existing nodes to see if they
923
906
        # would fit.
924
907
        # Clear the page cache so we ensure we have to read all the children
925
 
        chk_map.clear_cache()
 
908
        chk_map._page_cache.clear()
926
909
        chkmap.unmap(('aad',))
927
910
        self.assertIsInstance(chkmap._root_node._items['aaa'], LeafNode)
928
911
        self.assertIsInstance(chkmap._root_node._items['aab'], LeafNode)
962
945
        # Now clear the page cache, and only include 2 of the children in the
963
946
        # cache
964
947
        aab_key = chkmap._root_node._items['aab']
965
 
        aab_bytes = chk_map._get_cache()[aab_key]
 
948
        aab_bytes = chk_map._page_cache[aab_key]
966
949
        aac_key = chkmap._root_node._items['aac']
967
 
        aac_bytes = chk_map._get_cache()[aac_key]
968
 
        chk_map.clear_cache()
969
 
        chk_map._get_cache()[aab_key] = aab_bytes
970
 
        chk_map._get_cache()[aac_key] = aac_bytes
 
950
        aac_bytes = chk_map._page_cache[aac_key]
 
951
        chk_map._page_cache.clear()
 
952
        chk_map._page_cache[aab_key] = aab_bytes
 
953
        chk_map._page_cache[aac_key] = aac_bytes
971
954
 
972
955
        # Unmapping the new node will check the nodes from the page cache
973
956
        # first, and not have to read in 'aaa'
1108
1091
        basis_get = basis._store.get_record_stream
1109
1092
        def get_record_stream(keys, order, fulltext):
1110
1093
            if ('sha1:1adf7c0d1b9140ab5f33bb64c6275fa78b1580b7',) in keys:
1111
 
                raise AssertionError("'aaa' pointer was followed %r" % keys)
 
1094
                self.fail("'aaa' pointer was followed %r" % keys)
1112
1095
            return basis_get(keys, order, fulltext)
1113
1096
        basis._store.get_record_stream = get_record_stream
1114
1097
        result = sorted(list(target.iter_changes(basis)))