changeset 7780:9892c4d94fb7

rename: simplify forced renaming This should help work around virus scanner issues with rename on Windows.
author Matt Mackall <mpm@selenic.com>
date Mon, 16 Feb 2009 17:37:23 -0600
parents e899ead7b8ae
children a45206455d85
files mercurial/util.py
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Mon Feb 16 17:37:23 2009 -0600
+++ b/mercurial/util.py	Mon Feb 16 17:37:23 2009 -0600
@@ -740,12 +740,10 @@
         # on windows, rename to existing file is not allowed, so we
         # must delete destination first. but if file is open, unlink
         # schedules it for delete but does not delete it. rename
-        # happens immediately even for open files, so we create
-        # temporary file, delete it, rename destination to that name,
-        # then delete that. then rename is safe to do.
-        fd, temp = tempfile.mkstemp(dir=os.path.dirname(dst) or '.')
-        os.close(fd)
-        os.unlink(temp)
+        # happens immediately even for open files, so we rename
+        # destination to a temporary name, then delete that. then
+        # rename is safe to do.
+        temp = dst + "-force-rename"
         os.rename(dst, temp)
         os.unlink(temp)
         os.rename(src, dst)