~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/hashcache.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:
128
128
                self.needs_write = True
129
129
                del self._cache[path]
130
130
 
131
 
    def get_sha1(self, path):
 
131
    def get_sha1(self, path, stat_value=None):
132
132
        """Return the sha1 of a file.
133
133
        """
134
134
        abspath = pathjoin(self.root, path)
135
135
        self.stat_count += 1
136
 
        file_fp = self._fingerprint(abspath)
 
136
        file_fp = self._fingerprint(abspath, stat_value)
137
137
        
138
138
        if not file_fp:
139
139
            # not a regular file or not existing
277
277
        """
278
278
        return int(time.time()) - 3
279
279
           
280
 
    def _fingerprint(self, abspath):
281
 
        try:
282
 
            fs = os.lstat(abspath)
283
 
        except OSError:
284
 
            # might be missing, etc
285
 
            return None
 
280
    def _fingerprint(self, abspath, fs=None):
 
281
        if fs is None:
 
282
            try:
 
283
                fs = os.lstat(abspath)
 
284
            except OSError:
 
285
                # might be missing, etc
 
286
                return None
286
287
        if stat.S_ISDIR(fs.st_mode):
287
288
            return None
288
289
        # we discard any high precision because it's not reliable; perhaps we