repoview: use try/except/finally
authorMatt Mackall <mpm@selenic.com>
Fri, 15 May 2015 09:57:44 -0500
changeset 25086 140c2d1e57e7
parent 25085 e05734cd7902
child 25087 559f24e3957d
repoview: use try/except/finally
mercurial/repoview.py
--- a/mercurial/repoview.py	Fri May 15 09:57:02 2015 -0500
+++ b/mercurial/repoview.py	Fri May 15 09:57:44 2015 -0500
@@ -115,16 +115,15 @@
     """
     wlock = fh = None
     try:
-        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)
-        except (IOError, OSError):
-            repo.ui.debug('error writing hidden changesets cache')
-        except error.LockHeld:
-            repo.ui.debug('cannot obtain lock to write hidden changesets cache')
+        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)
+    except (IOError, OSError):
+        repo.ui.debug('error writing hidden changesets cache')
+    except error.LockHeld:
+        repo.ui.debug('cannot obtain lock to write hidden changesets cache')
     finally:
         if fh:
             fh.close()