tests/test-dirstate.t
author Simon Sapin <simon.sapin@octobus.net>
Tue, 09 Nov 2021 19:55:46 +0100
changeset 48384 b7fde9237c92
parent 48295 bf11ff22a9af
child 48468 000130cfafb6
permissions -rw-r--r--
rhg: Enable `rhg status` in most tests This subcommand is disabled by default because of bugs that make some test fail. Enable it in the rest of the tests in order to avoid regressing them. As with `RHG_ON_UNSUPPORTED`, an environment variable is used instead of a configuration file and `HGRCPATH` because some tests override `HGRCPATH`. Running `unset RHG_STATUS` at the start of a test restores the default of `rhg status` being disabled. Hopefully it can be increasingly removed from test files as bugs are fixed. Differential Revision: https://phab.mercurial-scm.org/D11756
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: 45681
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
48247
5c567aca080d dirstate-v2: add an option to prevent unintentional slow dirstate-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48235
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: 48235
diff changeset
     5
  > [format]
48295
bf11ff22a9af dirstate-v2: freeze the on-disk format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48247
diff changeset
     6
  > exp-rc-dirstate-v2=1
48247
5c567aca080d dirstate-v2: add an option to prevent unintentional slow dirstate-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48235
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: 48235
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: 48235
diff changeset
     9
  > EOF
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
    10
#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
    11
48384
b7fde9237c92 rhg: Enable `rhg status` in most tests
Simon Sapin <simon.sapin@octobus.net>
parents: 48295
diff changeset
    12
TODO: fix rhg bugs that make this test fail when status is enabled
b7fde9237c92 rhg: Enable `rhg status` in most tests
Simon Sapin <simon.sapin@octobus.net>
parents: 48295
diff changeset
    13
  $ unset RHG_STATUS
b7fde9237c92 rhg: Enable `rhg status` in most tests
Simon Sapin <simon.sapin@octobus.net>
parents: 48295
diff changeset
    14
b7fde9237c92 rhg: Enable `rhg status` in most tests
Simon Sapin <simon.sapin@octobus.net>
parents: 48295
diff changeset
    15
11888
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    16
------ Test dirstate._dirs refcounting
7096
6dab29f6df37 dirstate._dirs: fix refcounting broken by 7dfac37cfabf
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    17
11887
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    18
  $ hg init t
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    19
  $ cd t
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    20
  $ mkdir -p a/b/c/d
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    21
  $ touch a/b/c/d/x
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    22
  $ touch a/b/c/d/y
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    23
  $ touch a/b/c/d/z
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    24
  $ hg ci -Am m
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    25
  adding a/b/c/d/x
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    26
  adding a/b/c/d/y
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    27
  adding a/b/c/d/z
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    28
  $ hg mv a z
35400
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 33972
diff changeset
    29
  moving a/b/c/d/x to z/b/c/d/x
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 33972
diff changeset
    30
  moving a/b/c/d/y to z/b/c/d/y
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 33972
diff changeset
    31
  moving a/b/c/d/z to z/b/c/d/z
17095
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    32
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    33
Test name collisions
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    34
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    35
  $ rm z/b/c/d/x
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    36
  $ mkdir z/b/c/d/x
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    37
  $ touch z/b/c/d/x/y
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    38
  $ hg add z/b/c/d/x/y
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    39
  abort: file 'z/b/c/d/x' in dirstate clashes with 'z/b/c/d/x/y'
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    40
  [255]
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    41
  $ rm -rf z/b/c/d
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    42
  $ touch z/b/c/d
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    43
  $ hg add z/b/c/d
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    44
  abort: directory 'z/b/c/d' already in dirstate
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    45
  [255]
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    46
11888
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    47
  $ cd ..
11887
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    48
12399
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 11888
diff changeset
    49
Issue1790: dirstate entry locked into unset if file mtime is set into
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 11888
diff changeset
    50
the future
11888
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    51
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    52
Prepare test repo:
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    53
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    54
  $ hg init u
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    55
  $ cd u
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    56
  $ echo a > a
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    57
  $ hg add
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    58
  adding a
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    59
  $ hg ci -m1
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    60
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    61
Set mtime of a into the future:
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    62
48126
73bcfde21fc2 dirstate: push back the future a bit in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48083
diff changeset
    63
  $ touch -t 203101011200 a
11888
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    64
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    65
Status must not set a's entry to unset (issue1790):
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    66
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    67
  $ hg status
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    68
  $ hg debugstate
48126
73bcfde21fc2 dirstate: push back the future a bit in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48083
diff changeset
    69
  n 644          2 2031-01-01 12:00:00 a
17733
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    70
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    71
Test modulo storage/comparison of absurd dates:
11888
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    72
19092
8c560ad1cdc4 tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents: 17737
diff changeset
    73
#if no-aix
17733
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    74
  $ touch -t 195001011200 a
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    75
  $ hg st
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    76
  $ hg debugstate
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    77
  n 644          2 2018-01-19 15:14:08 a
19092
8c560ad1cdc4 tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents: 17737
diff changeset
    78
#endif
22406
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    79
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    80
Verify that exceptions during a dirstate change leave the dirstate
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    81
coherent (issue4353)
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    82
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    83
  $ cat > ../dirstateexception.py <<EOF
33972
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    84
  > from __future__ import absolute_import
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    85
  > from mercurial import (
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    86
  >   error,
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    87
  >   extensions,
44915
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 42472
diff changeset
    88
  >   mergestate as mergestatemod,
33972
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    89
  > )
22406
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    90
  > 
42472
87a34c767384 merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 35400
diff changeset
    91
  > def wraprecordupdates(*args):
45681
a736ab681b78 errors: stop passing non-strings to Abort's constructor
Martin von Zweigbergk <martinvonz@google.com>
parents: 44915
diff changeset
    92
  >     raise error.Abort(b"simulated error while recording dirstateupdates")
22406
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    93
  > 
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    94
  > def reposetup(ui, repo):
44915
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 42472
diff changeset
    95
  >     extensions.wrapfunction(mergestatemod, 'recordupdates',
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 42472
diff changeset
    96
  >                             wraprecordupdates)
22406
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    97
  > EOF
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    98
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    99
  $ hg rm a
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   100
  $ hg commit -m 'rm a'
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   101
  $ echo "[extensions]" >> .hg/hgrc
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   102
  $ echo "dirstateex=../dirstateexception.py" >> .hg/hgrc
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   103
  $ hg up 0
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   104
  abort: simulated error while recording dirstateupdates
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   105
  [255]
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   106
  $ hg log -r . -T '{rev}\n'
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   107
  1
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   108
  $ hg status
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
   109
  ? a