~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-07 07:44:36 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090907074436-pede7phglz90jrvf
split developer docs into their own website/chm file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1045
1045
    def get_annotator(self):
1046
1046
        return _KnitAnnotator(self)
1047
1047
 
1048
 
    def check(self, progress_bar=None):
 
1048
    def check(self, progress_bar=None, keys=None):
1049
1049
        """See VersionedFiles.check()."""
 
1050
        if keys is None:
 
1051
            return self._logical_check()
 
1052
        else:
 
1053
            # At the moment, check does not extra work over get_record_stream
 
1054
            return self.get_record_stream(keys, 'unordered', True)
 
1055
 
 
1056
    def _logical_check(self):
1050
1057
        # This doesn't actually test extraction of everything, but that will
1051
1058
        # impact 'bzr check' substantially, and needs to be integrated with
1052
1059
        # care. However, it does check for the obvious problem of a delta with
1183
1190
        generator = _VFContentMapGenerator(self, [key])
1184
1191
        return generator._get_content(key)
1185
1192
 
 
1193
    def get_known_graph_ancestry(self, keys):
 
1194
        """Get a KnownGraph instance with the ancestry of keys."""
 
1195
        parent_map, missing_keys = self._index.find_ancestry(keys)
 
1196
        for fallback in self._fallback_vfs:
 
1197
            if not missing_keys:
 
1198
                break
 
1199
            (f_parent_map, f_missing_keys) = fallback._index.find_ancestry(
 
1200
                                                missing_keys)
 
1201
            parent_map.update(f_parent_map)
 
1202
            missing_keys = f_missing_keys
 
1203
        kg = _mod_graph.KnownGraph(parent_map)
 
1204
        return kg
 
1205
 
1186
1206
    def get_parent_map(self, keys):
1187
1207
        """Get a map of the graph parents of keys.
1188
1208
 
2553
2573
        except KeyError:
2554
2574
            raise RevisionNotPresent(key, self)
2555
2575
 
 
2576
    def find_ancestry(self, keys):
 
2577
        """See CombinedGraphIndex.find_ancestry()"""
 
2578
        prefixes = set(key[:-1] for key in keys)
 
2579
        self._load_prefixes(prefixes)
 
2580
        result = {}
 
2581
        parent_map = {}
 
2582
        missing_keys = set()
 
2583
        pending_keys = list(keys)
 
2584
        # This assumes that keys will not reference parents in a different
 
2585
        # prefix, which is accurate so far.
 
2586
        while pending_keys:
 
2587
            key = pending_keys.pop()
 
2588
            if key in parent_map:
 
2589
                continue
 
2590
            prefix = key[:-1]
 
2591
            try:
 
2592
                suffix_parents = self._kndx_cache[prefix][0][key[-1]][4]
 
2593
            except KeyError:
 
2594
                missing_keys.add(key)
 
2595
            else:
 
2596
                parent_keys = tuple([prefix + (suffix,)
 
2597
                                     for suffix in suffix_parents])
 
2598
                parent_map[key] = parent_keys
 
2599
                pending_keys.extend([p for p in parent_keys
 
2600
                                        if p not in parent_map])
 
2601
        return parent_map, missing_keys
 
2602
 
2556
2603
    def get_parent_map(self, keys):
2557
2604
        """Get a map of the parents of keys.
2558
2605
 
3042
3089
            options.append('no-eol')
3043
3090
        return options
3044
3091
 
 
3092
    def find_ancestry(self, keys):
 
3093
        """See CombinedGraphIndex.find_ancestry()"""
 
3094
        return self._graph_index.find_ancestry(keys, 0)
 
3095
 
3045
3096
    def get_parent_map(self, keys):
3046
3097
        """Get a map of the parents of keys.
3047
3098
 
3621
3672
                    to_process.extend(self._process_pending(key))
3622
3673
 
3623
3674
try:
3624
 
    from bzrlib._knit_load_data_c import _load_data_c as _load_data
 
3675
    from bzrlib._knit_load_data_pyx import _load_data_c as _load_data
3625
3676
except ImportError:
3626
3677
    from bzrlib._knit_load_data_py import _load_data_py as _load_data