diff mercurial/revlog.py @ 2250:45aef5ddcdbe

windows: revlog.lazyparser not always safe to use. can not use on windows < nt or if win32 api not available.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Wed, 10 May 2006 11:10:18 -0700
parents c9e264b115e6
children 3f38e872f39a
line wrap: on
line diff
--- 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)