~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/chk_map.py

  • Committer: Parth Malwankar
  • Date: 2010-07-14 08:53:58 UTC
  • mto: (5050.3.7 2.2)
  • mto: This revision was merged to the branch mainline in revision 5365.
  • Revision ID: parth.malwankar@gmail.com-20100714085358-6un4ny0cn908spkq
better error message for RecursiveBind

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
_INTERESTING_NEW_SIZE = 50
91
91
# If a ChildNode shrinks by more than this amount, we check for a remap
92
92
_INTERESTING_SHRINKAGE_LIMIT = 20
 
93
# If we delete more than this many nodes applying a delta, we check for a remap
 
94
_INTERESTING_DELETES_LIMIT = 5
93
95
 
94
96
 
95
97
def _search_key_plain(key):
133
135
            into the map; if old_key is not None, then the old mapping
134
136
            of old_key is removed.
135
137
        """
136
 
        has_deletes = False
 
138
        delete_count = 0
137
139
        # Check preconditions first.
138
140
        as_st = StaticTuple.from_sequence
139
141
        new_items = set([as_st(key) for (old, key, value) in delta
146
148
        for old, new, value in delta:
147
149
            if old is not None and old != new:
148
150
                self.unmap(old, check_remap=False)
149
 
                has_deletes = True
 
151
                delete_count += 1
150
152
        for old, new, value in delta:
151
153
            if new is not None:
152
154
                self.map(new, value)
153
 
        if has_deletes:
 
155
        if delete_count > _INTERESTING_DELETES_LIMIT:
 
156
            trace.mutter("checking remap as %d deletions", delete_count)
154
157
            self._check_remap()
155
158
        return self._save()
156
159
 
570
573
        """Check if nodes can be collapsed."""
571
574
        self._ensure_root()
572
575
        if type(self._root_node) is InternalNode:
573
 
            self._root_node = self._root_node._check_remap(self._store)
 
576
            self._root_node._check_remap(self._store)
574
577
 
575
578
    def _save(self):
576
579
        """Save the map completely.
1369
1372
        return self._search_prefix
1370
1373
 
1371
1374
    def unmap(self, store, key, check_remap=True):
1372
 
        """Remove key from this node and its children."""
 
1375
        """Remove key from this node and it's children."""
1373
1376
        if not len(self._items):
1374
1377
            raise AssertionError("can't unmap in an empty InternalNode.")
1375
1378
        children = [node for node, _