/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/chk_map.py

  • Committer: John Arbash Meinel
  • Date: 2009-08-04 14:10:09 UTC
  • mfrom: (4585 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4588.
  • Revision ID: john@arbash-meinel.com-20090804141009-uety2n17v1atk5ok
Merge bzr.dev 4585, resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
Updates to a CHKMap are done preferentially via the apply_delta method, to
28
28
allow optimisation of the update operation; but individual map/unmap calls are
29
 
possible and supported. All changes via map/unmap are buffered in memory until
30
 
the _save method is called to force serialisation of the tree. apply_delta
31
 
performs a _save implicitly.
 
29
possible and supported. Individual changes via map/unmap are buffered in memory
 
30
until the _save method is called to force serialisation of the tree.
 
31
apply_delta records its changes immediately by performing an implicit _save.
32
32
 
33
33
TODO:
34
34
-----
41
41
 
42
42
from bzrlib import lazy_import
43
43
lazy_import.lazy_import(globals(), """
44
 
from bzrlib import versionedfile
 
44
from bzrlib import (
 
45
    errors,
 
46
    versionedfile,
 
47
    )
45
48
""")
46
49
from bzrlib import (
47
50
    lru_cache,
108
111
            of old_key is removed.
109
112
        """
110
113
        delete_count = 0
 
114
        # Check preconditions first.
 
115
        new_items = set([key for (old, key, value) in delta if key is not None
 
116
            and old is None])
 
117
        existing_new = list(self.iteritems(key_filter=new_items))
 
118
        if existing_new:
 
119
            raise errors.InconsistentDeltaDelta(delta,
 
120
                "New items are already in the map %r." % existing_new)
 
121
        # Now apply changes.
111
122
        for old, new, value in delta:
112
123
            if old is not None and old != new:
113
124
                self.unmap(old, check_remap=False)
485
496
        return len(self._root_node)
486
497
 
487
498
    def map(self, key, value):
488
 
        """Map a key tuple to value."""
 
499
        """Map a key tuple to value.
 
500
        
 
501
        :param key: A key to map.
 
502
        :param value: The value to assign to key.
 
503
        """
489
504
        # Need a root object.
490
505
        self._ensure_root()
491
506
        prefix, node_details = self._root_node.map(self._store, key, value)