~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/index.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-28 00:59:30 UTC
  • mfrom: (2979.2.5 commit.merge-speed)
  • Revision ID: pqm@pqm.ubuntu.com-20071128005930-4wb5pl12fyq8ek13
(robertc) Change commit on pack repositories to use the per-file
        graph for heads() calculations. (Robert Collins, 165306)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
lazy_import(globals(), """
33
33
from bzrlib import trace
34
34
from bzrlib.bisect_multi import bisect_multi_bytes
 
35
from bzrlib.revision import NULL_REVISION
35
36
from bzrlib.trace import mutter
36
37
""")
37
38
from bzrlib import debug, errors
994
995
                self.__class__.__name__,
995
996
                ', '.join(map(repr, self._indices)))
996
997
 
 
998
    def get_parents(self, revision_ids):
 
999
        """See StackedParentsProvider.get_parents.
 
1000
        
 
1001
        This implementation thunks the graph.Graph.get_parents api across to
 
1002
        GraphIndex.
 
1003
 
 
1004
        :param revision_ids: An iterable of graph keys for this graph.
 
1005
        :return: A list of parent details for each key in revision_ids.
 
1006
            Each parent details will be one of:
 
1007
             * None when the key was missing
 
1008
             * (NULL_REVISION,) when the key has no parents.
 
1009
             * (parent_key, parent_key...) otherwise.
 
1010
        """
 
1011
        search_keys = set(revision_ids)
 
1012
        search_keys.discard(NULL_REVISION)
 
1013
        found_parents = {NULL_REVISION:[]}
 
1014
        for index, key, value, refs in self.iter_entries(search_keys):
 
1015
            parents = refs[0]
 
1016
            if not parents:
 
1017
                parents = (NULL_REVISION,)
 
1018
            found_parents[key] = parents
 
1019
        result = []
 
1020
        for key in revision_ids:
 
1021
            try:
 
1022
                result.append(found_parents[key])
 
1023
            except KeyError:
 
1024
                result.append(None)
 
1025
        return result
 
1026
 
997
1027
    def insert_index(self, pos, index):
998
1028
        """Insert a new index in the list of indices to query.
999
1029
 
1128
1158
        """Iterate over keys within the index.
1129
1159
 
1130
1160
        :param keys: An iterable providing the keys to be retrieved.
1131
 
        :return: An iterable of (index, key, reference_lists, value). There is no
 
1161
        :return: An iterable of (index, key, value, reference_lists). There is no
1132
1162
            defined order for the result iteration - it will be in the most
1133
1163
            efficient order for the index (keys iteration order in this case).
1134
1164
        """
1312
1342
        """Iterate over keys within the index.
1313
1343
 
1314
1344
        :param keys: An iterable providing the keys to be retrieved.
1315
 
        :return: An iterable of (key, reference_lists, value). There is no
 
1345
        :return: An iterable of (index, key, value, reference_lists). There is no
1316
1346
            defined order for the result iteration - it will be in the most
1317
1347
            efficient order for the index (keys iteration order in this case).
1318
1348
        """