~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

Significant steps back to operation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
282
282
        return state._get_entry(0, fileid_utf8=file_id, path_utf8=path)
283
283
 
284
284
    def get_file_sha1(self, file_id, path=None, stat_value=None):
285
 
        #if not path:
286
 
        #    path = self.inventory.id2path(file_id)
287
 
        #    # now lookup row by path
288
 
        row, parents = self._get_row(file_id=file_id, path=path)
289
 
        assert row is not None, 'what error should this raise'
 
285
        # check file id is valid unconditionally.
 
286
        entry, parents = self._get_entry(file_id=file_id, path=path)
 
287
        assert entry is not None, 'what error should this raise'
290
288
        # TODO:
291
289
        # if row stat is valid, use cached sha1, else, get a new sha1.
292
290
        if path is None:
293
 
            path = (row[0] + '/' + row[1]).strip('/').decode('utf8')
 
291
            path = os.path.join(entry[0][0:2]).decode('utf8')
294
292
        return self._hashcache.get_sha1(path, stat_value)
295
293
 
296
294
    def _get_inventory(self):
329
327
    def id2path(self, fileid):
330
328
        state = self.current_dirstate()
331
329
        fileid_utf8 = fileid.encode('utf8')
332
 
        for row, parents in state._iter_rows():
333
 
            if row[3] == fileid_utf8:
334
 
                return (row[0] + '/' + row[1]).decode('utf8').strip('/')
 
330
        key, tree_details = state._get_entry(0, fileid_utf8=fileid_utf8)
 
331
        return os.path.join(*key[0:2]).decode('utf8')
335
332
 
336
333
    @needs_read_lock
337
334
    def __iter__(self):
341
338
        and the working file exists.
342
339
        """
343
340
        result = []
344
 
        for row, parents in self.current_dirstate()._iter_rows():
345
 
            if row[0] == '/':
 
341
        for key, tree_details in self.current_dirstate()._iter_entries():
 
342
            if tree_details[0][0] in ('absent', 'relocated'):
 
343
                # not relevant to the working tree
346
344
                continue
347
 
            path = pathjoin(self.basedir, row[0].decode('utf8'), row[1].decode('utf8'))
 
345
            path = pathjoin(self.basedir, key[0].decode('utf8'), key[1].decode('utf8'))
348
346
            if osutils.lexists(path):
349
 
                result.append(row[3].decode('utf8'))
 
347
                result.append(key[2].decode('utf8'))
350
348
        return iter(result)
351
349
 
352
350
    @needs_read_lock
522
520
    @needs_read_lock
523
521
    def path2id(self, path):
524
522
        """Return the id for path in this tree."""
525
 
        state = self.current_dirstate()
526
 
        row = self._get_row(path=path)
527
 
        if row == (None, None):
 
523
        entry = self._get_entry(path=path)
 
524
        if entry == (None, None):
528
525
            return None
529
 
        return row[0][3].decode('utf8')
 
526
        return entry[0][2].decode('utf8')
530
527
 
531
528
    def read_working_inventory(self):
532
529
        """Read the working inventory.