Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.3, 2.0.4, and 2.0.5

stable patchctx: compare mtime and file size when evaluating cached ctx (fixes #295)

Changeset 53ca55f9aa39

Parent 5c2699401a8e

by Steve Borho

Changes to 2 files · Browse files at 53ca55f9aa39 Showing diff from parent 5c2699401a8e Diff from another changeset...

 
575
576
577
578
579
580
581
 
 
 
 
 
 
 
 
582
583
584
 
575
576
577
 
 
 
 
578
579
580
581
582
583
584
585
586
587
588
@@ -575,10 +575,14 @@
 _pctxcache = {}  def genPatchContext(repo, patchpath, rev=None):   global _pctxcache - if os.path.exists(patchpath) and patchpath in _pctxcache: - cachedctx = _pctxcache[patchpath] - if cachedctx._mtime == os.path.getmtime(patchpath): - return cachedctx + try: + if os.path.exists(patchpath) and patchpath in _pctxcache: + cachedctx = _pctxcache[patchpath] + if cachedctx._mtime == os.path.getmtime(patchpath) and \ + cachedctx._fsize == os.path.getsize(patchpath): + return cachedctx + except EnvironmentError: + pass   # create a new context object   ctx = patchctx(patchpath, repo, rev=rev)   _pctxcache[patchpath] = ctx
 
41
42
43
 
44
45
46
 
 
47
48
49
50
51
52
 
41
42
43
44
45
46
47
48
49
50
51
 
52
53
54
@@ -41,12 +41,14 @@
  self._node = node.nullid   self._identity = node.nullid   self._mtime = None + self._fsize = 0   self._parseerror = None     try: + self._mtime = os.path.getmtime(patchpath) + self._fsize = os.path.getsize(patchpath)   ph = mq.patchheader(self._path)   self._ph = ph - self._mtime = os.path.getmtime(patchpath)   hash = util.sha1(self._path)   hash.update(str(self._mtime))   self._identity = hash.digest()