~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/index.py

  • Committer: Ian Clatworthy
  • Date: 2007-12-17 01:45:32 UTC
  • mto: (3119.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3120.
  • Revision ID: ian.clatworthy@internode.on.net-20071217014532-dmbv2mm72nzq0ai6
follow-up tweaks to bzr.dev integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
from bzrlib.revision import NULL_REVISION
36
36
from bzrlib.trace import mutter
37
37
""")
38
 
from bzrlib import (
39
 
    debug,
40
 
    errors,
41
 
    symbol_versioning,
42
 
    )
 
38
from bzrlib import debug, errors
43
39
 
44
40
_HEADER_READV = (0, 200)
45
41
_OPTION_KEY_ELEMENTS = "key_elements="
999
995
                self.__class__.__name__,
1000
996
                ', '.join(map(repr, self._indices)))
1001
997
 
1002
 
    @symbol_versioning.deprecated_method(symbol_versioning.one_one)
1003
998
    def get_parents(self, revision_ids):
1004
 
        """See graph._StackedParentsProvider.get_parents.
 
999
        """See StackedParentsProvider.get_parents.
1005
1000
        
1006
1001
        This implementation thunks the graph.Graph.get_parents api across to
1007
1002
        GraphIndex.
1013
1008
             * (NULL_REVISION,) when the key has no parents.
1014
1009
             * (parent_key, parent_key...) otherwise.
1015
1010
        """
1016
 
        parent_map = self.get_parent_map(revision_ids)
1017
 
        return [parent_map.get(r, None) for r in revision_ids]
1018
 
 
1019
 
    def get_parent_map(self, keys):
1020
 
        """See graph._StackedParentsProvider.get_parent_map"""
1021
 
        search_keys = set(keys)
1022
 
        if NULL_REVISION in search_keys:
1023
 
            search_keys.discard(NULL_REVISION)
1024
 
            found_parents = {NULL_REVISION:[]}
1025
 
        else:
1026
 
            found_parents = {}
 
1011
        search_keys = set(revision_ids)
 
1012
        search_keys.discard(NULL_REVISION)
 
1013
        found_parents = {NULL_REVISION:[]}
1027
1014
        for index, key, value, refs in self.iter_entries(search_keys):
1028
1015
            parents = refs[0]
1029
1016
            if not parents:
1030
1017
                parents = (NULL_REVISION,)
1031
1018
            found_parents[key] = parents
1032
 
        return found_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
1033
1026
 
1034
1027
    def insert_index(self, pos, index):
1035
1028
        """Insert a new index in the list of indices to query.