~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Martin Pool
  • Date: 2005-07-07 10:22:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050707102201-2d2a13a25098b101
- rearrange and clear up merged weave

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
20
21
import os
21
22
 
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
27
25
 
 
26
import bzrlib
28
27
 
29
28
exporters = {}
30
29
 
67
66
 
68
67
    def _get_inventory(self):
69
68
        return self._inventory
70
 
    
71
 
    def get_file_by_path(self, path):
72
 
        return self.get_file(self._inventory.path2id(path))
73
69
 
74
70
    inventory = property(_get_inventory,
75
71
                         doc="Inventory of this Tree")
135
131
 
136
132
    def get_file_sha1(self, file_id):
137
133
        ie = self._inventory[file_id]
138
 
        if ie.kind == "file":
139
 
            return ie.text_sha1
 
134
        return ie.text_sha1
140
135
 
141
136
    def has_filename(self, filename):
142
137
        return bool(self.inventory.path2id(filename))
149
144
 
150
145
class EmptyTree(Tree):
151
146
    def __init__(self):
 
147
        from bzrlib.inventory import Inventory
152
148
        self._inventory = Inventory()
153
149
 
154
150
    def has_filename(self, filename):
158
154
        if False:  # just to make it a generator
159
155
            yield None
160
156
    
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
 
 
169
157
 
170
158
 
171
159
######################################################################