changeset 30164:1c518d69d994

eol: make sure we always release the wlock when writing cache If any exception were to happen after we acquired the wlock, we could leave it unreleased. We move the wlock release in a 'finally:' close as it should be.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 13 Oct 2016 13:47:47 +0200
parents f5607b6253da
children 423377290a3a
files hgext/eol.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/eol.py	Thu Oct 13 21:42:11 2016 +0200
+++ b/hgext/eol.py	Thu Oct 13 13:47:47 2016 +0200
@@ -360,7 +360,6 @@
                     # Write the cache to update mtime and cache .hgeol
                     with self.vfs("eol.cache", "w") as f:
                         f.write(hgeoldata)
-                    wlock.release()
                 except error.LockUnavailable:
                     # If we cannot lock the repository and clear the
                     # dirstate, then a commit might not see all files
@@ -368,6 +367,9 @@
                     # repository, then we can also not make a commit,
                     # so ignore the error.
                     pass
+                finally:
+                    if wlock is not None:
+                        wlock.release()
 
         def commitctx(self, ctx, haserror=False):
             for f in sorted(ctx.added() + ctx.modified()):