/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/revisiontree.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-08 14:55:19 UTC
  • mfrom: (3530 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3532.
  • Revision ID: john@arbash-meinel.com-20080708145519-paqg4kjwbpgs2xmq
Merge bzr.dev 3530

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from cStringIO import StringIO
20
20
 
21
21
from bzrlib import (
 
22
    errors,
22
23
    osutils,
23
24
    revision,
24
25
    symbol_versioning,
39
40
        # construction - this will mean that we can change the constructor
40
41
        # with much less chance of breaking client code.
41
42
        self._repository = branch
42
 
        self._weave_store = branch.weave_store
43
43
        self._inventory = inv
44
44
        self._revision_id = revision_id
 
45
        self._rules_searcher = None
45
46
 
46
47
    def supports_tree_reference(self):
47
48
        return True
62
63
        """Return the revision id associated with this tree."""
63
64
        return self._revision_id
64
65
 
65
 
    @symbol_versioning.deprecated_method(symbol_versioning.zero_ninety)
66
 
    def get_weave(self, file_id):
67
 
        return self._get_weave(file_id)
68
 
 
69
 
    def _get_weave(self, file_id):
70
 
        return self._weave_store.get_weave(file_id,
71
 
                self._repository.get_transaction())
72
 
 
73
66
    def get_file_lines(self, file_id):
74
 
        ie = self._inventory[file_id]
75
 
        weave = self._get_weave(file_id)
76
 
        return weave.get_lines(ie.revision)
 
67
        return osutils.split_lines(self.get_file_text(file_id))
77
68
 
78
69
    def get_file_text(self, file_id):
79
 
        return ''.join(self.get_file_lines(file_id))
 
70
        return list(self.iter_files_bytes([(file_id, None)]))[0][1]
80
71
 
81
72
    def get_file(self, file_id, path=None):
82
73
        return StringIO(self.get_file_text(file_id))
83
74
 
84
75
    def iter_files_bytes(self, desired_files):
85
 
        """See Tree.extract_files_bytes.
 
76
        """See Tree.iter_files_bytes.
86
77
 
87
78
        This version is implemented on top of Repository.extract_files_bytes"""
88
79
        repo_desired_files = [(f, self.inventory[f].revision, i)
89
80
                              for f, i in desired_files]
90
 
        return self._repository.iter_files_bytes(repo_desired_files)
 
81
        try:
 
82
            for result in self._repository.iter_files_bytes(repo_desired_files):
 
83
                yield result
 
84
        except errors.RevisionNotPresent, e:
 
85
            raise errors.NoSuchFile(e.revision_id)
91
86
 
92
87
    def annotate_iter(self, file_id,
93
88
                      default_revision=revision.CURRENT_REVISION):
94
89
        """See Tree.annotate_iter"""
95
 
        w = self._get_weave(file_id)
96
 
        return w.annotate_iter(self.inventory[file_id].revision)
 
90
        text_key = (file_id, self.inventory[file_id].revision)
 
91
        annotations = self._repository.texts.annotate(text_key)
 
92
        return [(key[-1], line) for key, line in annotations]
97
93
 
98
94
    def get_file_size(self, file_id):
 
95
        """See Tree.get_file_size"""
99
96
        return self._inventory[file_id].text_size
100
97
 
101
98
    def get_file_sha1(self, file_id, path=None, stat_value=None):
162
159
        return entry.kind, entry.executable, None
163
160
 
164
161
    def _file_size(self, entry, stat_value):
165
 
        assert entry.text_size is not None
166
162
        return entry.text_size
167
163
 
168
164
    def _get_ancestors(self, default_revision):
207
203
            for dir in reversed(dirblock):
208
204
                if dir[2] == _directory:
209
205
                    pending.append(dir)
 
206
 
 
207
    def _get_rules_searcher(self, default_searcher):
 
208
        """See Tree._get_rules_searcher."""
 
209
        if self._rules_searcher is None:
 
210
            self._rules_searcher = super(RevisionTree,
 
211
                self)._get_rules_searcher(default_searcher)
 
212
        return self._rules_searcher