# HG changeset patch # User Matt Mackall # Date 1234827443 21600 # Node ID 9892c4d94fb76df173251df15f54930472ca1b72 # Parent e899ead7b8ae5f5044fbaf7ea38da1f72ff017c3 rename: simplify forced renaming This should help work around virus scanner issues with rename on Windows. diff -r e899ead7b8ae -r 9892c4d94fb7 mercurial/util.py --- 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)