~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Aaron Bentley
  • Date: 2006-09-20 14:03:05 UTC
  • mto: This revision was merged to the branch mainline in revision 2162.
  • Revision ID: abentley@panoramicfeedback.com-20060920140305-7726fe3eb92690b1
Get tree._iter_changed down to ~ 1 stat per file

Show diffs side-by-side

added added

removed removed

Lines of Context:
562
562
        return os.path.getsize(self.id2abspath(file_id))
563
563
 
564
564
    @needs_read_lock
565
 
    def get_file_sha1(self, file_id, path=None):
 
565
    def get_file_sha1(self, file_id, path=None, stat_value=None):
566
566
        if not path:
567
567
            path = self._inventory.id2path(file_id)
568
 
        return self._hashcache.get_sha1(path)
 
568
        return self._hashcache.get_sha1(path, stat_value)
569
569
 
570
570
    def get_file_mtime(self, file_id, path=None):
571
571
        if not path:
1310
1310
    def kind(self, file_id):
1311
1311
        return file_kind(self.id2abspath(file_id))
1312
1312
 
 
1313
    def _comparison_data(self, entry, path):
 
1314
        abspath = self.abspath(path)
 
1315
        try:
 
1316
            stat_value = os.lstat(abspath)
 
1317
        except OSError, e:
 
1318
            if getattr(e, 'errno', None) == errno.ENOENT:
 
1319
                stat_value = None
 
1320
                kind = None
 
1321
                executable = False
 
1322
            else:
 
1323
                raise
 
1324
        else:
 
1325
            mode = stat_value.st_mode
 
1326
            kind = osutils.file_kind_from_stat_mode(mode)
 
1327
            if not supports_executable():
 
1328
                executable = entry.executable
 
1329
            else:
 
1330
                executable = bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
 
1331
        return kind, executable, stat_value
 
1332
 
 
1333
    def _file_size(self, entry, stat_value):
 
1334
        return stat_value.st_size
 
1335
 
1313
1336
    def last_revision(self):
1314
1337
        """Return the last revision of the branch for this tree.
1315
1338