~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Martin
  • Date: 2011-04-15 21:22:57 UTC
  • mto: This revision was merged to the branch mainline in revision 5797.
  • Revision ID: gzlist@googlemail.com-20110415212257-jgtovwwp4be7egd9
Add release notes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
2
 
#
3
 
# Authors:
4
 
#   Johan Rydberg <jrydberg@gnu.org>
 
1
# Copyright (C) 2006-2011 Canonical Ltd
5
2
#
6
3
# This program is free software; you can redistribute it and/or modify
7
4
# it under the terms of the GNU General Public License as published by
31
28
 
32
29
from bzrlib import (
33
30
    annotate,
 
31
    bencode,
34
32
    errors,
35
33
    graph as _mod_graph,
36
34
    groupcompress,
40
38
    multiparent,
41
39
    tsort,
42
40
    revision,
43
 
    ui,
44
41
    )
45
 
from bzrlib.graph import DictParentsProvider, Graph, StackedParentsProvider
46
 
from bzrlib.transport.memory import MemoryTransport
47
42
""")
48
43
from bzrlib.registry import Registry
49
44
from bzrlib.textmerge import TextMerge
50
 
from bzrlib import bencode
51
45
 
52
46
 
53
47
adapter_registry = Registry()
930
924
 
931
925
    The use of tuples allows a single code base to support several different
932
926
    uses with only the mapping logic changing from instance to instance.
 
927
 
 
928
    :ivar _immediate_fallback_vfs: For subclasses that support stacking,
 
929
        this is a list of other VersionedFiles immediately underneath this
 
930
        one.  They may in turn each have further fallbacks.
933
931
    """
934
932
 
935
933
    def add_lines(self, key, parents, lines, parent_texts=None,
1193
1191
    def _extract_blocks(self, version_id, source, target):
1194
1192
        return None
1195
1193
 
 
1194
    def _transitive_fallbacks(self):
 
1195
        """Return the whole stack of fallback versionedfiles.
 
1196
 
 
1197
        This VersionedFiles may have a list of fallbacks, but it doesn't
 
1198
        necessarily know about the whole stack going down, and it can't know
 
1199
        at open time because they may change after the objects are opened.
 
1200
        """
 
1201
        all_fallbacks = []
 
1202
        for a_vfs in self._immediate_fallback_vfs:
 
1203
            all_fallbacks.append(a_vfs)
 
1204
            all_fallbacks.extend(a_vfs._transitive_fallbacks())
 
1205
        return all_fallbacks
 
1206
 
1196
1207
 
1197
1208
class ThunkedVersionedFiles(VersionedFiles):
1198
1209
    """Storage for many versioned files thunked onto a 'VersionedFile' class.
1437
1448
        # line data for locally held keys.
1438
1449
        self._lines = {}
1439
1450
        # key lookup providers
1440
 
        self._providers = [DictParentsProvider(self._parents)]
 
1451
        self._providers = [_mod_graph.DictParentsProvider(self._parents)]
1441
1452
 
1442
1453
    def plan_merge(self, ver_a, ver_b, base=None):
1443
1454
        """See VersionedFile.plan_merge"""
1450
1461
 
1451
1462
    def plan_lca_merge(self, ver_a, ver_b, base=None):
1452
1463
        from bzrlib.merge import _PlanLCAMerge
1453
 
        graph = Graph(self)
 
1464
        graph = _mod_graph.Graph(self)
1454
1465
        new_plan = _PlanLCAMerge(ver_a, ver_b, self, (self._file_id,), graph).plan_merge()
1455
1466
        if base is None:
1456
1467
            return new_plan
1508
1519
            result[revision.NULL_REVISION] = ()
1509
1520
        self._providers = self._providers[:1] + self.fallback_versionedfiles
1510
1521
        result.update(
1511
 
            StackedParentsProvider(self._providers).get_parent_map(keys))
 
1522
            _mod_graph.StackedParentsProvider(
 
1523
                self._providers).get_parent_map(keys))
1512
1524
        for key, parents in result.iteritems():
1513
1525
            if parents == ():
1514
1526
                result[key] = (revision.NULL_REVISION,)