vfs: use checkambigatclosing in checkambig=True but atomictemp=False case
In Mercurial source tree, opening a file in "a"/"a+" mode like below
doesn't specify atomictemp=True for vfs, and this avoids file stat
ambiguity check by atomictempfile.
- writing changes out in revlog layer uses "a+" mode
- truncation in repair.strip() uses "a" mode
- truncation in transaction._playback() uses "a" mode
If steps below occurs at "the same time in sec", all of mtime, ctime
and size are same between (1) and (3).
1. append data to revlog-style file (and close transaction)
2. discard appended data by truncation (strip or rollback)
3. append same size but different data to revlog-style file again
Therefore, cache validation doesn't work after (3) as expected.
This patch uses checkambigatclosing in checkambig=True but
atomictemp=False case, to check (and get rid of) file stat ambiguity
at closing.
This is a part of ExactCacheValidationPlan.
https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
$ hg init
$ $PYTHON -c 'file("a", "wb").write("confuse str.splitlines\nembedded\rnewline\n")'
$ hg ci -Ama -d '1 0'
adding a
$ echo clean diff >> a
$ hg ci -mb -d '2 0'
$ hg diff -r0 -r1
diff -r 107ba6f817b5 -r 310ce7989cdc a
--- a/a Thu Jan 01 00:00:01 1970 +0000
+++ b/a Thu Jan 01 00:00:02 1970 +0000
@@ -1,2 +1,3 @@
confuse str.splitlines
embedded\r (no-eol) (esc)
newline
+clean diff