changeset 13278:e9a52ed28157

windows.rename: check OSError for EEXIST For example, if src has been opened with Python's open(), os.rename will raise EACCES. Continuing in that case is pointless.
author Adrian Buehlmann <adrian@cadifra.com>
date Tue, 11 Jan 2011 14:10:16 +0100
parents 57d433f632b7
children eed22340b7aa
files mercurial/windows.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/windows.py	Fri Jan 07 10:48:30 2011 +0100
+++ b/mercurial/windows.py	Tue Jan 11 14:10:16 2011 +0100
@@ -289,7 +289,9 @@
     '''atomically rename file src to dst, replacing dst if it exists'''
     try:
         os.rename(src, dst)
-    except OSError: # FIXME: check err (EEXIST ?)
+    except OSError, e:
+        if e.errno != errno.EEXIST:
+            raise
 
         # On windows, rename to existing file is not allowed, so we
         # must delete destination first. But if a file is open, unlink