comparison mercurial/util_win32.py @ 5895:f1ac41359b36

Merge with crew-stable
author Patrick Mezard <pmezard@gmail.com>
date Sat, 19 Jan 2008 13:19:27 +0100
parents e90a7a3c28a4 cacfeee38870
children 821fc5c0656c
comparison
equal deleted inserted replaced
5894:e181665c1c79 5895:f1ac41359b36
145 WinError.__init__(self, err) 145 WinError.__init__(self, err)
146 OSError.__init__(self, self.winerror_map.get(self.win_errno, 0), 146 OSError.__init__(self, self.winerror_map.get(self.win_errno, 0),
147 self.win_strerror) 147 self.win_strerror)
148 148
149 def os_link(src, dst): 149 def os_link(src, dst):
150 # NB will only succeed on NTFS
151 try: 150 try:
152 win32file.CreateHardLink(dst, src) 151 win32file.CreateHardLink(dst, src)
152 # CreateHardLink sometimes succeeds on mapped drives but
153 # following nlinks() returns 1. Check it now and bail out.
154 if nlinks(src) < 2:
155 try:
156 win32file.DeleteFile(dst)
157 except:
158 pass
159 # Fake hardlinking error
160 raise WinOSError((18, 'CreateHardLink', 'The system cannot '
161 'move the file to a different disk drive'))
153 except pywintypes.error, details: 162 except pywintypes.error, details:
154 raise WinOSError(details) 163 raise WinOSError(details)
155 164
156 def nlinks(pathname): 165 def nlinks(pathname):
157 """Return number of hardlinks for the given file.""" 166 """Return number of hardlinks for the given file."""