##// END OF EJS Templates
windows: revlog.lazyparser not always safe to use....
Vadim Gelfer -
r2250:45aef5dd default
parent child Browse files
Show More
@@ -87,6 +87,13 b' class lazyparser(object):'
87 87 """
88 88 this class avoids the need to parse the entirety of large indices
89 89 """
90
91 # lazyparser is not safe to use on windows if win32 extensions not
92 # available. it keeps file handle open, which make it not possible
93 # to break hardlinks on local cloned repos.
94 safe_to_use = os.name != 'nt' or (not util.is_win_9x() and
95 hasattr(util, 'win32api'))
96
90 97 def __init__(self, dataf, size, indexformat, shaoffset):
91 98 self.dataf = dataf
92 99 self.format = indexformat
@@ -362,7 +369,8 b' class revlog(object):'
362 369 shaoffset = ngshaoffset
363 370
364 371 if i:
365 if not self.inlinedata() and st and st.st_size > 10000:
372 if (lazyparser.safe_to_use and not self.inlinedata() and
373 st and st.st_size > 10000):
366 374 # big index, let's parse it on demand
367 375 parser = lazyparser(f, st.st_size, self.indexformat, shaoffset)
368 376 self.index = lazyindex(parser)
@@ -489,6 +489,13 b' def fstat(fp):'
489 489
490 490 posixfile = file
491 491
492 def is_win_9x():
493 '''return true if run on windows 95, 98 or me.'''
494 try:
495 return sys.getwindowsversion()[3] == 1
496 except AttributeError:
497 return os.name == 'nt' and 'command' in os.environ.get('comspec', '')
498
492 499 # Platform specific variants
493 500 if os.name == 'nt':
494 501 demandload(globals(), "msvcrt")
@@ -570,6 +577,8 b" if os.name == 'nt':"
570 577 try:
571 578 # override functions with win32 versions if possible
572 579 from util_win32 import *
580 if not is_win_9x():
581 posixfile = posixfile_nt
573 582 except ImportError:
574 583 pass
575 584
@@ -183,11 +183,11 b' def system_rcpath_win32():'
183 183 filename = win32process.GetModuleFileNameEx(proc, 0)
184 184 return [os.path.join(os.path.dirname(filename), 'mercurial.ini')]
185 185
186 class posixfile(object):
186 class posixfile_nt(object):
187 187 '''file object with posix-like semantics. on windows, normal
188 188 files can not be deleted or renamed if they are open. must open
189 189 with win32file.FILE_SHARE_DELETE. this flag does not exist on
190 windows <= nt.'''
190 windows < nt, so do not use this class there.'''
191 191
192 192 # tried to use win32file._open_osfhandle to pass fd to os.fdopen,
193 193 # but does not work at all. wrap win32 file api instead.
General Comments 0
You need to be logged in to leave comments. Login now