~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/index.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-19 10:42:59 UTC
  • mto: This revision was merged to the branch mainline in revision 5806.
  • Revision ID: jelmer@samba.org-20110419104259-g9exlcp1f5jdu3ci
Move Inventory._get_mutable_inventory -> mutable_inventory_from_tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
31
31
 
32
32
from bzrlib.lazy_import import lazy_import
33
33
lazy_import(globals(), """
34
 
from bzrlib import trace
35
 
from bzrlib.bisect_multi import bisect_multi_bytes
36
 
from bzrlib.revision import NULL_REVISION
37
 
from bzrlib.trace import mutter
 
34
from bzrlib import (
 
35
    bisect_multi,
 
36
    revision as _mod_revision,
 
37
    trace,
 
38
    )
38
39
""")
39
40
from bzrlib import (
40
41
    debug,
444
445
            # We already did this
445
446
            return
446
447
        if 'index' in debug.debug_flags:
447
 
            mutter('Reading entire index %s', self._transport.abspath(self._name))
 
448
            trace.mutter('Reading entire index %s',
 
449
                          self._transport.abspath(self._name))
448
450
        if stream is None:
449
451
            stream = self._transport.get(self._name)
450
452
            if self._base_offset != 0:
462
464
        trailers = 0
463
465
        pos = stream.tell()
464
466
        lines = stream.read().split('\n')
 
467
        # GZ 2009-09-20: Should really use a try/finally block to ensure close
465
468
        stream.close()
466
469
        del lines[-1]
467
470
        _, _, _, trailers = self._parse_lines(lines, pos)
670
673
        if self._nodes is not None:
671
674
            return self._iter_entries_from_total_buffer(keys)
672
675
        else:
673
 
            return (result[1] for result in bisect_multi_bytes(
 
676
            return (result[1] for result in bisect_multi.bisect_multi_bytes(
674
677
                self._lookup_keys_via_location, self._size, keys))
675
678
 
676
679
    def iter_entries_prefix(self, keys):
1287
1290
    def get_parent_map(self, keys):
1288
1291
        """See graph.StackedParentsProvider.get_parent_map"""
1289
1292
        search_keys = set(keys)
1290
 
        if NULL_REVISION in search_keys:
1291
 
            search_keys.discard(NULL_REVISION)
1292
 
            found_parents = {NULL_REVISION:[]}
 
1293
        if _mod_revision.NULL_REVISION in search_keys:
 
1294
            search_keys.discard(_mod_revision.NULL_REVISION)
 
1295
            found_parents = {_mod_revision.NULL_REVISION:[]}
1293
1296
        else:
1294
1297
            found_parents = {}
1295
1298
        for index, key, value, refs in self.iter_entries(search_keys):
1296
1299
            parents = refs[0]
1297
1300
            if not parents:
1298
 
                parents = (NULL_REVISION,)
 
1301
                parents = (_mod_revision.NULL_REVISION,)
1299
1302
            found_parents[key] = parents
1300
1303
        return found_parents
1301
1304
 
1433
1436
        """
1434
1437
        indices_info = zip(self._index_names, self._indices)
1435
1438
        if 'index' in debug.debug_flags:
1436
 
            mutter('CombinedGraphIndex reordering: currently %r, promoting %r',
1437
 
                   indices_info, hit_indices)
 
1439
            trace.mutter('CombinedGraphIndex reordering: currently %r, '
 
1440
                         'promoting %r', indices_info, hit_indices)
1438
1441
        hit_names = []
1439
1442
        unhit_names = []
1440
1443
        new_hit_indices = []
1457
1460
        self._indices = new_hit_indices + unhit_indices
1458
1461
        self._index_names = hit_names + unhit_names
1459
1462
        if 'index' in debug.debug_flags:
1460
 
            mutter('CombinedGraphIndex reordered: %r', self._indices)
 
1463
            trace.mutter('CombinedGraphIndex reordered: %r', self._indices)
1461
1464
        return hit_names
1462
1465
 
1463
1466
    def _move_to_front_by_name(self, hit_names):