##// 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 this class avoids the need to parse the entirety of large indices
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 def __init__(self, dataf, size, indexformat, shaoffset):
97 def __init__(self, dataf, size, indexformat, shaoffset):
91 self.dataf = dataf
98 self.dataf = dataf
92 self.format = indexformat
99 self.format = indexformat
@@ -362,7 +369,8 b' class revlog(object):'
362 shaoffset = ngshaoffset
369 shaoffset = ngshaoffset
363
370
364 if i:
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 # big index, let's parse it on demand
374 # big index, let's parse it on demand
367 parser = lazyparser(f, st.st_size, self.indexformat, shaoffset)
375 parser = lazyparser(f, st.st_size, self.indexformat, shaoffset)
368 self.index = lazyindex(parser)
376 self.index = lazyindex(parser)
@@ -489,6 +489,13 b' def fstat(fp):'
489
489
490 posixfile = file
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 # Platform specific variants
499 # Platform specific variants
493 if os.name == 'nt':
500 if os.name == 'nt':
494 demandload(globals(), "msvcrt")
501 demandload(globals(), "msvcrt")
@@ -570,6 +577,8 b" if os.name == 'nt':"
570 try:
577 try:
571 # override functions with win32 versions if possible
578 # override functions with win32 versions if possible
572 from util_win32 import *
579 from util_win32 import *
580 if not is_win_9x():
581 posixfile = posixfile_nt
573 except ImportError:
582 except ImportError:
574 pass
583 pass
575
584
@@ -183,11 +183,11 b' def system_rcpath_win32():'
183 filename = win32process.GetModuleFileNameEx(proc, 0)
183 filename = win32process.GetModuleFileNameEx(proc, 0)
184 return [os.path.join(os.path.dirname(filename), 'mercurial.ini')]
184 return [os.path.join(os.path.dirname(filename), 'mercurial.ini')]
185
185
186 class posixfile(object):
186 class posixfile_nt(object):
187 '''file object with posix-like semantics. on windows, normal
187 '''file object with posix-like semantics. on windows, normal
188 files can not be deleted or renamed if they are open. must open
188 files can not be deleted or renamed if they are open. must open
189 with win32file.FILE_SHARE_DELETE. this flag does not exist on
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 # tried to use win32file._open_osfhandle to pass fd to os.fdopen,
192 # tried to use win32file._open_osfhandle to pass fd to os.fdopen,
193 # but does not work at all. wrap win32 file api instead.
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