~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/chk_map.py

  • Committer: Parth Malwankar
  • Date: 2010-06-30 12:03:30 UTC
  • mto: This revision was merged to the branch mainline in revision 5339.
  • Revision ID: parth.malwankar@gmail.com-20100630120330-uud7s38i8s08izh8
added InvalidPattern error.
This is raised by lazy_regex and Globster on bad regex.

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.