mercurial/win32.py
branchstable
changeset 19159 1b329f8c7b24
parent 18959 2f6418d8a4c9
child 20425 ca6aa8362f33
--- a/mercurial/win32.py	Thu May 09 21:09:58 2013 +0900
+++ b/mercurial/win32.py	Tue May 07 05:04:11 2013 +0900
@@ -344,6 +344,12 @@
 def unlink(f):
     '''try to implement POSIX' unlink semantics on Windows'''
 
+    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:
     # - Calling os.unlink (or os.rename) on a file f fails if f or any