~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/hashcache.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-02 04:45:19 UTC
  • mfrom: (2012.1.18 tree-compare)
  • Revision ID: pqm@pqm.ubuntu.com-20061202044519-b51893edd371d01d
New low-level interface for determining differences between trees

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
286
 
        if stat.S_ISDIR(fs.st_mode):
 
280
    def _fingerprint(self, abspath, stat_value=None):
 
281
        if stat_value is None:
 
282
            try:
 
283
                stat_value = os.lstat(abspath)
 
284
            except OSError:
 
285
                # might be missing, etc
 
286
                return None
 
287
        if stat.S_ISDIR(stat_value.st_mode):
287
288
            return None
288
289
        # we discard any high precision because it's not reliable; perhaps we
289
290
        # could do better on some systems?
290
 
        return (fs.st_size, long(fs.st_mtime),
291
 
                long(fs.st_ctime), fs.st_ino, fs.st_dev, fs.st_mode)
 
291
        return (stat_value.st_size, long(stat_value.st_mtime),
 
292
                long(stat_value.st_ctime), stat_value.st_ino, 
 
293
                stat_value.st_dev, stat_value.st_mode)