Mercurial > hg
annotate tests/test-merge9.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 | 8e6d5b7317e6 |
children | 41ef02ba329b |
rev | line source |
---|---|
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
1 test that we don't interrupt the merge session if |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
2 a file-level merge failed |
4682
dc5920ea12f8
merge: fix small bug with a failed merge across a rename
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
3 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
4 $ hg init repo |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
5 $ cd repo |
4682
dc5920ea12f8
merge: fix small bug with a failed merge across a rename
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
6 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
7 $ echo foo > foo |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
8 $ echo a > bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
9 $ hg ci -Am 'add foo' |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
10 adding bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
11 adding foo |
4682
dc5920ea12f8
merge: fix small bug with a failed merge across a rename
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
12 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
13 $ hg mv foo baz |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
14 $ echo b >> bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
15 $ echo quux > quux1 |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
16 $ hg ci -Am 'mv foo baz' |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
17 adding quux1 |
4682
dc5920ea12f8
merge: fix small bug with a failed merge across a rename
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
18 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
19 $ hg up -qC 0 |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
20 $ echo >> foo |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
21 $ echo c >> bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
22 $ echo quux > quux2 |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
23 $ hg ci -Am 'change foo' |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
24 adding quux2 |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
25 created new head |
4682
dc5920ea12f8
merge: fix small bug with a failed merge across a rename
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
26 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
27 test with the rename on the remote side |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
28 $ HGMERGE=false hg merge |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
29 merging bar |
26618
8e6d5b7317e6
merge.mergestate: perform all premerges before any merges (BC)
Siddharth Agarwal <sid0@fb.com>
parents:
26614
diff
changeset
|
30 merging foo and baz to baz |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
31 merging bar failed! |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
32 1 files updated, 1 files merged, 0 files removed, 1 files unresolved |
12314
f2daa6ab514a
merge: suggest 'hg up -C .' for discarding changes, not 'hg up -C'
Brodie Rao <brodie@bitheap.org>
parents:
11982
diff
changeset
|
33 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12314
diff
changeset
|
34 [1] |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
35 $ hg resolve -l |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
36 U bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
37 R baz |
4682
dc5920ea12f8
merge: fix small bug with a failed merge across a rename
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
38 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
39 test with the rename on the local side |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
40 $ hg up -C 1 |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
41 3 files updated, 0 files merged, 1 files removed, 0 files unresolved |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
42 $ HGMERGE=false hg merge |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
43 merging bar |
26618
8e6d5b7317e6
merge.mergestate: perform all premerges before any merges (BC)
Siddharth Agarwal <sid0@fb.com>
parents:
26614
diff
changeset
|
44 merging baz and foo to baz |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
45 merging bar failed! |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
46 1 files updated, 1 files merged, 0 files removed, 1 files unresolved |
12314
f2daa6ab514a
merge: suggest 'hg up -C .' for discarding changes, not 'hg up -C'
Brodie Rao <brodie@bitheap.org>
parents:
11982
diff
changeset
|
47 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12314
diff
changeset
|
48 [1] |
6518 | 49 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
50 show unresolved |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
51 $ hg resolve -l |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
52 U bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
53 R baz |
6518 | 54 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
55 unmark baz |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
56 $ hg resolve -u baz |
6518 | 57 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
58 show |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
59 $ hg resolve -l |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
60 U bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
61 U baz |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
62 $ hg st |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
63 M bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
64 M baz |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
65 M quux2 |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
66 ? bar.orig |
6518 | 67 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
68 re-resolve baz |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
69 $ hg resolve baz |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
70 merging baz and foo to baz |
6518 | 71 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
72 after resolve |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
73 $ hg resolve -l |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
74 U bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
75 R baz |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
76 |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
77 resolve all warning |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
78 $ hg resolve |
21940
9209c02f1f25
resolve: report no argument warning using a hint
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
16913
diff
changeset
|
79 abort: no files or directories specified |
26352
e635bc9bb7d9
resolve: consistently describe re-merge + unresolved
timeless@mozdev.org
parents:
21940
diff
changeset
|
80 (use --all to re-merge all unresolved files) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12314
diff
changeset
|
81 [255] |
7527
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
6518
diff
changeset
|
82 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
83 resolve all |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
84 $ hg resolve -a |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
85 merging bar |
26614
ef1eb6df7071
simplemerge: move conflict warning message to filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26352
diff
changeset
|
86 warning: conflicts while merging bar! (edit, then use 'hg resolve --mark') |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12314
diff
changeset
|
87 [1] |
6518 | 88 |
11982
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
89 after |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
90 $ hg resolve -l |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
91 U bar |
56d9b73487ff
tests: unify test-merge9
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
8167
diff
changeset
|
92 R baz |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
15501
diff
changeset
|
93 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
15501
diff
changeset
|
94 $ cd .. |