repoview: ignore unwritable hidden cache stable
authorMatt Mackall <mpm@selenic.com>
Thu, 28 Apr 2016 16:26:18 -0500
branchstable
changeset 31393 a4dc5fe7bf54c339e1c23ff22cf061ad104a1701
parent 31392 e3055b46ed1b927f11cf3d74acb83b04b304e657
child 31394 b962ae0a0a058d15053685dffdb508d36cd89b11
push id225
push usergszorc@mozilla.com
push dateThu, 05 May 2016 16:13:29 +0000
repoview: ignore unwritable hidden cache The atomictemp.close() file attempts to do a rename, which can fail. Moving the close inside the exception handler fixes it. This doesn't fit well with the with: pattern, as it's the finalizer that's failing.
mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -125,23 +125,22 @@ def trywritehiddencache(repo, hideable, 
     """
     wlock = fh = None
     try:
         wlock = repo.wlock(wait=False)
         # write cache to file
         newhash = cachehash(repo, hideable)
         fh = repo.vfs.open(cachefile, 'w+b', atomictemp=True)
         _writehiddencache(fh, newhash, hidden)
+        fh.close()
     except (IOError, OSError):
         repo.ui.debug('error writing hidden changesets cache\n')
     except error.LockHeld:
         repo.ui.debug('cannot obtain lock to write hidden changesets cache\n')
     finally:
-        if fh:
-            fh.close()
         if wlock:
             wlock.release()
 
 def tryreadcache(repo, hideable):
     """read a cache if the cache exists and is valid, otherwise returns None."""
     hidden = fh = None
     try:
         if repo.vfs.exists(cachefile):