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

Sune Foldager cryo at cyanite.org
Sat Oct 3 01:05:57 CDT 2009


Laurens Holst wrote:
>          temp = tempname(dst)
>          os.rename(dst, temp)
> +        os.rename(src, dst)
>          os.unlink(temp)
> -        os.rename(src, dst)
>

Since I sorta wrote the code you're changing above and since Windows
integrity has been pretty sensitive to this code in the various versions
we tried in the past, I am bit worried about just changing it but... did
you see if this actually helps anything?

If it does, I would analyse it as follows: os.rename creates, as far as
the stupid virus scanner is concerned, a new file, which is then opened
for scanning. The file 'src', having not been created right this
instant, might have been scanned in that past and already closed now, so
the rename to dst can go through. Then the unlink might fail, of course.

...but I don't see how this code in any way prevents unlink from
failing, which would in any case prevent the transaction from
completing. But I guess you're mainly concerned about a corrupt dirstate
file?

/Sune




More information about the Mercurial-devel mailing list