windows: revlog.lazyparser not always safe to use.
can not use on windows < nt or if win32 api not available.
--- a/mercurial/revlog.py Wed May 10 10:32:24 2006 -0700
+++ b/mercurial/revlog.py Wed May 10 11:10:18 2006 -0700
@@ -87,6 +87,13 @@
"""
this class avoids the need to parse the entirety of large indices
"""
+
+ # lazyparser is not safe to use on windows if win32 extensions not
+ # available. it keeps file handle open, which make it not possible
+ # to break hardlinks on local cloned repos.
+ safe_to_use = os.name != 'nt' or (not util.is_win_9x() and
+ hasattr(util, 'win32api'))
+
def __init__(self, dataf, size, indexformat, shaoffset):
self.dataf = dataf
self.format = indexformat
@@ -362,7 +369,8 @@
shaoffset = ngshaoffset
if i:
- if not self.inlinedata() and st and st.st_size > 10000:
+ if (lazyparser.safe_to_use and not self.inlinedata() and
+ st and st.st_size > 10000):
# big index, let's parse it on demand
parser = lazyparser(f, st.st_size, self.indexformat, shaoffset)
self.index = lazyindex(parser)
--- a/mercurial/util.py Wed May 10 10:32:24 2006 -0700
+++ b/mercurial/util.py Wed May 10 11:10:18 2006 -0700
@@ -489,6 +489,13 @@
posixfile = file
+def is_win_9x():
+ '''return true if run on windows 95, 98 or me.'''
+ try:
+ return sys.getwindowsversion()[3] == 1
+ except AttributeError:
+ return os.name == 'nt' and 'command' in os.environ.get('comspec', '')
+
# Platform specific variants
if os.name == 'nt':
demandload(globals(), "msvcrt")
@@ -570,6 +577,8 @@
try:
# override functions with win32 versions if possible
from util_win32 import *
+ if not is_win_9x():
+ posixfile = posixfile_nt
except ImportError:
pass
--- a/mercurial/util_win32.py Wed May 10 10:32:24 2006 -0700
+++ b/mercurial/util_win32.py Wed May 10 11:10:18 2006 -0700
@@ -183,11 +183,11 @@
filename = win32process.GetModuleFileNameEx(proc, 0)
return [os.path.join(os.path.dirname(filename), 'mercurial.ini')]
-class posixfile(object):
+class posixfile_nt(object):
'''file object with posix-like semantics. on windows, normal
files can not be deleted or renamed if they are open. must open
with win32file.FILE_SHARE_DELETE. this flag does not exist on
- windows <= nt.'''
+ windows < nt, so do not use this class there.'''
# tried to use win32file._open_osfhandle to pass fd to os.fdopen,
# but does not work at all. wrap win32 file api instead.