tests/test-dirstate-race.t
author Simon Sapin <simon.sapin@octobus.net>
Fri, 16 Jul 2021 18:42:20 +0200
changeset 48235 b4f83c9e7905
parent 48083 bf8837e3d7ce
child 48247 5c567aca080d
permissions -rw-r--r--
dirstate-v2: Add support when Rust is not enabled This wires into `dirstatemap` the parser and serializer added in previous changesets. The memory representation is still the same, with a flat `dict` for `DirstateItem`s and another one for copy sources. Serialization always creates a new dirstate-v2 data file and does not support (when Rust is not enabled) appending to an existing one, since we don’t keep track of which tree nodes are new or modified. Instead the tree is reconstructed during serialization. Differential Revision: https://phab.mercurial-scm.org/D11520
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48083
bf8837e3d7ce dirstate: Remove the flat Rust DirstateMap implementation
Simon Sapin <simon.sapin@octobus.net>
parents: 47292
diff changeset
     1
#testcases dirstate-v1 dirstate-v2
47143
93eb6c8035a9 dirstate-tree: Add a dirstate-v1-tree variant of some tests
Simon Sapin <simon.sapin@octobus.net>
parents: 45794
diff changeset
     2
47292
6763913fa175 dirstate-v2: Add a variant of some tests, that uses the new format
Simon Sapin <simon.sapin@octobus.net>
parents: 47143
diff changeset
     3
#if dirstate-v2
6763913fa175 dirstate-v2: Add a variant of some tests, that uses the new format
Simon Sapin <simon.sapin@octobus.net>
parents: 47143
diff changeset
     4
  $ echo '[format]' >> $HGRCPATH
6763913fa175 dirstate-v2: Add a variant of some tests, that uses the new format
Simon Sapin <simon.sapin@octobus.net>
parents: 47143
diff changeset
     5
  $ 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: 47143
diff changeset
     6
#endif
6763913fa175 dirstate-v2: Add a variant of some tests, that uses the new format
Simon Sapin <simon.sapin@octobus.net>
parents: 47143
diff changeset
     7
32141
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
     8
  $ hg init repo
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
     9
  $ cd repo
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    10
  $ echo a > a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    11
  $ hg add a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    12
  $ hg commit -m test
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    13
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    14
Do we ever miss a sub-second change?:
6327
6d952dc2abc9 dirstate: refactor granularity code, add a test
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    16
  $ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    17
  >     hg co -qC 0
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    18
  >     echo b > a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    19
  >     hg st
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    20
  > done
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    21
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    22
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    23
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    24
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    25
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    26
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    27
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    28
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    29
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    30
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    31
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    32
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    33
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    34
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    35
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    36
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    37
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    38
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    39
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    40
  M a
6327
6d952dc2abc9 dirstate: refactor granularity code, add a test
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    41
32141
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    42
  $ echo test > b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    43
  $ mkdir dir1
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    44
  $ echo test > dir1/c
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    45
  $ echo test > d
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    46
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    47
  $ echo test > e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    48
#if execbit
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    49
A directory will typically have the execute bit -- make sure it doesn't get
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    50
confused with a file with the exec bit set
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    51
  $ chmod +x e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    52
#endif
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    53
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    54
  $ hg add b dir1 d e
35400
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 33577
diff changeset
    55
  adding dir1/c
32141
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    56
  $ hg commit -m test2
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    57
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    58
  $ cat >> $TESTTMP/dirstaterace.py << EOF
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    59
  > from mercurial import (
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    60
  >     context,
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    61
  >     extensions,
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    62
  > )
41071
28a4fb793ba1 extensions: deprecate extsetup without a `ui` argument (API)
Matt Harbison <matt_harbison@yahoo.com>
parents: 40296
diff changeset
    63
  > def extsetup(ui):
32141
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    64
  >     extensions.wrapfunction(context.workingctx, '_checklookup', overridechecklookup)
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    65
  > def overridechecklookup(orig, self, files):
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    66
  >     # make an update that changes the dirstate from underneath
40296
e787d97e90ad py3: fix test-dirstate-race.t
Mark Thomas <mbthomas@fb.com>
parents: 35400
diff changeset
    67
  >     self._repo.ui.system(br"sh '$TESTTMP/dirstaterace.sh'",
32771
627eaab1ad07 tests: factor external procedures out for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32698
diff changeset
    68
  >                          cwd=self._repo.root)
