[PATCH STABLE] windows: make win32 mandatory (issue1922)

Adrian Buehlmann adrian at cadifra.com
Thu Jan 20 07:54:53 CST 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1295531395 -3600
# Branch stable
# Node ID 3fd55ff419f068ad5c3a96f7e2d2855072b5f32b
# Parent  75d0c38a0bca3501aaa3fa6b8c26de8ca0270803
windows: make win32 mandatory (issue1922)

importing mercurial.win32 fails with

  ImportError: No module named win32api

if pywin32 is not installed. In that case nlinks() was defined as

  def nlinks(pathname):
      """Return number of hardlinks for the given file."""
      return os.lstat(pathname).st_nlink

os.lstat(pathname).st_nlink is 0 for every file on Windows, which
leads to util.opener failing to break up hardlinks.

On Windows, the implementation of nlinks() in mercurial/win32.py
*is* required.

Users using installers like

  mercurial-1.7.3-1.win32-py2.6.exe

must additionally install the pywin32 package.

diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -366,10 +366,6 @@ def groupmembers(name):
     # Don't support groups on Windows for now
     raise KeyError()
 
-try:
-    # override functions with win32 versions if possible
-    from win32 import *
-except ImportError:
-    pass
+from win32 import *
 
 expandglobs = True


More information about the Mercurial-devel mailing list