[PATCH STABLE] win32: backout 1a9ebc83a74c

Adrian Buehlmann adrian at cadifra.com
Sat May 3 03:43:55 CDT 2014


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1399106034 -7200
# Branch stable
# Node ID b3bceb2a103e9f279f058e7a3bacf272968b6bb6
# Parent  d36440d843284ba546858b241da9cc4817811fe5
win32: backout 1a9ebc83a74c

This appears to cause havoc on TortoiseHg. While 1a9ebc83a74c may be nice to
have (as soon as someone can prove it has no unwanted side effects), it is not
worth the troubles at this point.

diff --git a/mercurial/win32.py b/mercurial/win32.py
--- a/mercurial/win32.py
+++ b/mercurial/win32.py
@@ -24,7 +24,6 @@
 
 # GetLastError
 _ERROR_SUCCESS = 0
-_ERROR_SHARING_VIOLATION = 32
 _ERROR_INVALID_PARAMETER = 87
 _ERROR_INSUFFICIENT_BUFFER = 122
 
@@ -60,9 +59,7 @@
 
 _OPEN_EXISTING = 3
 
-_FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
 _FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
-_FILE_FLAG_DELETE_ON_CLOSE = 0x04000000
 
 # SetFileAttributes
 _FILE_ATTRIBUTE_NORMAL = 0x80
@@ -423,18 +420,11 @@
 def unlink(f):
     '''try to implement POSIX' unlink semantics on Windows'''
 
-    # If we can open f exclusively, no other processes must have open handles
-    # for it and we can expect its name will be deleted immediately when we
-    # close the handle unless we have another in the same process.  We also
-    # expect we shall simply fail to open f if it is a directory.
-    fh = _kernel32.CreateFileA(f, 0, 0, None, _OPEN_EXISTING,
-        _FILE_FLAG_OPEN_REPARSE_POINT | _FILE_FLAG_DELETE_ON_CLOSE, None)
-    if fh != _INVALID_HANDLE_VALUE:
-        _kernel32.CloseHandle(fh)
-        return
-    error = _kernel32.GetLastError()
-    if error != _ERROR_SHARING_VIOLATION:
-        raise ctypes.WinError(error)
+    if os.path.isdir(f):
+        # use EPERM because it is POSIX prescribed value, even though
+        # unlink(2) on directories returns EISDIR on Linux
+        raise IOError(errno.EPERM,
+                      "Unlinking directory not permitted: '%s'" % f)
 
     # POSIX allows to unlink and rename open files. Windows has serious
     # problems with doing that:


More information about the Mercurial-devel mailing list