mercurial/repoview.py
changeset 22174 0cc2db64c335
parent 22151 c0c369aec643
child 22261 eba48f2b9b74
--- a/mercurial/repoview.py	Thu Aug 14 16:25:47 2014 -0500
+++ b/mercurial/repoview.py	Thu Aug 14 16:39:02 2014 -0500
@@ -85,19 +85,20 @@
     """
     wlock = fh = None
     try:
-        wlock = repo.wlock(wait=False)
-        # write cache to file
-        newhash = cachehash(repo, hideable)
-        sortedset = sorted(hidden)
-        data = struct.pack('>%iI' % len(sortedset), *sortedset)
-        fh = repo.vfs.open(cachefile, 'w+b', atomictemp=True)
-        fh.write(struct.pack(">H", cacheversion))
-        fh.write(newhash)
-        fh.write(data)
-    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')
+        try:
+            wlock = repo.wlock(wait=False)
+            # write cache to file
+            newhash = cachehash(repo, hideable)
+            sortedset = sorted(hidden)
+            data = struct.pack('>%iI' % len(sortedset), *sortedset)
+            fh = repo.vfs.open(cachefile, 'w+b', atomictemp=True)
+            fh.write(struct.pack(">H", cacheversion))
+            fh.write(newhash)
+            fh.write(data)
+        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()