32141
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    69
  >     return orig(self, files)
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    70
  > EOF
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    71
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    72
  $ hg debugrebuilddirstate
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    73
  $ hg debugdirstate
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    74
  n   0         -1 unset               a
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    75
  n   0         -1 unset               b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    76
  n   0         -1 unset               d
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    77
  n   0         -1 unset               dir1/c
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    78
  n   0         -1 unset               e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    79
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    80
XXX Note that this returns M for files that got replaced by directories. This is
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    81
definitely a bug, but the fix for that is hard and the next status run is fine
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    82
anyway.
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    83
32771
627eaab1ad07 tests: factor external procedures out for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32698
diff changeset
    84
  $ cat > $TESTTMP/dirstaterace.sh <<EOF
627eaab1ad07 tests: factor external procedures out for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32698
diff changeset
    85
  > rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e
627eaab1ad07 tests: factor external procedures out for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32698
diff changeset
    86
  > EOF
627eaab1ad07 tests: factor external procedures out for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32698
diff changeset
    87
627eaab1ad07 tests: factor external procedures out for portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32698
diff changeset
    88
  $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py
32141
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    89
  M d
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    90
  M e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    91
  ! b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    92
  ! dir1/c
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    93
  $ hg debugdirstate
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    94
  n 644          2 * a (glob)
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    95
  n   0         -1 unset               b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    96
  n   0         -1 unset               d
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    97
  n   0         -1 unset               dir1/c
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    98
  n   0         -1 unset               e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    99
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
   100
  $ hg status
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
   101
  ! b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
   102
  ! d
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
   103
  ! dir1/c
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
   104
  ! e
32772
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   105
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   106
  $ rmdir d e
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   107
  $ hg update -C -q .
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   108
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   109
Test that dirstate changes aren't written out at the end of "hg
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   110
status", if .hg/dirstate is already changed simultaneously before
32831
add613cddcb6 workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents: 32821
diff changeset
   111
acquisition of wlock in workingctx._poststatusfixup().
32772
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   112
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   113
This avoidance is important to keep consistency of dirstate in race
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   114
condition (see issue5584 for detail).
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   115
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   116
  $ hg parents -q
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   117
  1:* (glob)
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   118
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   119
  $ hg debugrebuilddirstate
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   120
  $ hg debugdirstate
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   121
  n   0         -1 unset               a
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   122
  n   0         -1 unset               b
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   123
  n   0         -1 unset               d
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   124
  n   0         -1 unset               dir1/c
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   125
  n   0         -1 unset               e
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   126
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   127
  $ cat > $TESTTMP/dirstaterace.sh <<EOF
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   128
  > # This script assumes timetable of typical issue5584 case below:
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   129
  > #
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   130
  > # 1. "hg status" loads .hg/dirstate
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   131
  > # 2. "hg status" confirms clean-ness of FILE
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   132
  > # 3. "hg update -C 0" updates the working directory simultaneously
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   133
  > #    (FILE is removed, and FILE is dropped from .hg/dirstate)
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   134
  > # 4. "hg status" acquires wlock
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   135
  > #    (.hg/dirstate is re-loaded = no FILE entry in dirstate)
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   136
  > # 5. "hg status" marks FILE in dirstate as clean
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   137
  > #    (FILE entry is added to in-memory dirstate)
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   138
  > # 6. "hg status" writes dirstate changes into .hg/dirstate
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   139
  > #    (FILE entry is written into .hg/dirstate)
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   140
  > #
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   141
  > # To reproduce similar situation easily and certainly, #2 and #3
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   142
  > # are swapped.  "hg cat" below ensures #2 on "hg status" side.
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   143
  > 
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   144
  > hg update -q -C 0
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   145
  > hg cat -r 1 b > b
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   146
  > EOF
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   147
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   148
"hg status" below should excludes "e", of which exec flag is set, for
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   149
portability of test scenario, because unsure but missing "e" is
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   150
treated differently in _checklookup() according to runtime platform.
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   151
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   152
- "missing(!)" on POSIX, "pctx[f].cmp(self[f])" raises ENOENT
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   153
- "modified(M)" on Windows, "self.flags(f) != pctx.flags(f)" is True
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   154
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   155
  $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug -X path:e
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   156
  skip updating dirstate: identity mismatch
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   157
  M a
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   158
  ! d
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   159
  ! dir1/c
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   160
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   161
  $ hg parents -q
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   162
  0:* (glob)
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   163
  $ hg files
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   164
  a
dc7efa2826e4 context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32771
diff changeset
   165
  $ hg debugdirstate
32821
f40eec7af044 test-dirstate-race: back out changeset c82fa7efcbc8
Siddharth Agarwal <sid0@fb.com>
parents: 32791
diff changeset
   166
  n * * * a (glob)
