[PATCH 2 of 2] Reorder rename operations to minimise risk of leaving repository in unknown state

Steve Borho steve at borho.org
Mon Sep 28 17:24:22 CDT 2009


On Mon, Sep 28, 2009 at 5:00 PM, Laurens Holst <laurens.nospam at grauw.nl> wrote:
> # HG changeset patch
> # User Grauw <laurens.hg at grauw.nl>
> # Date 1254174954 -7200
> # Node ID c6d8d8a535d478f6fdc00dd6e111c34cf7491c2b
> # Parent  844c64c7cc2123c5ae16fbfcd27f16fa3e232eca
> Reorder rename operations to minimise risk of leaving repository in unknown state
> because of interfering virus scanner. As suggested by Steve Borho, see
> http://bitbucket.org/tortoisehg/stable/issue/580/#comment-57703
> Issue 1840 - AVG anti-virus interferes with disk access
>
> diff -r 844c64c7cc21 -r c6d8d8a535d4 mercurial/util.py
> --- a/mercurial/util.py Fri Aug 07 01:15:16 2009 +0200
> +++ b/mercurial/util.py Mon Sep 28 23:55:54 2009 +0200
> @@ -444,8 +444,8 @@
>
>         temp = tempname(dst)
>         os.rename(dst, temp)
> +        os.rename(src, dst)
>         os.unlink(temp)
> -        os.rename(src, dst)
>
>  def unlink(f):
>     """unlink and remove the directory if it is empty"""

A few of us discussed this issue on IRC today and came to the
conclusion this change would not have recovered the dirstate file
Mercurial was attempting to rename.  Until the AV tool releases the
renamed source file, any attempt to rename over the original filename
will fail.

Since there is very little interest in adding fall-back timers into
Mercurial to work around unfriendly AV checkers, you're only recourse
is to figure out how to disable AVG free inside your repository or
switch to another anti-virus tool.  I don't recommend using Mercurial
with AVG free, as the next time it breaks a rename it could be a file
that is not as recoverable as dirstate.

I've added a note to the front page of TortoiseHg's wiki to this effect.

--
Steve Borho



More information about the Mercurial-devel mailing list