| 1 |
#testcases dirstate-v1 dirstate-v2 |
| 2 |
|
| 3 |
#if dirstate-v2 |
| 4 |
$ cat >> $HGRCPATH << EOF |
| 5 |
> [format] |
| 6 |
> use-dirstate-v2=1 |
| 7 |
> [storage] |
| 8 |
> dirstate-v2.slow-path=allow |
| 9 |
> EOF |
| 10 |
#endif |
| 11 |
|
| 12 |
Checking the size/permissions/file-type of files stored in the |
| 13 |
dirstate after an update where the files are changed concurrently |
| 14 |
outside of hg's control. |
| 15 |
|
| 16 |
$ hg init repo |
| 17 |
$ cd repo |
| 18 |
$ echo a > a |
| 19 |
$ hg commit -qAm _ |
| 20 |
$ echo aa > a |
| 21 |
$ hg commit -m _ |
| 22 |
# this sleep is there to ensure current time has -at-least- one second away |
| 23 |
# from the current time. It ensure the mtime is not ambiguous. If the test |
| 24 |
# "sleep" longer this will be fine. |
| 25 |
# It is not used to synchronise parallele operation so it is "fine" to use it. |
| 26 |
$ sleep 1 |
| 27 |
$ hg status |
| 28 |
|
| 29 |
$ hg debugdirstate --no-dates |
| 30 |
n 644 3 (set |unset) a (re) |
| 31 |
|
| 32 |
$ cat >> $TESTTMP/dirstaterace.py << EOF |
| 33 |
> import time |
| 34 |
> from mercurial import ( |
| 35 |
> commit, |
| 36 |
> extensions, |
| 37 |
> ) |
| 38 |
> from mercurial.merge_utils import update |
| 39 |
> def extsetup(ui): |
| 40 |
> extensions.wrapfunction(update, 'apply_updates', wrap(0)) |
| 41 |
> extensions.wrapfunction(commit, 'commitctx', wrap(1)) |
| 42 |
> def wrap(duration): |
| 43 |
> def new(orig, *args, **kwargs): |
| 44 |
> res = orig(*args, **kwargs) |
| 45 |
> with open("a", "w"): |
| 46 |
> pass # just truncate the file |
| 47 |
> time.sleep(duration) |
| 48 |
> return res |
| 49 |
> return new |
| 50 |
> EOF |
| 51 |
|
| 52 |
Do an update where file 'a' is changed between hg writing it to disk |
| 53 |
and hg writing the dirstate. The dirstate is correct nonetheless, and |
| 54 |
so hg status correctly shows a as clean. |
| 55 |
|
| 56 |
$ hg up -r 0 --config extensions.race=$TESTTMP/dirstaterace.py |
| 57 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 58 |
$ hg debugdirstate --no-dates |
| 59 |
n 644 2 (set |unset) a (re) |
| 60 |
$ echo a > a; hg status; hg diff |
| 61 |
|
| 62 |
Do a commit where file 'a' is changed between hg committing its new |
| 63 |
revision into the repository, and the writing of the dirstate. |
| 64 |
|
| 65 |
This used to results in a corrupted dirstate (size did not match committed size). |
| 66 |
|
| 67 |
$ echo aaa > a; hg commit -qm _ |
| 68 |
$ hg merge -qr 1; hg resolve -m; rm a.orig |
| 69 |
warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
| 70 |
(no more unresolved files) |
| 71 |
$ cat a |
| 72 |
<<<<<<< working copy: be46f74ce38d - test: _ |
| 73 |
aaa |
| 74 |
======= |
| 75 |
aa |
| 76 |
>>>>>>> merge rev: eb3fc6c17aa3 - test: _ |
| 77 |
$ hg debugdirstate --no-dates |
| 78 |
m 0 -2 (set |unset) a (re) |
| 79 |
$ hg commit -m _ --config extensions.race=$TESTTMP/dirstaterace.py |
| 80 |
$ hg debugdirstate --no-dates |
| 81 |
n 0 -1 unset a |
| 82 |
$ cat a | wc -c |
| 83 |
*0 (re) |
| 84 |
$ hg cat -r . a | wc -c |
| 85 |
*105 (re) |
| 86 |
$ hg status; hg diff --stat |
| 87 |
M a |
| 88 |
a | 5 ----- |
| 89 |
1 files changed, 0 insertions(+), 5 deletions(-) |