tests/test-dirstate-race.t
author Siddharth Agarwal <sid0@fb.com>
Fri, 02 Jun 2017 22:27:52 -0700
branchstable
changeset 32651 c850f0ed54c1
parent 12279 28e2e3804f2e
child 32678 bcb6684d144b
permissions -rw-r--r--
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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32651
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
     1
  $ hg init repo
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
     2
  $ cd repo
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
     3
  $ echo a > a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
     4
  $ hg add a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
     5
  $ hg commit -m test
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
     6
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
     7
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
     8
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
     9
  $ 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
    10
  >     hg co -qC 0
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    11
  >     echo b > a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    12
  >     hg st
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    13
  > done
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    14
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    15
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    16
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    17
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    18
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    19
  M a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 6327
diff changeset
    20
  M a
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
6327
6d952dc2abc9 dirstate: refactor granularity code, add a test
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    34
32651
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    35
  $ echo test > b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    36
  $ mkdir dir1
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    37
  $ echo test > dir1/c
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    38
  $ echo test > d
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    39
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    40
  $ echo test > e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    41
#if execbit
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    42
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
    43
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
    44
  $ chmod +x e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    45
#endif
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
  $ hg add b dir1 d e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    48
  adding dir1/c
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    49
  $ hg commit -m test2
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    50
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    51
  $ cat >> $TESTTMP/dirstaterace.py << EOF
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    52
  > from mercurial import (
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    53
  >     context,
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    54
  >     extensions,
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    55
  > )
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    56
  > def extsetup():
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    57
  >     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
    58
  > def overridechecklookup(orig, self, files):
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    59
  >     # make an update that changes the dirstate from underneath
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    60
  >     self._repo.ui.system(self._repo.ui.config('dirstaterace', 'command'), cwd=self._repo.root)
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    61
  >     return orig(self, files)
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    62
  > EOF
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    63
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    64
  $ hg debugrebuilddirstate
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    65
  $ hg debugdirstate
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    66
  n   0         -1 unset               a
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    67
  n   0         -1 unset               b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    68
  n   0         -1 unset               d
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    69
  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
    70
  n   0         -1 unset               e
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
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
    73
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
    74
anyway.
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    75
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    76
  $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py \
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    77
  >   --config dirstaterace.command='rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e'
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    78
  M d
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    79
  M e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    80
  ! b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    81
  ! dir1/c
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    82
  $ hg debugdirstate
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    83
  n 644          2 * a (glob)
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    84
  n   0         -1 unset               b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    85
  n   0         -1 unset               d
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    86
  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
    87
  n   0         -1 unset               e
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    88
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    89
  $ hg status
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    90
  ! b
c850f0ed54c1 status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents: 12279
diff changeset
    91
  ! d
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
  ! e