comparison tests/test-evolve-interrupted.t @ 4848:535ab2609e45

cmdstate: introduce a "saver" contextmanager and use it in place of save() Previously, the state was only saved in some paths out of these functions. This can be problematic, if the user ctrl-c's (or `kill -9`'s) the process, or we exit out of `relocate` for anything besides the "expected" reason, we won't record that we were in the middle of an evolve. One of our users has discovered that this leaves hg in a weird state; the user did something like this: ``` $ hg evolve <something goes wrong with the merge tool, hits ctrl-c> <deals with the merge conflicts> $ hg evolve --continue abort: no interrupted evolve to continue $ hg evolve abort: uncommitted changes # Note: commands.status.verbose=True is set. $ hg status M foo # The repository is in an unfinished *update* state. # No unresolved merge conflicts # To continue: hg update ``` The user did an `hg update`, but it didn't actually do anything besides take it out of the unfinished update state (the files were still dirty in the working directory).
author Kyle Lippincott <spectral@google.com>
date Mon, 16 Sep 2019 12:44:38 -0700
parents
children 31c481934138 591a0afd2ef3
comparison
equal deleted inserted replaced
4847:0fecff9ac36d 4848:535ab2609e45
1 Quitting an evolve in the middle (via ctrl-c or something) can leave things in a
2 weird intermediate state where hg thinks we're in the middle of an update
3 operation (or even just leave the 'merge' directory around without actually
4 indicating we're in the middle of *any* operation).
5
6 $ . $TESTDIR/testlib/common.sh
7
8 $ cat << EOF >> $HGRCPATH
9 > [extensions]
10 > rebase =
11 > evolve =
12 > [alias]
13 > l = log -G -T'{rev} {desc}'
14 > EOF
15
16 $ hg init interrupted-orphan
17 $ cd interrupted-orphan
18
19 $ echo apricot > a
20 $ hg ci -qAm apricot
21
22 $ echo banana > b
23 $ hg ci -qAm banana
24
25 Let's go back to amend 0 and make an orphan out of 1 (and a merge conflict to
26 test with)
27
28 $ hg up -q 0
29 $ echo blueberry > b
30 $ hg l
31 o 1 banana
32 |
33 @ 0 apricot
34
35 $ hg ci --amend -qAm 'apricot and blueberry'
36 1 new orphan changesets
37 $ hg l
38 @ 2 apricot and blueberry
39
40 * 1 banana
41 |
42 x 0 apricot
43
44
45 $ hg evolve --update --config hooks.precommit=false --config ui.merge=:other
46 move:[1] banana
47 atop:[2] apricot and blueberry
48 transaction abort!
49 rollback completed
50 abort: precommit hook exited with status 1
51 [255]
52 $ hg l
53 @ 2 apricot and blueberry
54
55 * 1 banana
56 |
57 x 0 apricot
58
59 $ cat b
60 banana
61
62 $ hg status --config commands.status.verbose=True
63 M b
64 # The repository is in an unfinished *evolve* state.
65
66 # No unresolved merge conflicts.
67
68 # To continue: hg evolve --continue
69 # To abort: hg evolve --abort
70 # To stop: hg evolve --stop
71 # (also see `hg help evolve.interrupted`)
72
73
74 $ ls .hg/evolvestate
75 .hg/evolvestate
76
77 $ cat b
78 banana
79
80 $ hg l
81 @ 2 apricot and blueberry
82
83 * 1 banana
84 |
85 x 0 apricot
86
87
88 Test various methods of handling that unfinished state
89 $ hg evolve --abort
90 evolve aborted
91 working directory is now at e1989e4b1526
92 $ ls .hg/evolvestate
93 ls: cannot access '?.hg/evolvestate'?: No such file or directory (re)
94 [2]
95 $ cat b
96 blueberry
97 $ hg l
98 @ 2 apricot and blueberry
99
100 * 1 banana
101 |
102 x 0 apricot
103
104
105 $ hg evolve --update --config hooks.precommit=false --config ui.merge=:other
106 move:[1] banana
107 atop:[2] apricot and blueberry
108 transaction abort!
109 rollback completed
110 abort: precommit hook exited with status 1
111 [255]
112 $ cat b
113 banana
114 $ hg evolve --stop
115 stopped the interrupted evolve
116 working directory is now at e1989e4b1526
117 $ cat .hg/evolvestate
118 cat: .hg/evolvestate: No such file or directory
119 [1]
120 $ cat b
121 blueberry
122 $ hg l
123 @ 2 apricot and blueberry
124
125 * 1 banana
126 |
127 x 0 apricot
128
129
130 $ hg evolve --update --config hooks.precommit=false --config ui.merge=:other
131 move:[1] banana
132 atop:[2] apricot and blueberry
133 transaction abort!
134 rollback completed
135 abort: precommit hook exited with status 1
136 [255]
137 $ hg evolve --continue
138 evolving 1:e0486f65907d "banana"
139 working directory is now at bd5ec7dfc2af
140 $ cat .hg/evolvestate
141 cat: .hg/evolvestate: No such file or directory
142 [1]
143 $ cat b
144 banana
145 $ hg l
146 @ 3 banana
147 |
148 o 2 apricot and blueberry
149