32834
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   167
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   168
  $ rm b
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   169
32835
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   170
#if fsmonitor
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   171
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   172
Create fsmonitor state.
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   173
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   174
  $ hg status
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   175
  $ f --type .hg/fsmonitor.state
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   176
  .hg/fsmonitor.state: file
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   177
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   178
Test that invalidating fsmonitor state in the middle (which doesn't require the
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   179
wlock) causes the fsmonitor update to be skipped.
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   180
hg debugrebuilddirstate ensures that the dirstaterace hook will be called, but
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   181
it also invalidates the fsmonitor state. So back it up and restore it.
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   182
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   183
  $ mv .hg/fsmonitor.state .hg/fsmonitor.state.tmp
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   184
  $ hg debugrebuilddirstate
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   185
  $ mv .hg/fsmonitor.state.tmp .hg/fsmonitor.state
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   186
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   187
  $ cat > $TESTTMP/dirstaterace.sh <<EOF
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   188
  > rm .hg/fsmonitor.state
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   189
  > EOF
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   190
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   191
  $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   192
  skip updating fsmonitor.state: identity mismatch
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   193
  $ f .hg/fsmonitor.state
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   194
  .hg/fsmonitor.state: file not found
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   195
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   196
#endif
1b25c648d5b7 fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32834
diff changeset
   197
32834
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   198
Set up a rebase situation for issue5581.
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   199
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   200
  $ echo c2 > a
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   201
  $ echo c2 > b
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   202
  $ hg add b
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   203
  $ hg commit -m c2
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   204
  created new head
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   205
  $ echo c3 >> a
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   206
  $ hg commit -m c3
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   207
  $ hg update 2
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   208
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   209
  $ echo c4 >> a
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   210
  $ echo c4 >> b
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   211
  $ hg commit -m c4
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   212
  created new head
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   213
33577
34a8ef358c93 test-dirstate-race: hide irrelevant hg status output
Siddharth Agarwal <sid0@fb.com>
parents: 33146
diff changeset
   214
Configure a merge tool that runs status in the middle of the rebase. The goal of
34a8ef358c93 test-dirstate-race: hide irrelevant hg status output
Siddharth Agarwal <sid0@fb.com>
parents: 33146
diff changeset
   215
the status call is to trigger a potential bug if fsmonitor's state is written
34a8ef358c93 test-dirstate-race: hide irrelevant hg status output
Siddharth Agarwal <sid0@fb.com>
parents: 33146
diff changeset
   216
even though the wlock is held by another process. The output of 'hg status' in
34a8ef358c93 test-dirstate-race: hide irrelevant hg status output
Siddharth Agarwal <sid0@fb.com>
parents: 33146
diff changeset
   217
the merge tool goes to /dev/null because we're more interested in the results of
34a8ef358c93 test-dirstate-race: hide irrelevant hg status output
Siddharth Agarwal <sid0@fb.com>
parents: 33146
diff changeset
   218
'hg status' run after the rebase.
32834
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   219
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   220
  $ cat >> $TESTTMP/mergetool-race.sh << EOF
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   221
  > echo "custom merge tool"
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   222
  > printf "c2\nc3\nc4\n" > \$1
33577
34a8ef358c93 test-dirstate-race: hide irrelevant hg status output
Siddharth Agarwal <sid0@fb.com>
parents: 33146
diff changeset
   223
  > hg --cwd "$TESTTMP/repo" status > /dev/null
32834
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   224
  > echo "custom merge tool end"
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   225
  > EOF
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   226
  $ cat >> $HGRCPATH << EOF
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   227
  > [extensions]
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   228
  > rebase =
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   229
  > [merge-tools]
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   230
  > test.executable=sh
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   231
  > test.args=$TESTTMP/mergetool-race.sh \$output
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   232
  > EOF
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   233
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   234
  $ hg rebase -s . -d 3 --tool test
45794
f90a5c211251 rebase: change and standarize template for rebase's one-line summary
Martin von Zweigbergk <martinvonz@google.com>
parents: 41071
diff changeset
   235
  rebasing 4:b08445fd6b2a tip "c4"
32834
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   236
  merging a
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   237
  custom merge tool
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   238
  custom merge tool end
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   239
  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/* (glob)
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   240
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   241
This hg status should be empty, whether or not fsmonitor is enabled (issue5581).
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   242
15e85dded933 fsmonitor: write state with wlock held and dirstate unchanged (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents: 32831
diff changeset
   243
  $ hg status