~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: mbp at sourcefrog
  • Date: 2005-04-11 02:44:45 UTC
  • Revision ID: mbp@sourcefrog.net-20050411024445-a2d4fa7e39309d2300533a6a
- Experiments in inventory performance

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
        fp = fingerprint_file(f)
79
79
        f.seek(0)
80
80
        
81
 
        if ie.text_size is not None:
 
81
        if ie.text_size != None:
82
82
            if ie.text_size != fp['size']:
83
83
                bailout("mismatched size for file %r in %r" % (ie.file_id, self._store),
84
84
                        ["inventory expects %d bytes" % ie.text_size,
92
92
                     "store is probably damaged/corrupt"])
93
93
 
94
94
 
95
 
    def export(self, dest):
 
95
    def print_file(self, fileid):
 
96
        """Print file with id `fileid` to stdout."""
 
97
        import sys
 
98
        pumpfile(self.get_file(fileid), sys.stdout)
 
99
        
 
100
        
 
101
    def export(self, dest):        
96
102
        """Export this tree to a new directory.
97
103
 
98
104
        `dest` should not exist, and will be created holding the
115
121
            elif kind == 'file':
116
122
                pumpfile(self.get_file(ie.file_id), file(fullpath, 'wb'))
117
123
            else:
118
 
                bailout("don't know how to export {%s} of kind %r", fid, kind)
 
124
                bailout("don't know how to export {%s} of kind %r" % (fid, kind))
119
125
            mutter("  export {%s} kind %s to %s" % (ie.file_id, kind, fullpath))
120
126
 
121
127
 
151
157
        return file(self.abspath(filename), 'rb')
152
158
 
153
159
    def _get_store_filename(self, file_id):
 
160
        ## XXX: badly named; this isn't in the store at all
154
161
        return self.abspath(self.id2path(file_id))
155
162
 
156
163
    def has_id(self, file_id):
188
195
        """
189
196
        inv = self.inventory
190
197
 
191
 
        def descend(from_dir, from_dir_id, dp):
 
198
        def descend(from_dir_relpath, from_dir_id, dp):
192
199
            ls = os.listdir(dp)
193
200
            ls.sort()
194
201
            for f in ls:
199
206
                    continue
200
207
 
201
208
                # path within tree
202
 
                fp = appendpath(from_dir, f)
 
209
                fp = appendpath(from_dir_relpath, f)
203
210
 
204
211
                # absolute path
205
212
                fap = appendpath(dp, f)
231
238
                for ff in descend(fp, f_ie.file_id, fap):
232
239
                    yield ff
233
240
 
234
 
        for f in descend('', None, self.basedir):
 
241
        for f in descend('', inv.root.file_id, self.basedir):
235
242
            yield f
236
243
            
237
244