[PATCH 1 of 1 STABLE] readlock: close lock file as early as possible
Adrian Buehlmann
adrian at cadifra.com
Thu Dec 2 18:33:40 CST 2010
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1291335788 -3600
# Branch stable
# Node ID a8d607c0565008848e207a54dc08ca3edff005fe
# Parent 5e51254ad4d4c80669f462e310b2677f2b3c54a7
readlock: close lock file as early as possible
Avoiding Windows' "scheduled delete" state on the lock file, which
happens if the lock file is unlinked while it is open.
Scheduled delete state prevents creating the lock file, which
is bad.
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -598,7 +598,11 @@ def readlock(pathname):
raise
except AttributeError: # no symlink in os
pass
- return posixfile(pathname).read()
+ fd = posixfile(pathname)
+ try:
+ return fd.read()
+ finally:
+ fd.close()
def fstat(fp):
'''stat file object that may not have fileno method.'''
More information about the Mercurial-devel
mailing list