tests/test-dirstate-race2.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Wed, 21 Jul 2021 22:52:09 +0200
branchstable
changeset 47759 d7515d29761d
parent 47281 6763913fa175
child 48068 bf8837e3d7ce
permissions -rw-r--r--
branching: merge default into stable This mark the start of the 5.9 freeze.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
     1
#testcases dirstate-v1 dirstate-v1-tree 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
93eb6c8035a9 dirstate-tree: Add a dirstate-v1-tree variant of some tests
Simon Sapin <simon.sapin@octobus.net>
parents: 42456
diff changeset
     3
#if dirstate-v1-tree
93eb6c8035a9 dirstate-tree: Add a dirstate-v1-tree variant of some tests
Simon Sapin <simon.sapin@octobus.net>
parents: 42456
diff changeset
     4
#require rust
93eb6c8035a9 dirstate-tree: Add a dirstate-v1-tree variant of some tests
Simon Sapin <simon.sapin@octobus.net>
parents: 42456
diff changeset
     5
  $ echo '[experimental]' >> $HGRCPATH
93eb6c8035a9 dirstate-tree: Add a dirstate-v1-tree variant of some tests
Simon Sapin <simon.sapin@octobus.net>
parents: 42456
diff changeset
     6
  $ echo 'dirstate-tree.in-memory=1' >> $HGRCPATH
93eb6c8035a9 dirstate-tree: Add a dirstate-v1-tree variant of some tests
Simon Sapin <simon.sapin@octobus.net>
parents: 42456
diff changeset
     7
#endif
93eb6c8035a9 dirstate-tree: Add a dirstate-v1-tree variant of some tests
Simon Sapin <simon.sapin@octobus.net>
parents: 42456
diff changeset
     8
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
     9
#if dirstate-v2
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
#require rust
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
  $ echo '[format]' >> $HGRCPATH
6763913fa175 dirstate-v2: Add a variant of some tests, that uses the new format
Simon Sapin <simon.sapin@octobus.net>
parents: 47129
diff changeset
    12
  $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
6763913fa175 dirstate-v2: Add a variant of some tests, that uses the new format
Simon Sapin <simon.sapin@octobus.net>
parents: 47129
diff changeset
    13
#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
    14
42454
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    15
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
    16
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
    17
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
    18
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    19
  $ 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
    20
  $ cd repo
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    21
  $ 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
    22
  $ 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
    23
  $ 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
    24
  $ hg commit -m _
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    25
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    26
  $ 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
    27
  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
    28
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    29
  $ cat >> $TESTTMP/dirstaterace.py << EOF
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    30
  > from mercurial import (
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    31
  >     extensions,
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    32
  >     merge,
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    33
  > )
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    34
  > def extsetup(ui):
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    35
  >     extensions.wrapfunction(merge, 'applyupdates', wrap)
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    36
  > def wrap(orig, *args, **kwargs):
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    37
  >     res = orig(*args, **kwargs)
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    38
  >     with open("a", "w"):
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    39
  >         pass # just truncate the file
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    40
  >     return res
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    41
  > EOF
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    42
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    43
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
    44
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
    45
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
    46
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    47
  $ 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
    48
  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
    49
  $ 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
    50
  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
    51
  $ echo a > a; hg status; hg diff