~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 04:25:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5472.
  • Revision ID: andrew.bennetts@canonical.com-20101008042510-sg9vdhmnggilzxsk
Fix stray TAB in source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2011 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 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
23
23
except ImportError:
24
24
    pylzma = None
25
25
 
26
 
from bzrlib.lazy_import import lazy_import
27
 
lazy_import(globals(), """
28
26
from bzrlib import (
29
27
    annotate,
30
28
    debug,
31
29
    errors,
32
30
    graph as _mod_graph,
 
31
    knit,
33
32
    osutils,
34
33
    pack,
35
34
    static_tuple,
36
35
    trace,
37
 
    tsort,
38
36
    )
39
 
 
40
 
from bzrlib.repofmt import pack_repo
41
 
""")
42
 
 
43
37
from bzrlib.btree_index import BTreeBuilder
44
38
from bzrlib.lru_cache import LRUSizeCache
 
39
from bzrlib.tsort import topo_sort
45
40
from bzrlib.versionedfile import (
46
 
    _KeyRefs,
47
41
    adapter_registry,
48
42
    AbsentContentFactory,
49
43
    ChunkedContentFactory,
83
77
 
84
78
    present_keys = []
85
79
    for prefix in sorted(per_prefix_map):
86
 
        present_keys.extend(reversed(tsort.topo_sort(per_prefix_map[prefix])))
 
80
        present_keys.extend(reversed(topo_sort(per_prefix_map[prefix])))
87
81
    return present_keys
88
82
 
89
83
 
1052
1046
        index = _GCGraphIndex(graph_index, lambda:True, parents=parents,
1053
1047
            add_callback=graph_index.add_nodes,
1054
1048
            inconsistency_fatal=inconsistency_fatal)
1055
 
        access = pack_repo._DirectPackAccess({})
 
1049
        access = knit._DirectPackAccess({})
1056
1050
        access.set_writer(writer, graph_index, (transport, 'newpack'))
1057
1051
        result = GroupCompressVersionedFiles(index, access, delta)
1058
1052
        result.stream = stream
1192
1186
            _unadded_refs = {}
1193
1187
        self._unadded_refs = _unadded_refs
1194
1188
        self._group_cache = LRUSizeCache(max_size=50*1024*1024)
1195
 
        self._immediate_fallback_vfs = []
 
1189
        self._fallback_vfs = []
1196
1190
 
1197
1191
    def without_fallbacks(self):
1198
1192
        """Return a clone of this object without any fallbacks configured."""
1272
1266
 
1273
1267
        :param a_versioned_files: A VersionedFiles object.
1274
1268
        """
1275
 
        self._immediate_fallback_vfs.append(a_versioned_files)
 
1269
        self._fallback_vfs.append(a_versioned_files)
1276
1270
 
1277
1271
    def annotate(self, key):
1278
1272
        """See VersionedFiles.annotate."""
1318
1312
        # KnitVersionedFiles.get_known_graph_ancestry, but they don't share
1319
1313
        # ancestry.
1320
1314
        parent_map, missing_keys = self._index.find_ancestry(keys)
1321
 
        for fallback in self._transitive_fallbacks():
 
1315
        for fallback in self._fallback_vfs:
1322
1316
            if not missing_keys:
1323
1317
                break
1324
1318
            (f_parent_map, f_missing_keys) = fallback._index.find_ancestry(
1348
1342
            and so on.
1349
1343
        """
1350
1344
        result = {}
1351
 
        sources = [self._index] + self._immediate_fallback_vfs
 
1345
        sources = [self._index] + self._fallback_vfs
1352
1346
        source_results = []
1353
1347
        missing = set(keys)
1354
1348
        for source in sources:
1455
1449
        parent_map = {}
1456
1450
        key_to_source_map = {}
1457
1451
        source_results = []
1458
 
        for source in self._immediate_fallback_vfs:
 
1452
        for source in self._fallback_vfs:
1459
1453
            if not missing:
1460
1454
                break
1461
1455
            source_parents = source.get_parent_map(missing)
1476
1470
            the defined order, regardless of source.
1477
1471
        """
1478
1472
        if ordering == 'topological':
1479
 
            present_keys = tsort.topo_sort(parent_map)
 
1473
            present_keys = topo_sort(parent_map)
1480
1474
        else:
1481
1475
            # ordering == 'groupcompress'
1482
1476
            # XXX: This only optimizes for the target ordering. We may need
1838
1832
        """See VersionedFiles.keys."""
1839
1833
        if 'evil' in debug.debug_flags:
1840
1834
            trace.mutter_callsite(2, "keys scales with size of history")
1841
 
        sources = [self._index] + self._immediate_fallback_vfs
 
1835
        sources = [self._index] + self._fallback_vfs
1842
1836
        result = set()
1843
1837
        for source in sources:
1844
1838
            result.update(source.keys())
1927
1921
        # repeated over and over, this creates a surplus of ints
1928
1922
        self._int_cache = {}
1929
1923
        if track_external_parent_refs:
1930
 
            self._key_dependencies = _KeyRefs(
 
1924
            self._key_dependencies = knit._KeyRefs(
1931
1925
                track_new_keys=track_new_keys)
1932
1926
        else:
1933
1927
            self._key_dependencies = None