Mercurial > hg
annotate tests/test-586.t @ 26631:e077ce385609
localrepo: restore dirstate to one before rollbacking if not parent-gone
'localrepository.rollback()' explicilty restores dirstate, only if at
least one of current parents of the working directory is removed at
rollbacking (a.k.a "parent-gone").
After DirstateTransactionPlan, 'dirstate.write()' will cause marking
'.hg/dirstate' as a file to be restored at rollbacking.
https://mercurial.selenic.com/wiki/DirstateTransactionPlan
Then, 'transaction.rollback()' restores '.hg/dirstate' regardless of
parents of the working directory at that time, and this causes
unexpected dirstate changes if not "parent-gone" (e.g. "hg update" to
another branch after "hg commit" or so, then "hg rollback").
To avoid such situation, this patch restores dirstate to one before
rollbacking if not "parent-gone".
before:
b1. restore dirstate explicitly, if "parent-gone"
after:
a1. save dirstate before actual rollbacking via dirstateguard
a2. restore dirstate via 'transaction.rollback()'
a3. if "parent-gone"
- discard backup (a1)
- restore dirstate from 'undo.dirstate'
a4. otherwise, restore dirstate from backup (a1)
Even though restoring dirstate at (a3) after (a2) seems redundant,
this patch keeps this existing code path, because:
- it isn't ensured that 'dirstate.write()' was invoked at least once
while transaction running
If not, '.hg/dirstate' isn't restored at (a2).
In addition to it, rude 3rd party extension invoking
'dirstate.write()' without 'repo' while transaction running (see
subsequent patches for detail) may break consistency of a file
backup-ed by transaction.
- this patch mainly focuses on changes for DirstateTransactionPlan
Restoring dirstate at (a3) itself should be cheaper enough than
rollbacking itself. Redundancy will be removed in next step.
Newly added test is almost meaningless at this point. It will be used
to detect regression while implementing delayed dirstate write out.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 13 Oct 2015 12:25:43 -0700 |
parents | f2719b387380 |
children |
rev | line source |
---|---|
12399
4fee1fd3de9a
tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents:
11846
diff
changeset
|
1 Issue586: removing remote files after merge appears to corrupt the |
4fee1fd3de9a
tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents:
11846
diff
changeset
|
2 dirstate |
4535
720ae5085ee3
commit: fix bug where dirstate for removed file is confused
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 |
11846 | 4 $ hg init a |
5 $ cd a | |
6 $ echo a > a | |
7 $ hg ci -Ama | |
8 adding a | |
9 | |
10 $ hg init ../b | |
11 $ cd ../b | |
12 $ echo b > b | |
13 $ hg ci -Amb | |
14 adding b | |
4535
720ae5085ee3
commit: fix bug where dirstate for removed file is confused
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
15 |
11846 | 16 $ hg pull -f ../a |
17 pulling from ../a | |
18 searching for changes | |
19 warning: repository is unrelated | |
13742
7abab875e647
discovery: avoid discovery when local graph is a subset of remote
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12399
diff
changeset
|
20 requesting all changes |
11846 | 21 adding changesets |
22 adding manifests | |
23 adding file changes | |
24 added 1 changesets with 1 changes to 1 files (+1 heads) | |
25 (run 'hg heads' to see heads, 'hg merge' to merge) | |
26 $ hg merge | |
27 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
28 (branch merge, don't forget to commit) | |
29 $ hg rm -f a | |
30 $ hg ci -Amc | |
4535
720ae5085ee3
commit: fix bug where dirstate for removed file is confused
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
31 |
11846 | 32 $ hg st -A |
33 C b | |
34 $ cd .. | |
35 | |
12399
4fee1fd3de9a
tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents:
11846
diff
changeset
|
36 Issue1433: Traceback after two unrelated pull, two move, a merge and |
4fee1fd3de9a
tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents:
11846
diff
changeset
|
37 a commit (related to issue586) |
4535
720ae5085ee3
commit: fix bug where dirstate for removed file is confused
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 |
11846 | 39 create test repos |
40 | |
41 $ hg init repoa | |
42 $ touch repoa/a | |
43 $ hg -R repoa ci -Am adda | |
44 adding a | |
7564
f1af59451c0c
localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents:
4535
diff
changeset
|
45 |
11846 | 46 $ hg init repob |
47 $ touch repob/b | |
48 $ hg -R repob ci -Am addb | |
49 adding b | |
7564
f1af59451c0c
localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents:
4535
diff
changeset
|
50 |
11846 | 51 $ hg init repoc |
52 $ cd repoc | |
53 $ hg pull ../repoa | |
54 pulling from ../repoa | |
55 requesting all changes | |
56 adding changesets | |
57 adding manifests | |
58 adding file changes | |
59 added 1 changesets with 1 changes to 1 files | |
60 (run 'hg update' to get a working copy) | |
61 $ hg update | |
62 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
63 $ mkdir tst | |
64 $ hg mv * tst | |
65 $ hg ci -m "import a in tst" | |
66 $ hg pull -f ../repob | |
67 pulling from ../repob | |
68 searching for changes | |
69 warning: repository is unrelated | |
13742
7abab875e647
discovery: avoid discovery when local graph is a subset of remote
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12399
diff
changeset
|
70 requesting all changes |
11846 | 71 adding changesets |
72 adding manifests | |
73 adding file changes | |
74 added 1 changesets with 1 changes to 1 files (+1 heads) | |
75 (run 'hg heads' to see heads, 'hg merge' to merge) | |
7564
f1af59451c0c
localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents:
4535
diff
changeset
|
76 |
11846 | 77 merge both repos |
7564
f1af59451c0c
localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents:
4535
diff
changeset
|
78 |
11846 | 79 $ hg merge |
80 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
81 (branch merge, don't forget to commit) | |
82 $ mkdir src | |
7564
f1af59451c0c
localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents:
4535
diff
changeset
|
83 |
11846 | 84 move b content |
85 | |
86 $ hg mv b src | |
87 $ hg ci -m "import b in src" | |
88 $ hg manifest | |
89 src/b | |
90 tst/a | |
91 | |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
13742
diff
changeset
|
92 $ cd .. |