~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-19 18:04:49 UTC
  • mfrom: (4593.5.43 1.19-known-graph-sorted)
  • Revision ID: pqm@pqm.ubuntu.com-20090819180449-p5dibldf9pcp24n4
(jam) Add VersionedFiles.get_known_graph_ancestry and
        KnownGraph.merge_sort()

Show diffs side-by-side

added added

removed removed

Lines of Context:
1190
1190
        generator = _VFContentMapGenerator(self, [key])
1191
1191
        return generator._get_content(key)
1192
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
        kg = _mod_graph.KnownGraph(parent_map)
 
1197
        return kg
 
1198
 
1193
1199
    def get_parent_map(self, keys):
1194
1200
        """Get a map of the graph parents of keys.
1195
1201
 
2560
2566
        except KeyError:
2561
2567
            raise RevisionNotPresent(key, self)
2562
2568
 
 
2569
    def find_ancestry(self, keys):
 
2570
        """See CombinedGraphIndex.find_ancestry()"""
 
2571
        prefixes = set(key[:-1] for key in keys)
 
2572
        self._load_prefixes(prefixes)
 
2573
        result = {}
 
2574
        parent_map = {}
 
2575
        missing_keys = set()
 
2576
        pending_keys = list(keys)
 
2577
        # This assumes that keys will not reference parents in a different
 
2578
        # prefix, which is accurate so far.
 
2579
        while pending_keys:
 
2580
            key = pending_keys.pop()
 
2581
            if key in parent_map:
 
2582
                continue
 
2583
            prefix = key[:-1]
 
2584
            try:
 
2585
                suffix_parents = self._kndx_cache[prefix][0][key[-1]][4]
 
2586
            except KeyError:
 
2587
                missing_keys.add(key)
 
2588
            else:
 
2589
                parent_keys = tuple([prefix + (suffix,)
 
2590
                                     for suffix in suffix_parents])
 
2591
                parent_map[key] = parent_keys
 
2592
                pending_keys.extend([p for p in parent_keys
 
2593
                                        if p not in parent_map])
 
2594
        return parent_map, missing_keys
 
2595
 
2563
2596
    def get_parent_map(self, keys):
2564
2597
        """Get a map of the parents of keys.
2565
2598
 
3049
3082
            options.append('no-eol')
3050
3083
        return options
3051
3084
 
 
3085
    def find_ancestry(self, keys):
 
3086
        """See CombinedGraphIndex.find_ancestry()"""
 
3087
        return self._graph_index.find_ancestry(keys, 0)
 
3088
 
3052
3089
    def get_parent_map(self, keys):
3053
3090
        """Get a map of the parents of keys.
3054
3091