Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

stable csinfo: fix cache mechanism

Changeset 6859796e3898

Parent 5df130f64aa0

by Yuki KODAMA

Changes to one file · Browse files at 6859796e3898 Showing diff from parent 5df130f64aa0 Diff from another changeset...

 
330
331
332
333
334
 
 
335
336
 
 
 
 
 
 
 
 
 
 
 
 
 
337
338
339
340
 
 
341
342
343
 
330
331
332
 
 
333
334
335
 
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
 
 
351
352
353
354
355
@@ -330,14 +330,26 @@
    def try_cache(self, target, func, *args):   item, widget, ctx, custom = args - ctxstr = ctx._repo.root + ctx.hex() - key = target + item + ctxstr + str(custom) + root = ctx._repo.root + repoid = id(ctx._repo)   try: - return self.cache[key] + cacheinfo = self.cache[root] + if cacheinfo[0] != repoid: + # clear cache + del self.cache[root] + cacheinfo = None + except KeyError: + cacheinfo = None + if cacheinfo is None: + cacheinfo = (repoid, {}) + self.cache[root] = cacheinfo + key = target + item + ctx.hex() + str(custom) + try: + return cacheinfo[1][key]   except KeyError:   pass - self.cache[key] = value = func(self, *args) - return value + cacheinfo[1][key] = func(self, *args) + return cacheinfo[1][key]     def get_data(self, *args):   return self.try_cache('data', SummaryInfo.get_data, *args)