[PATCH] util.rename: do not abort if os.unlink fails (issue1840)
Steve Borho
steve at borho.org
Tue Oct 6 21:13:53 UTC 2009
On Tue, Oct 6, 2009 at 4:55 AM, Adrian Buehlmann <adrian at cadifra.com> wrote:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1254818723 -7200
> # Node ID 0aa4141bfb5cc1f033cc2c41dc3d0e1d6a3a2b6f
> # Parent d932dc6558812678bb374d66a364212d54503744
> util.rename: do not abort if os.unlink fails (issue1840)
>
Thanks,
I've pushed this to crew-stable. Can you make a patch for crew that splits
rename() into posix and win versions as Greg suggests?
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -427,7 +427,14 @@ def rename(src, dst):
>
> temp = tempname(dst)
> os.rename(dst, temp)
> - os.unlink(temp)
> + try:
> + os.unlink(temp)
> + except:
> + # Some rude AV-scanners on Windows may cause the unlink to
> + # fail. Not aborting here just leaks the temp file, whereas
> + # aborting at this point may leave serious inconsistencies.
> + # Ideally, we would notify the user here.
> + pass
> os.rename(src, dst)
>
> def unlink(f):
>
--
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20091006/613fce10/attachment-0001.html>
More information about the Mercurial-devel
mailing list