~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/statcache.py

  • Committer: Martin Pool
  • Date: 2005-05-11 02:37:07 UTC
  • Revision ID: mbp@sourcefrog.net-20050511023707-3d9437714db27504
- more trace and profiling in statcache

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
 
165
165
    from sets import Set
166
166
 
167
 
    hardcheck = dirty = 0
 
167
    stat_cnt = missing_cnt = hardcheck = change_cnt = 0
168
168
 
169
169
    # files that have been recently touched and can't be
170
170
    # committed to a persistent cache yet.
171
171
    
172
172
    dangerfiles = Set()
173
173
    now = int(time.time())
174
 
    
 
174
 
 
175
    mutter('update statcache under %r' % basedir)
175
176
    for file_id, path in to_update:
176
 
        fap = os.path.join(basedir, path)
177
 
        fp = fingerprint(fap, path)
 
177
        abspath = os.path.join(basedir, path)
 
178
        fp = fingerprint(abspath, path)
 
179
        stat_cnt += 1
 
180
        
178
181
        cacheentry = cache.get(file_id)
179
182
 
180
183
        if fp == None: # not here
181
184
            if cacheentry:
182
185
                del cache[file_id]
183
 
                dirty += 1
 
186
                change_cnt += 1
 
187
            missing_cnt += 1
184
188
            continue
185
189
 
186
190
        if (fp[FP_MTIME] >= now) or (fp[FP_CTIME] >= now):
191
195
 
192
196
        hardcheck += 1
193
197
 
194
 
        dig = sha.new(file(fap, 'rb').read()).hexdigest()
 
198
        dig = sha.new(file(abspath, 'rb').read()).hexdigest()
195
199
 
196
200
        if cacheentry == None or dig != cacheentry[1]: 
197
201
            # if there was no previous entry for this file, or if the
198
202
            # SHA has changed, then update the cache
199
203
            cacheentry = (file_id, dig, path) + fp
200
204
            cache[file_id] = cacheentry
201
 
            dirty += 1
 
205
            change_cnt += 1
202
206
 
203
 
    mutter('statcache: read %d files, %d changed, %d dangerous, '
 
207
    mutter('statcache: statted %d files, read %d files, %d changed, %d dangerous, '
204
208
           '%d in cache'
205
 
           % (hardcheck, dirty, len(dangerfiles), len(cache)))
 
209
           % (stat_cnt, hardcheck, change_cnt, len(dangerfiles), len(cache)))
206
210
        
207
 
    if dirty:
 
211
    if change_cnt:
208
212
        mutter('updating on-disk statcache')
209
213
        _write_cache(basedir, cache.itervalues(), dangerfiles)
210
214