~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

- merge improved merge base selection from aaron
aaron.bentley@utoronto.ca-20050912025534-43d7275dd948e4ad

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tree classes, representing directory at point in time.
18
18
"""
19
19
 
20
 
from osutils import pumpfile, appendpath, fingerprint_file
21
20
import os
22
21
 
 
22
import bzrlib
23
23
from bzrlib.trace import mutter, note
24
24
from bzrlib.errors import BzrError
 
25
from bzrlib.inventory import Inventory
 
26
from bzrlib.osutils import pumpfile, appendpath, fingerprint_file
25
27
 
26
 
import bzrlib
27
28
 
28
29
exporters = {}
29
30
 
66
67
 
67
68
    def _get_inventory(self):
68
69
        return self._inventory
 
70
    
 
71
    def get_file_by_path(self, path):
 
72
        return self.get_file(self._inventory.path2id(path))
69
73
 
70
74
    inventory = property(_get_inventory,
71
75
                         doc="Inventory of this Tree")
131
135
 
132
136
    def get_file_sha1(self, file_id):
133
137
        ie = self._inventory[file_id]
134
 
        return ie.text_sha1
 
138
        if ie.kind == "file":
 
139
            return ie.text_sha1
135
140
 
136
141
    def has_filename(self, filename):
137
142
        return bool(self.inventory.path2id(filename))
143
148
 
144
149
 
145
150
class EmptyTree(Tree):
146
 
    def __init__(self, root_id):
147
 
        from bzrlib.inventory import Inventory
148
 
        self._inventory = Inventory(root_id)
 
151
    def __init__(self):
 
152
        self._inventory = Inventory()
149
153
 
150
154
    def has_filename(self, filename):
151
155
        return False
154
158
        if False:  # just to make it a generator
155
159
            yield None
156
160
    
 
161
    def __contains__(self, file_id):
 
162
        return file_id in self._inventory
 
163
 
 
164
    def get_file_sha1(self, file_id):
 
165
        assert self._inventory[file_id].kind == "root_directory"
 
166
        return None
 
167
 
 
168
 
157
169
 
158
170
 
159
171
######################################################################