annotate tests/test-dirstate-race2.t @ 51470:406b413e3cf2 stable

rust-filepatterns: export glob_to_re function Making this function public should not risk freezing the internal API, and it can be useful for all downstream code that needs to perform glob matching against byte strings, such as RHGitaly where it will be useful to match on branches and tags.
author Georges Racinet <georges.racinet@octobus.net>
date Mon, 11 Mar 2024 13:23:18 +0100
parents e845537f6adb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48068
bf8837e3d7ce dirstate: Remove the flat Rust DirstateMap implementation
Simon Sapin <simon.sapin@octobus.net>
parents: 47281
diff changeset
1 #testcases dirstate-v1 dirstate-v2
47129
93eb6c8035a9 dirstate-tree: Add a dirstate-v1-tree variant of some tests
Simon Sapin <simon.sapin@octobus.net>
parents: 42456
diff changeset
2
47281
6763913fa175 dirstate-v2: Add a variant of some tests, that uses the new format
Simon Sapin <simon.sapin@octobus.net>
parents: 47129
diff changeset
3 #if dirstate-v2
48235
5c567aca080d dirstate-v2: add an option to prevent unintentional slow dirstate-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48223
diff changeset
4 $ cat >> $HGRCPATH << EOF
5c567aca080d dirstate-v2: add an option to prevent unintentional slow dirstate-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48223
diff changeset
5 > [format]
48674
f7086f6173f8 dirstate-v2: rename the configuration to enable the format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48295
diff changeset
6 > use-dirstate-v2=1
48235
5c567aca080d dirstate-v2: add an option to prevent unintentional slow dirstate-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48223
diff changeset
7 > [storage]
5c567aca080d dirstate-v2: add an option to prevent unintentional slow dirstate-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48223
diff changeset
8 > dirstate-v2.slow-path=allow
5c567aca080d dirstate-v2: add an option to prevent unintentional slow dirstate-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48223
diff changeset
9 > EOF
47281
6763913fa175 dirstate-v2: Add a variant of some tests, that uses the new format
Simon Sapin <simon.sapin@octobus.net>
parents: 47129
diff changeset
10 #endif
6763913fa175 dirstate-v2: Add a variant of some tests, that uses the new format
Simon Sapin <simon.sapin@octobus.net>
parents: 47129
diff changeset
11
42454
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
12 Checking the size/permissions/file-type of files stored in the
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
13 dirstate after an update where the files are changed concurrently
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
14 outside of hg's control.
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
15
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
16 $ hg init repo
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
17 $ cd repo
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
18 $ echo a > a
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
19 $ hg commit -qAm _
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
20 $ echo aa > a
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
21 $ hg commit -m _
48374
a4a5d123fb03 tests: make sure no ambiguities remains after the commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48295
diff changeset
22 # this sleep is there to ensure current time has -at-least- one second away
a4a5d123fb03 tests: make sure no ambiguities remains after the commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48295
diff changeset
23 # from the current time. It ensure the mtime is not ambiguous. If the test
a4a5d123fb03 tests: make sure no ambiguities remains after the commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48295
diff changeset
24 # "sleep" longer this will be fine.
a4a5d123fb03 tests: make sure no ambiguities remains after the commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48295
diff changeset
25 # It is not used to synchronise parallele operation so it is "fine" to use it.
a4a5d123fb03 tests: make sure no ambiguities remains after the commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48295
diff changeset
26 $ sleep 1
a4a5d123fb03 tests: make sure no ambiguities remains after the commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48295
diff changeset
27 $ hg status
42454
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
28
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
29 $ hg debugdirstate --no-dates
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
30 n 644 3 (set |unset) a (re)
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
31
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
32 $ cat >> $TESTTMP/dirstaterace.py << EOF
48459
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
33 > import time
42454
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
34 > from mercurial import (
48459
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
35 > commit,
42454
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
36 > extensions,
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
37 > merge,
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
38 > )
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
39 > def extsetup(ui):
48459
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
40 > extensions.wrapfunction(merge, 'applyupdates', wrap(0))
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
41 > extensions.wrapfunction(commit, 'commitctx', wrap(1))
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
42 > def wrap(duration):
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
43 > def new(orig, *args, **kwargs):
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
44 > res = orig(*args, **kwargs)
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
45 > with open("a", "w"):
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
46 > pass # just truncate the file
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
47 > time.sleep(duration)
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
48 > return res
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
49 > return new
42454
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
50 > EOF
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
51
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
52 Do an update where file 'a' is changed between hg writing it to disk
42456
87a34c767384 merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 42454
diff changeset
53 and hg writing the dirstate. The dirstate is correct nonetheless, and
87a34c767384 merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 42454
diff changeset
54 so hg status correctly shows a as clean.
42454
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
55
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
56 $ hg up -r 0 --config extensions.race=$TESTTMP/dirstaterace.py
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
57 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
58 $ hg debugdirstate --no-dates
42456
87a34c767384 merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 42454
diff changeset
59 n 644 2 (set |unset) a (re)
42454
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
60 $ echo a > a; hg status; hg diff
48459
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
61
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
62 Do a commit where file 'a' is changed between hg committing its new
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
63 revision into the repository, and the writing of the dirstate.
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
64
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
65 This used to results in a corrupted dirstate (size did not match committed size).
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
66
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
67 $ echo aaa > a; hg commit -qm _
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
68 $ hg merge -qr 1; hg resolve -m; rm a.orig
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
69 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
70 (no more unresolved files)
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
71 $ cat a
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
72 <<<<<<< working copy: be46f74ce38d - test: _
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
73 aaa
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
74 =======
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
75 aa
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
76 >>>>>>> merge rev: eb3fc6c17aa3 - test: _
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
77 $ hg debugdirstate --no-dates
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
78 m 0 -2 (set |unset) a (re)
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
79 $ hg commit -m _ --config extensions.race=$TESTTMP/dirstaterace.py
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
80 $ hg debugdirstate --no-dates
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
81 n 0 -1 unset a
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
82 $ cat a | wc -c
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
83 *0 (re)
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
84 $ hg cat -r . a | wc -c
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
85 *105 (re)
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
86 $ hg status; hg diff --stat
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
87 M a
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
88 a | 5 -----
bc6547f61310 test: add test for a former race resulting in bad dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 48422
diff changeset
89 1 files changed, 0 insertions(+), 5 deletions(-)