##// END OF EJS Templates
test-histedit-edit.t: demonstrate qnew fails during a histedit (issue4366)...
Augie Fackler -
r24299:68d998a7 default
parent child Browse files
Show More
@@ -1,364 +1,371
1 1 $ . "$TESTDIR/histedit-helpers.sh"
2 2
3 3 $ cat >> $HGRCPATH <<EOF
4 4 > [extensions]
5 5 > histedit=
6 6 > strip=
7 7 > EOF
8 8
9 9 $ initrepo ()
10 10 > {
11 11 > hg init r
12 12 > cd r
13 13 > for x in a b c d e f g; do
14 14 > echo $x > $x
15 15 > hg add $x
16 16 > hg ci -m $x
17 17 > done
18 18 > }
19 19
20 20 $ initrepo
21 21
22 22 log before edit
23 23 $ hg log --graph
24 24 @ changeset: 6:3c6a8ed2ebe8
25 25 | tag: tip
26 26 | user: test
27 27 | date: Thu Jan 01 00:00:00 1970 +0000
28 28 | summary: g
29 29 |
30 30 o changeset: 5:652413bf663e
31 31 | user: test
32 32 | date: Thu Jan 01 00:00:00 1970 +0000
33 33 | summary: f
34 34 |
35 35 o changeset: 4:e860deea161a
36 36 | user: test
37 37 | date: Thu Jan 01 00:00:00 1970 +0000
38 38 | summary: e
39 39 |
40 40 o changeset: 3:055a42cdd887
41 41 | user: test
42 42 | date: Thu Jan 01 00:00:00 1970 +0000
43 43 | summary: d
44 44 |
45 45 o changeset: 2:177f92b77385
46 46 | user: test
47 47 | date: Thu Jan 01 00:00:00 1970 +0000
48 48 | summary: c
49 49 |
50 50 o changeset: 1:d2ae7f538514
51 51 | user: test
52 52 | date: Thu Jan 01 00:00:00 1970 +0000
53 53 | summary: b
54 54 |
55 55 o changeset: 0:cb9a9f314b8b
56 56 user: test
57 57 date: Thu Jan 01 00:00:00 1970 +0000
58 58 summary: a
59 59
60 60
61 61 edit the history
62 62 $ hg histedit 177f92b77385 --commands - 2>&1 << EOF| fixbundle
63 63 > pick 177f92b77385 c
64 64 > pick 055a42cdd887 d
65 65 > edit e860deea161a e
66 66 > pick 652413bf663e f
67 67 > pick 3c6a8ed2ebe8 g
68 68 > EOF
69 69 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
70 70 Make changes as needed, you may commit or record as needed now.
71 71 When you are finished, run hg histedit --continue to resume.
72 72
73 73 edit the plan
74 74 $ hg histedit --edit-plan --commands - 2>&1 << EOF
75 75 > edit e860deea161a e
76 76 > pick 652413bf663e f
77 77 > drop 3c6a8ed2ebe8 g
78 78 > EOF
79 79
80 80 Go at a random point and try to continue
81 81
82 82 $ hg id -n
83 83 3+
84 84 $ hg up 0
85 85 abort: histedit in progress
86 86 (use 'hg histedit --continue' or 'hg histedit --abort')
87 87 [255]
88 88
89 89 Try to delete necessary commit
90 90 $ hg strip -r 652413bf663e
91 91 abort: histedit in progress, can't strip 363532343133
92 92 [255]
93 93
94 94 commit, then edit the revision
95 95 $ hg ci -m 'wat'
96 96 created new head
97 97 $ echo a > e
98
99 qnew should fail while we're in the middle of the edit step
100
101 $ hg --config extensions.mq= qnew please-fail
102 abort: histedit in progress
103 (use 'hg histedit --continue' or 'hg histedit --abort')
104 [255]
98 105 $ HGEDITOR='echo foobaz > ' hg histedit --continue 2>&1 | fixbundle
99 106 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 107 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 108
102 109 $ hg log --graph
103 110 @ changeset: 6:b5f70786f9b0
104 111 | tag: tip
105 112 | user: test
106 113 | date: Thu Jan 01 00:00:00 1970 +0000
107 114 | summary: f
108 115 |
109 116 o changeset: 5:a5e1ba2f7afb
110 117 | user: test
111 118 | date: Thu Jan 01 00:00:00 1970 +0000
112 119 | summary: foobaz
113 120 |
114 121 o changeset: 4:1a60820cd1f6
115 122 | user: test
116 123 | date: Thu Jan 01 00:00:00 1970 +0000
117 124 | summary: wat
118 125 |
119 126 o changeset: 3:055a42cdd887
120 127 | user: test
121 128 | date: Thu Jan 01 00:00:00 1970 +0000
122 129 | summary: d
123 130 |
124 131 o changeset: 2:177f92b77385
125 132 | user: test
126 133 | date: Thu Jan 01 00:00:00 1970 +0000
127 134 | summary: c
128 135 |
129 136 o changeset: 1:d2ae7f538514
130 137 | user: test
131 138 | date: Thu Jan 01 00:00:00 1970 +0000
132 139 | summary: b
133 140 |
134 141 o changeset: 0:cb9a9f314b8b
135 142 user: test
136 143 date: Thu Jan 01 00:00:00 1970 +0000
137 144 summary: a
138 145
139 146
140 147 $ hg cat e
141 148 a
142 149
143 150 check histedit_source
144 151
145 152 $ hg log --debug --rev 5
146 153 changeset: 5:a5e1ba2f7afb899ef1581cea528fd885d2fca70d
147 154 phase: draft
148 155 parent: 4:1a60820cd1f6004a362aa622ebc47d59bc48eb34
149 156 parent: -1:0000000000000000000000000000000000000000
150 157 manifest: 5:5ad3be8791f39117565557781f5464363b918a45
151 158 user: test
152 159 date: Thu Jan 01 00:00:00 1970 +0000
153 160 files: e
154 161 extra: branch=default
155 162 extra: histedit_source=e860deea161a2f77de56603b340ebbb4536308ae
156 163 description:
157 164 foobaz
158 165
159 166
160 167
161 168 $ hg histedit tip --commands - 2>&1 <<EOF| fixbundle
162 169 > edit b5f70786f9b0 f
163 170 > EOF
164 171 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
165 172 Make changes as needed, you may commit or record as needed now.
166 173 When you are finished, run hg histedit --continue to resume.
167 174 $ hg status
168 175 A f
169 176
170 177 $ hg summary
171 178 parent: 5:a5e1ba2f7afb
172 179 foobaz
173 180 branch: default
174 181 commit: 1 added (new branch head)
175 182 update: 1 new changesets (update)
176 183 hist: 1 remaining (histedit --continue)
177 184
178 185 (test also that editor is invoked if histedit is continued for
179 186 "edit" action)
180 187
181 188 $ HGEDITOR='cat' hg histedit --continue
182 189 f
183 190
184 191
185 192 HG: Enter commit message. Lines beginning with 'HG:' are removed.
186 193 HG: Leave message empty to abort commit.
187 194 HG: --
188 195 HG: user: test
189 196 HG: branch 'default'
190 197 HG: added f
191 198 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
192 199 saved backup bundle to $TESTTMP/r/.hg/strip-backup/b5f70786f9b0-c28d9c86-backup.hg (glob)
193 200
194 201 $ hg status
195 202
196 203 log after edit
197 204 $ hg log --limit 1
198 205 changeset: 6:a107ee126658
199 206 tag: tip
200 207 user: test
201 208 date: Thu Jan 01 00:00:00 1970 +0000
202 209 summary: f
203 210
204 211
205 212 say we'll change the message, but don't.
206 213 $ cat > ../edit.sh <<EOF
207 214 > cat "\$1" | sed s/pick/mess/ > tmp
208 215 > mv tmp "\$1"
209 216 > EOF
210 217 $ HGEDITOR="sh ../edit.sh" hg histedit tip 2>&1 | fixbundle
211 218 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
212 219 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
213 220 $ hg status
214 221 $ hg log --limit 1
215 222 changeset: 6:1fd3b2fe7754
216 223 tag: tip
217 224 user: test
218 225 date: Thu Jan 01 00:00:00 1970 +0000
219 226 summary: f
220 227
221 228
222 229 modify the message
223 230
224 231 check saving last-message.txt, at first
225 232
226 233 $ cat > $TESTTMP/commitfailure.py <<EOF
227 234 > from mercurial import util
228 235 > def reposetup(ui, repo):
229 236 > class commitfailure(repo.__class__):
230 237 > def commit(self, *args, **kwargs):
231 238 > raise util.Abort('emulating unexpected abort')
232 239 > repo.__class__ = commitfailure
233 240 > EOF
234 241 $ cat >> .hg/hgrc <<EOF
235 242 > [extensions]
236 243 > # this failure occurs before editor invocation
237 244 > commitfailure = $TESTTMP/commitfailure.py
238 245 > EOF
239 246
240 247 $ cat > $TESTTMP/editor.sh <<EOF
241 248 > echo "==== before editing"
242 249 > cat \$1
243 250 > echo "===="
244 251 > echo "check saving last-message.txt" >> \$1
245 252 > EOF
246 253
247 254 (test that editor is not invoked before transaction starting)
248 255
249 256 $ rm -f .hg/last-message.txt
250 257 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit tip --commands - 2>&1 << EOF | fixbundle
251 258 > mess 1fd3b2fe7754 f
252 259 > EOF
253 260 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
254 261 abort: emulating unexpected abort
255 262 $ test -f .hg/last-message.txt
256 263 [1]
257 264
258 265 $ cat >> .hg/hgrc <<EOF
259 266 > [extensions]
260 267 > commitfailure = !
261 268 > EOF
262 269 $ hg histedit --abort -q
263 270
264 271 (test that editor is invoked and commit message is saved into
265 272 "last-message.txt")
266 273
267 274 $ cat >> .hg/hgrc <<EOF
268 275 > [hooks]
269 276 > # this failure occurs after editor invocation
270 277 > pretxncommit.unexpectedabort = false
271 278 > EOF
272 279
273 280 $ hg status --rev '1fd3b2fe7754^1' --rev 1fd3b2fe7754
274 281 A f
275 282
276 283 $ rm -f .hg/last-message.txt
277 284 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit tip --commands - 2>&1 << EOF
278 285 > mess 1fd3b2fe7754 f
279 286 > EOF
280 287 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
281 288 adding f
282 289 ==== before editing
283 290 f
284 291
285 292
286 293 HG: Enter commit message. Lines beginning with 'HG:' are removed.
287 294 HG: Leave message empty to abort commit.
288 295 HG: --
289 296 HG: user: test
290 297 HG: branch 'default'
291 298 HG: added f
292 299 ====
293 300 transaction abort!
294 301 rollback completed
295 302 note: commit message saved in .hg/last-message.txt
296 303 abort: pretxncommit.unexpectedabort hook exited with status 1
297 304 [255]
298 305 $ cat .hg/last-message.txt
299 306 f
300 307
301 308
302 309 check saving last-message.txt
303 310
304 311 (test also that editor is invoked if histedit is continued for "message"
305 312 action)
306 313
307 314 $ HGEDITOR=cat hg histedit --continue
308 315 f
309 316
310 317
311 318 HG: Enter commit message. Lines beginning with 'HG:' are removed.
312 319 HG: Leave message empty to abort commit.
313 320 HG: --
314 321 HG: user: test
315 322 HG: branch 'default'
316 323 HG: added f
317 324 transaction abort!
318 325 rollback completed
319 326 note: commit message saved in .hg/last-message.txt
320 327 abort: pretxncommit.unexpectedabort hook exited with status 1
321 328 [255]
322 329
323 330 $ cat >> .hg/hgrc <<EOF
324 331 > [hooks]
325 332 > pretxncommit.unexpectedabort =
326 333 > EOF
327 334 $ hg histedit --abort -q
328 335
329 336 then, check "modify the message" itself
330 337
331 338 $ hg histedit tip --commands - 2>&1 << EOF | fixbundle
332 339 > mess 1fd3b2fe7754 f
333 340 > EOF
334 341 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
335 342 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
336 343 $ hg status
337 344 $ hg log --limit 1
338 345 changeset: 6:62feedb1200e
339 346 tag: tip
340 347 user: test
341 348 date: Thu Jan 01 00:00:00 1970 +0000
342 349 summary: f
343 350
344 351
345 352 rollback should not work after a histedit
346 353 $ hg rollback
347 354 no rollback information available
348 355 [1]
349 356
350 357 $ cd ..
351 358 $ hg clone -qr0 r r0
352 359 $ cd r0
353 360 $ hg phase -fdr0
354 361 $ hg histedit --commands - 0 2>&1 << EOF
355 362 > edit cb9a9f314b8b a > $EDITED
356 363 > EOF
357 364 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
358 365 adding a
359 366 Make changes as needed, you may commit or record as needed now.
360 367 When you are finished, run hg histedit --continue to resume.
361 368 [1]
362 369 $ HGEDITOR=true hg histedit --continue
363 370 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
364 371 saved backup bundle to $TESTTMP/r0/.hg/strip-backup/cb9a9f314b8b-cc5ccb0b-backup.hg (glob)
General Comments 0
You need to be logged in to leave comments. Login now