comparison tests/test-dirstate-race.t @ 32651:c850f0ed54c1 stable 4.2.1

status: don't crash if a lookup file disappears This can happen if another process (even another hg process!) comes along and removes the file at that time. This partly resolves issue5584, but not completely -- a bogus dirstate update can still happen. However, the full fix is too involved for stable.
author Siddharth Agarwal <sid0@fb.com>
date Fri, 02 Jun 2017 22:27:52 -0700
parents 28e2e3804f2e
children bcb6684d144b
comparison
equal deleted inserted replaced
32608:85b978031a75 32651:c850f0ed54c1
1 $ hg init 1 $ hg init repo
2 $ cd repo
2 $ echo a > a 3 $ echo a > a
3 $ hg add a 4 $ hg add a
4 $ hg commit -m test 5 $ hg commit -m test
5 6
6 Do we ever miss a sub-second change?: 7 Do we ever miss a sub-second change?:
29 M a 30 M a
30 M a 31 M a
31 M a 32 M a
32 M a 33 M a
33 34
35 $ echo test > b
36 $ mkdir dir1
37 $ echo test > dir1/c
38 $ echo test > d
39
40 $ echo test > e
41 #if execbit
42 A directory will typically have the execute bit -- make sure it doesn't get
43 confused with a file with the exec bit set
44 $ chmod +x e
45 #endif
46
47 $ hg add b dir1 d e
48 adding dir1/c
49 $ hg commit -m test2
50
51 $ cat >> $TESTTMP/dirstaterace.py << EOF
52 > from mercurial import (
53 > context,
54 > extensions,
55 > )
56 > def extsetup():
57 > extensions.wrapfunction(context.workingctx, '_checklookup', overridechecklookup)
58 > def overridechecklookup(orig, self, files):
59 > # make an update that changes the dirstate from underneath
60 > self._repo.ui.system(self._repo.ui.config('dirstaterace', 'command'), cwd=self._repo.root)
61 > return orig(self, files)
62 > EOF
63
64 $ hg debugrebuilddirstate
65 $ hg debugdirstate
66 n 0 -1 unset a
67 n 0 -1 unset b
68 n 0 -1 unset d
69 n 0 -1 unset dir1/c
70 n 0 -1 unset e
71
72 XXX Note that this returns M for files that got replaced by directories. This is
73 definitely a bug, but the fix for that is hard and the next status run is fine
74 anyway.
75
76 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py \
77 > --config dirstaterace.command='rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e'
78 M d
79 M e
80 ! b
81 ! dir1/c
82 $ hg debugdirstate
83 n 644 2 * a (glob)
84 n 0 -1 unset b
85 n 0 -1 unset d
86 n 0 -1 unset dir1/c
87 n 0 -1 unset e
88
89 $ hg status
90 ! b
91 ! d
92 ! dir1/c
93 ! e