comparison tests/test-evolve-stop.t @ 3577:279d8b610ac5

evolve: add a `--stop` flag for `hg evolve` command This patch adds a `--stop` flag for `hg evolve` command. The stop flag lets you stop the evolution from where you are and let you move to other things if you want. This fuctionality is great as user can decide to resolve conflicts later on, stop the command execution, do something else and get back once they has time or care about resolving them. As implementation details, it clears the evolvestate, updates to the parent of working directory clearing the uncommitted changes which also deletes the mergestate. A new test file test-evolve-stop.t is added with tests of the new flag added.
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 20 Mar 2018 18:41:31 +0530
parents
children d5adce52cef4 f6979d64b9fb
comparison
equal deleted inserted replaced
3576:89acae8f7e93 3577:279d8b610ac5
1 Tests for the --stop flag for `hg evolve` command
2 =================================================
3
4 The `--stop` flag stops the interrupted evolution and delete the state file so
5 user can do other things and comeback and do evolution later on
6
7 Setup
8 =====
9
10 $ cat >> $HGRCPATH <<EOF
11 > [alias]
12 > glog = log -GT "{rev}:{node|short} {desc}\n ({bookmarks}) {phase}"
13 > [extensions]
14 > EOF
15 $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
16
17 $ hg init stoprepo
18 $ cd stoprepo
19 $ echo ".*\.orig" > .hgignore
20 $ hg add .hgignore
21 $ hg ci -m "added hgignore"
22 $ for ch in a b c d; do echo foo > $ch; hg add $ch; hg ci -qm "added "$ch; done;
23
24 $ hg glog
25 @ 4:c41c793e0ef1 added d
26 | () draft
27 o 3:ca1b80f7960a added c
28 | () draft
29 o 2:b1661037fa25 added b
30 | () draft
31 o 1:c7586e2a9264 added a
32 | () draft
33 o 0:8fa14d15e168 added hgignore
34 () draft
35
36 Testing `--stop` when no evolve is interrupted
37 ==============================================
38
39 $ hg evolve --stop
40 abort: no interrupted evolve to stop
41 [255]
42
43 Testing with wrong combinations of flags
44 ========================================
45
46 $ hg evolve --stop --rev 1
47 abort: cannot specify both "--rev" and "--stop"
48 [255]
49
50 $ hg evolve --stop --continue
51 abort: cannot specify both "--stop" and "--continue"
52 [255]
53
54 $ hg evolve --stop --all
55 abort: cannot specify both "--all" and "--stop"
56 [255]
57
58 $ hg evolve --stop --any
59 abort: cannot specify both "--any" and "--stop"
60 [255]
61
62 Testing when only one revision is to evolve
63 ===========================================
64
65 $ hg prev
66 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
67 [3] added c
68 $ echo bar > d
69 $ hg add d
70 $ hg amend
71 1 new orphan changesets
72 $ hg glog
73 @ 5:cb6a2ab625bb added c
74 | () draft
75 | * 4:c41c793e0ef1 added d
76 | | () draft
77 | x 3:ca1b80f7960a added c
78 |/ () draft
79 o 2:b1661037fa25 added b
80 | () draft
81 o 1:c7586e2a9264 added a
82 | () draft
83 o 0:8fa14d15e168 added hgignore
84 () draft
85
86 $ hg evolve
87 move:[4] added d
88 atop:[5] added c
89 merging d
90 warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
91 evolve failed!
92 fix conflict and run 'hg evolve --continue' or use 'hg update -C .' to abort
93 abort: unresolved merge conflicts (see hg help resolve)
94 [255]
95
96 $ hg evolve --stop
97 stopped the interrupted evolve
98 working directory is now at cb6a2ab625bb
99
100 Checking whether evolvestate file exists or not
101 $ cat .hg/evolvestate
102 cat: .hg/evolvestate: No such file or directory
103 [1]
104
105 Checking where we are
106 $ hg id
107 cb6a2ab625bb tip
108
109 Checking working dir
110 $ hg status
111 Checking for incomplete mergestate
112 $ ls .hg/merge
113 ls: cannot access .?\.hg/merge.?: No such file or directory (re)
114 [2]
115
116 Checking graph
117 $ hg glog
118 @ 5:cb6a2ab625bb added c
119 | () draft
120 | * 4:c41c793e0ef1 added d
121 | | () draft
122 | x 3:ca1b80f7960a added c
123 |/ () draft
124 o 2:b1661037fa25 added b
125 | () draft
126 o 1:c7586e2a9264 added a
127 | () draft
128 o 0:8fa14d15e168 added hgignore
129 () draft
130
131 Testing the stop flag in case conflicts are caused by `hg next --evolve`
132 ========================================================================
133
134 $ hg next --evolve
135 move:[4] added d
136 atop:[5] added c
137 merging d
138 warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
139 evolve failed!
140 fix conflict and run 'hg evolve --continue' or use 'hg update -C .' to abort
141 abort: unresolved merge conflicts (see hg help resolve)
142 [255]
143
144 $ hg diff
145 diff -r cb6a2ab625bb d
146 --- a/d Thu Jan 01 00:00:00 1970 +0000
147 +++ b/d Thu Jan 01 00:00:00 1970 +0000
148 @@ -1,1 +1,5 @@
149 +<<<<<<< destination: cb6a2ab625bb - test: added c
150 bar
151 +=======
152 +foo
153 +>>>>>>> evolving: c41c793e0ef1 - test: added d
154
155 $ hg evolve --stop
156 stopped the interrupted evolve
157 working directory is now at cb6a2ab625bb
158
159 $ hg glog
160 @ 5:cb6a2ab625bb added c
161 | () draft
162 | * 4:c41c793e0ef1 added d
163 | | () draft
164 | x 3:ca1b80f7960a added c
165 |/ () draft
166 o 2:b1661037fa25 added b
167 | () draft
168 o 1:c7586e2a9264 added a
169 | () draft
170 o 0:8fa14d15e168 added hgignore
171 () draft
172
173 $ hg status
174
175 Checking when multiple revs need to be evolved, some revs evolve without
176 conflicts
177 =========================================================================
178
179 Making sure obsmarkers should be on evolved changeset and not rest of them once
180 we do `evolve --stop`
181 --------------------------------------------------------------------------------
182
183 $ hg evolve
184 move:[4] added d
185 atop:[5] added c
186 merging d
187 warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
188 evolve failed!
189 fix conflict and run 'hg evolve --continue' or use 'hg update -C .' to abort
190 abort: unresolved merge conflicts (see hg help resolve)
191 [255]
192 $ echo foo > d
193 $ hg resolve -m
194 (no more unresolved files)
195 continue: hg evolve --continue
196 $ hg evolve --continue
197 evolving 4:c41c793e0ef1 "added d"
198 working directory is now at 2a4e03d422e2
199 $ hg glog
200 @ 6:2a4e03d422e2 added d
201 | () draft
202 o 5:cb6a2ab625bb added c
203 | () draft
204 o 2:b1661037fa25 added b
205 | () draft
206 o 1:c7586e2a9264 added a
207 | () draft
208 o 0:8fa14d15e168 added hgignore
209 () draft
210
211 $ hg up .^^^^
212 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
213 $ echo bar > c
214 $ hg add c
215 $ hg amend
216 4 new orphan changesets
217
218 $ hg glog
219 @ 7:21817cd42526 added hgignore
220 () draft
221 * 6:2a4e03d422e2 added d
222 | () draft
223 * 5:cb6a2ab625bb added c
224 | () draft
225 * 2:b1661037fa25 added b
226 | () draft
227 * 1:c7586e2a9264 added a
228 | () draft
229 x 0:8fa14d15e168 added hgignore
230 () draft
231
232 $ hg evolve --all
233 move:[1] added a
234 atop:[7] added hgignore
235 move:[2] added b
236 atop:[8] added a
237 move:[5] added c
238 atop:[9] added b
239 merging c
240 warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
241 evolve failed!
242 fix conflict and run 'hg evolve --continue' or use 'hg update -C .' to abort
243 abort: unresolved merge conflicts (see hg help resolve)
244 [255]
245
246 $ hg status
247 M c
248 A d
249
250 $ hg evolve --stop
251 stopped the interrupted evolve
252 working directory is now at aec285328e90
253
254 Only changeset which has a successor now are obsoleted
255 $ hg glog
256 @ 9:aec285328e90 added b
257 | () draft
258 o 8:fd00db71edca added a
259 | () draft
260 o 7:21817cd42526 added hgignore
261 () draft
262 * 6:2a4e03d422e2 added d
263 | () draft
264 * 5:cb6a2ab625bb added c
265 | () draft
266 x 2:b1661037fa25 added b
267 | () draft
268 x 1:c7586e2a9264 added a
269 | () draft
270 x 0:8fa14d15e168 added hgignore
271 () draft
272
273 Making sure doing evolve again resumes from right place and does the right thing
274
275 $ hg evolve --all
276 move:[5] added c
277 atop:[9] added b
278 merging c
279 warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
280 evolve failed!
281 fix conflict and run 'hg evolve --continue' or use 'hg update -C .' to abort
282 abort: unresolved merge conflicts (see hg help resolve)
283 [255]
284
285 $ echo foobar > c
286 $ hg resolve -m
287 (no more unresolved files)
288 continue: hg evolve --continue
289 $ hg evolve --continue
290 evolving 5:cb6a2ab625bb "added c"
291 move:[6] added d
292 atop:[10] added c
293 working directory is now at cd0909a30222
294 $ hg glog
295 @ 11:cd0909a30222 added d
296 | () draft
297 o 10:cb1dd1086ef6 added c
298 | () draft
299 o 9:aec285328e90 added b
300 | () draft
301 o 8:fd00db71edca added a
302 | () draft
303 o 7:21817cd42526 added hgignore
304 () draft
305
306 Bookmarks should only be moved of the changesets which have been evolved,
307 bookmarks of rest of them should stay where they are are
308 -------------------------------------------------------------------------
309
310 $ hg up .^
311 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
312 $ hg bookmark b1
313 $ hg up .^
314 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
315 (leaving bookmark b1)
316 $ hg bookmark b2
317
318 $ hg glog
319 o 11:cd0909a30222 added d
320 | () draft
321 o 10:cb1dd1086ef6 added c
322 | (b1) draft
323 @ 9:aec285328e90 added b
324 | (b2) draft
325 o 8:fd00db71edca added a
326 | () draft
327 o 7:21817cd42526 added hgignore
328 () draft
329
330 $ hg prev
331 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
332 [8] added a
333 $ echo tom > c
334 $ hg amend
335 3 new orphan changesets
336
337 $ hg glog
338 @ 12:a3cc2042492f added a
339 | () draft
340 | * 11:cd0909a30222 added d
341 | | () draft
342 | * 10:cb1dd1086ef6 added c
343 | | (b1) draft
344 | * 9:aec285328e90 added b
345 | | (b2) draft
346 | x 8:fd00db71edca added a
347 |/ () draft
348 o 7:21817cd42526 added hgignore
349 () draft
350
351 $ hg evolve --all
352 move:[9] added b
353 atop:[12] added a
354 move:[10] added c
355 atop:[13] added b
356 merging c
357 warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
358 evolve failed!
359 fix conflict and run 'hg evolve --continue' or use 'hg update -C .' to abort
360 abort: unresolved merge conflicts (see hg help resolve)
361 [255]
362
363 $ hg evolve --stop
364 stopped the interrupted evolve
365 working directory is now at a3f4b95da934
366
367 Bookmarks of only the changeset which are evolved is moved
368 $ hg glog
369 @ 13:a3f4b95da934 added b
370 | (b2) draft
371 o 12:a3cc2042492f added a
372 | () draft
373 | * 11:cd0909a30222 added d
374 | | () draft
375 | * 10:cb1dd1086ef6 added c
376 | | (b1) draft
377 | x 9:aec285328e90 added b
378 | | () draft
379 | x 8:fd00db71edca added a
380 |/ () draft
381 o 7:21817cd42526 added hgignore
382 () draft