Mercurial > hg
annotate tests/test-merge-revert2.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 | ef1eb6df7071 |
children | ce3a133f71b3 |
rev | line source |
---|---|
12279 | 1 $ hg init |
2 | |
3 $ echo "added file1" > file1 | |
4 $ echo "another line of text" >> file1 | |
5 $ echo "added file2" > file2 | |
6 $ hg add file1 file2 | |
7 $ hg commit -m "added file1 and file2" | |
8 | |
9 $ echo "changed file1" >> file1 | |
10 $ hg commit -m "changed file1" | |
11 | |
12 $ hg -q log | |
13 1:dfab7f3c2efb | |
14 0:c3fa057dd86f | |
15 $ hg id | |
16 dfab7f3c2efb tip | |
17 | |
18 $ hg update -C 0 | |
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
20 $ hg id | |
21 c3fa057dd86f | |
22 | |
23 $ echo "changed file1" >> file1 | |
24 $ hg id | |
25 c3fa057dd86f+ | |
26 | |
27 $ hg revert --no-backup --all | |
28 reverting file1 | |
29 $ hg diff | |
30 $ hg status | |
31 $ hg id | |
32 c3fa057dd86f | |
33 | |
34 $ hg update | |
35 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
36 $ hg diff | |
37 $ hg status | |
38 $ hg id | |
39 dfab7f3c2efb tip | |
40 | |
41 $ hg update -C 0 | |
42 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
43 $ echo "changed file1 different" >> file1 | |
792
49ec802b4a16
Added tests for bug with three-way-merging of old tip, tip and cwd.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
44 |
12279 | 45 $ hg update |
46 merging file1 | |
26614
ef1eb6df7071
simplemerge: move conflict warning message to filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
21693
diff
changeset
|
47 warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') |
12279 | 48 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
49 use 'hg resolve' to retry unresolved file merges | |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12279
diff
changeset
|
50 [1] |
12279 | 51 |
52 $ hg diff --nodates | |
53 diff -r dfab7f3c2efb file1 | |
54 --- a/file1 | |
55 +++ b/file1 | |
56 @@ -1,3 +1,7 @@ | |
57 added file1 | |
58 another line of text | |
21693
9c35f3a8cac4
merge: drop the quotes around commit description
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21537
diff
changeset
|
59 +<<<<<<< working copy: c3fa057dd86f - test: added file1 and file2 |
12279 | 60 +changed file1 different |
61 +======= | |
62 changed file1 | |
21693
9c35f3a8cac4
merge: drop the quotes around commit description
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21537
diff
changeset
|
63 +>>>>>>> destination: dfab7f3c2efb - test: changed file1 |
792
49ec802b4a16
Added tests for bug with three-way-merging of old tip, tip and cwd.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
64 |
12279 | 65 $ hg status |
66 M file1 | |
67 ? file1.orig | |
68 $ hg id | |
69 dfab7f3c2efb+ tip | |
70 | |
71 $ hg revert --no-backup --all | |
72 reverting file1 | |
73 $ hg diff | |
74 $ hg status | |
75 ? file1.orig | |
76 $ hg id | |
77 dfab7f3c2efb tip | |
78 | |
79 $ hg revert -r tip --no-backup --all | |
80 $ hg diff | |
81 $ hg status | |
82 ? file1.orig | |
83 $ hg id | |
84 dfab7f3c2efb tip | |
85 | |
86 $ hg update -C | |
87 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
88 $ hg diff | |
89 $ hg status | |
90 ? file1.orig | |
91 $ hg id | |
92 dfab7f3c2efb tip | |
93 |