tests/test-dirstate-race2.t
author Simon Sapin <simon.sapin@octobus.net>
Mon, 03 May 2021 20:04:19 +0200
changeset 47129 93eb6c8035a9
parent 42456 87a34c767384
child 47281 6763913fa175
permissions -rw-r--r--
dirstate-tree: Add a dirstate-v1-tree variant of some tests The `dirstate-v1` variant has the previous behavior. `dirstate-v1-tree` uses the same format on disk, but uses the new `DirstateMap` with a tree data structure and the new `status` algorithm. These were untested so far. Differential Revision: https://phab.mercurial-scm.org/D10698
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47129
93eb6c8035a9 dirstate-tree: Add a dirstate-v1-tree variant of some tests
Simon Sapin <simon.sapin@octobus.net>
parents: 42456
diff changeset
     1
#testcases dirstate-v1 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
     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
42454
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
     9
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
    10
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
    11
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
    12
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    13
  $ 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
    14
  $ cd repo
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    15
  $ 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
    16
  $ 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
    17
  $ 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
    18
  $ 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
    19
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    20
  $ 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
    21
  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
    22
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    23
  $ 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
    24
  > 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
    25
  >     extensions,
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    26
  >     merge,
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    27
  > )
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    28
  > 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
    29
  >     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
    30
  > 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
    31
  >     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
    32
  >     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
    33
  >         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
    34
  >     return res
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    35
  > EOF
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    36
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    37
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
    38
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
    39
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
    40
0eb8c61c306b tests: show how the dirstate can end up containing wrong information
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
diff changeset
    41
  $ 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
    42
  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
    43
  $ 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
    44
  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
    45
  $ echo a > a; hg status; hg diff