diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -112,8 +112,6 @@ class lazyparser(object): # 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): self.dataf = dataf @@ -362,7 +360,7 @@ class revlogio(object): except AttributeError: size = 0 - if lazyparser.safe_to_use and not inline and size > 1000000: + if util.openhardlinks() and not inline and size > 1000000: # big index, let's parse it on demand parser = lazyparser(fp, size) index = lazyindex(parser) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -772,12 +772,9 @@ def fstat(fp): 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', '') +def openhardlinks(): + '''return true if it is safe to hold open file handles to hardlinks''' + return True getuser_fallback = None @@ -943,6 +940,16 @@ if os.name == 'nt': sys.stdout = winstdout(sys.stdout) + def _is_win_9x(): + '''return true if run on windows 95, 98 or me.''' + try: + return sys.getwindowsversion()[3] == 1 + except AttributeError: + return 'command' in os.environ.get('comspec', '') + + def openhardlinks(): + return not _is_win_9x and "win32api" in locals() + def system_rcpath(): try: return system_rcpath_win32() @@ -1074,7 +1081,7 @@ if os.name == 'nt': try: # override functions with win32 versions if possible from util_win32 import * - if not is_win_9x(): + if not _is_win_9x(): posixfile = posixfile_nt except ImportError: pass