/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/repofmt/pack_repo.py

  • Committer: Andrew Bennetts
  • Date: 2009-08-07 05:56:29 UTC
  • mfrom: (4595 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4608.
  • Revision ID: andrew.bennetts@canonical.com-20090807055629-wkgbne6gf7t284ai
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2223
2223
        self.revisions._index._key_dependencies.refs.clear()
2224
2224
        self._pack_collection._abort_write_group()
2225
2225
 
2226
 
    def _find_inconsistent_revision_parents(self):
2227
 
        """Find revisions with incorrectly cached parents.
2228
 
 
2229
 
        :returns: an iterator yielding tuples of (revison-id, parents-in-index,
2230
 
            parents-in-revision).
2231
 
        """
2232
 
        if not self.is_locked():
2233
 
            raise errors.ObjectNotLocked(self)
2234
 
        pb = ui.ui_factory.nested_progress_bar()
2235
 
        result = []
2236
 
        try:
2237
 
            revision_nodes = self._pack_collection.revision_index \
2238
 
                .combined_index.iter_all_entries()
2239
 
            index_positions = []
2240
 
            # Get the cached index values for all revisions, and also the
2241
 
            # location in each index of the revision text so we can perform
2242
 
            # linear IO.
2243
 
            for index, key, value, refs in revision_nodes:
2244
 
                node = (index, key, value, refs)
2245
 
                index_memo = self.revisions._index._node_to_position(node)
2246
 
                if index_memo[0] != index:
2247
 
                    raise AssertionError('%r != %r' % (index_memo[0], index))
2248
 
                index_positions.append((index_memo, key[0],
2249
 
                                       tuple(parent[0] for parent in refs[0])))
2250
 
                pb.update("Reading revision index", 0, 0)
2251
 
            index_positions.sort()
2252
 
            batch_size = 1000
2253
 
            pb.update("Checking cached revision graph", 0,
2254
 
                      len(index_positions))
2255
 
            for offset in xrange(0, len(index_positions), 1000):
2256
 
                pb.update("Checking cached revision graph", offset)
2257
 
                to_query = index_positions[offset:offset + batch_size]
2258
 
                if not to_query:
2259
 
                    break
2260
 
                rev_ids = [item[1] for item in to_query]
2261
 
                revs = self.get_revisions(rev_ids)
2262
 
                for revision, item in zip(revs, to_query):
2263
 
                    index_parents = item[2]
2264
 
                    rev_parents = tuple(revision.parent_ids)
2265
 
                    if index_parents != rev_parents:
2266
 
                        result.append((revision.revision_id, index_parents,
2267
 
                                       rev_parents))
2268
 
        finally:
2269
 
            pb.finished()
2270
 
        return result
2271
 
 
2272
2226
    def _get_source(self, to_format):
2273
2227
        if to_format.network_name() == self._format.network_name():
2274
2228
            return KnitPackStreamSource(self, to_format)