comparison tests/test-dirstate-race2.t @ 42454:0eb8c61c306b

tests: show how the dirstate can end up containing wrong information which can result in bad status output. Concretely, this seems to be easily triggered by having a build system watching the filesystem for changes, and rebuilding files that are both tracked and generated while an update is happening. Differential Revision: https://phab.mercurial-scm.org/D6474
author Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
date Sun, 19 May 2019 16:06:06 -0400
parents
children 87a34c767384
comparison
equal deleted inserted replaced
42453:94167e701e12 42454:0eb8c61c306b
1 Checking the size/permissions/file-type of files stored in the
2 dirstate after an update where the files are changed concurrently
3 outside of hg's control.
4
5 $ hg init repo
6 $ cd repo
7 $ echo a > a
8 $ hg commit -qAm _
9 $ echo aa > a
10 $ hg commit -m _
11
12 $ hg debugdirstate --no-dates
13 n 644 3 (set |unset) a (re)
14
15 $ cat >> $TESTTMP/dirstaterace.py << EOF
16 > from mercurial import (
17 > extensions,
18 > merge,
19 > )
20 > def extsetup(ui):
21 > extensions.wrapfunction(merge, 'applyupdates', wrap)
22 > def wrap(orig, *args, **kwargs):
23 > res = orig(*args, **kwargs)
24 > with open("a", "w"):
25 > pass # just truncate the file
26 > return res
27 > EOF
28
29 Do an update where file 'a' is changed between hg writing it to disk
30 and hg writing the dirstate. It results in a corrupted dirstate, which
31 stores the wrong size, and thus hg status shows spuriously modified
32 files.
33
34 $ hg up -r 0 --config extensions.race=$TESTTMP/dirstaterace.py
35 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
36 $ hg debugdirstate --no-dates
37 n 644 0 (set |unset) a (re)
38 $ echo a > a; hg status; hg diff
39 M a