~larstiq/bzr/bzr.lq

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-19 00:05:50 UTC
  • mfrom: (1769.2.22 +trunk)
  • Revision ID: larstiq@larstiq.dyndns.org-20060619000550-f65dc3f619342755
[merge] bzr.dev 1791

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from cStringIO import StringIO
22
22
 
23
23
import bzrlib
24
 
from bzrlib.trace import mutter, note
25
24
from bzrlib.errors import BzrError, BzrCheckError
26
25
from bzrlib.inventory import Inventory
27
26
from bzrlib.osutils import fingerprint_file
 
27
import bzrlib.revision
 
28
from bzrlib.trace import mutter, note
28
29
 
29
30
class Tree(object):
30
31
    """Abstract file tree.
48
49
    trees or versioned trees.
49
50
    """
50
51
    
 
52
    def conflicts(self):
 
53
        """Get a list of the conflicts in the tree.
 
54
 
 
55
        Each conflict is an instance of bzrlib.conflicts.Conflict.
 
56
        """
 
57
        return []
 
58
 
 
59
    def get_parent_ids(self):
 
60
        """Get the parent ids for this tree. 
 
61
 
 
62
        :return: a list of parent ids. [] is returned to indicate
 
63
        a tree with no parents.
 
64
        :raises: BzrError if the parents are not known.
 
65
        """
 
66
        raise NotImplementedError(self.get_parent_ids)
 
67
    
51
68
    def has_filename(self, filename):
52
69
        """True if the tree has given filename."""
53
70
        raise NotImplementedError()
108
125
    def lock_read(self):
109
126
        pass
110
127
 
 
128
    def unknowns(self):
 
129
        """What files are present in this tree and unknown.
 
130
        
 
131
        :return: an iterator over the unknown files.
 
132
        """
 
133
        return iter([])
 
134
 
111
135
    def unlock(self):
112
136
        pass
113
137
 
134
158
    """
135
159
    
136
160
    def __init__(self, branch, inv, revision_id):
137
 
        self._branch = branch
 
161
        # for compatability the 'branch' parameter has not been renamed to 
 
162
        # repository at this point. However, we should change RevisionTree's
 
163
        # construction to always be via Repository and not via direct 
 
164
        # construction - this will mean that we can change the constructor
 
165
        # with much less chance of breaking client code.
 
166
        self._repository = branch
138
167
        self._weave_store = branch.weave_store
139
168
        self._inventory = inv
140
169
        self._revision_id = revision_id
141
170
 
 
171
    def get_parent_ids(self):
 
172
        """See Tree.get_parent_ids.
 
173
 
 
174
        A RevisionTree's parents match the revision graph.
 
175
        """
 
176
        parent_ids = self._repository.get_revision(self._revision_id).parent_ids
 
177
        return parent_ids
 
178
        
142
179
    def get_revision_id(self):
143
180
        """Return the revision id associated with this tree."""
144
181
        return self._revision_id
145
182
 
146
183
    def get_weave(self, file_id):
147
184
        return self._weave_store.get_weave(file_id,
148
 
                self._branch.get_transaction())
 
185
                self._repository.get_transaction())
149
186
 
150
187
    def get_file_lines(self, file_id):
151
188
        ie = self._inventory[file_id]
169
206
 
170
207
    def get_file_mtime(self, file_id, path=None):
171
208
        ie = self._inventory[file_id]
172
 
        revision = self._branch.get_revision(ie.revision)
 
209
        revision = self._repository.get_revision(ie.revision)
173
210
        return revision.timestamp
174
211
 
175
212
    def is_executable(self, file_id, path=None):
194
231
        return self._inventory[file_id].kind
195
232
 
196
233
    def lock_read(self):
197
 
        self._branch.lock_read()
 
234
        self._repository.lock_read()
198
235
 
199
236
    def unlock(self):
200
 
        self._branch.unlock()
 
237
        self._repository.unlock()
201
238
 
202
239
 
203
240
class EmptyTree(Tree):
 
241
 
204
242
    def __init__(self):
205
243
        self._inventory = Inventory()
206
244
 
 
245
    def get_parent_ids(self):
 
246
        """See Tree.get_parent_ids.
 
247
 
 
248
        An EmptyTree always has NULL_REVISION as the only parent.
 
249
        """
 
250
        return []
 
251
 
207
252
    def get_symlink_target(self, file_id):
208
253
        return None
209
254