changeset 5895:f1ac41359b36

Merge with crew-stable
author Patrick Mezard <pmezard@gmail.com>
date Sat, 19 Jan 2008 13:19:27 +0100
parents e181665c1c79 (current diff) cacfeee38870 (diff)
children ff7fb4f0db53
files mercurial/util_win32.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util_win32.py	Sat Jan 19 03:06:01 2008 +0100
+++ b/mercurial/util_win32.py	Sat Jan 19 13:19:27 2008 +0100
@@ -147,9 +147,18 @@
                          self.win_strerror)
 
 def os_link(src, dst):
-    # NB will only succeed on NTFS
     try:
         win32file.CreateHardLink(dst, src)
+        # CreateHardLink sometimes succeeds on mapped drives but
+        # following nlinks() returns 1. Check it now and bail out.
+        if nlinks(src) < 2:
+            try:
+                win32file.DeleteFile(dst)
+            except:
+                pass
+            # Fake hardlinking error
+            raise WinOSError((18, 'CreateHardLink', 'The system cannot '
+                              'move the file to a different disk drive'))
     except pywintypes.error, details:
         raise WinOSError(details)