##// END OF EJS Templates
tests: choose the proper environment variable style for the platform...
Matt Harbison -
r23390:6a3e38a1 default
parent child Browse files
Show More
@@ -1,490 +1,497 b''
1 1 Test histedit extension: Fold commands
2 2 ======================================
3 3
4 4 This test file is dedicated to testing the fold command in non conflicting
5 5 case.
6 6
7 7 Initialization
8 8 ---------------
9 9
10 10
11 11 $ . "$TESTDIR/histedit-helpers.sh"
12 12
13 13 $ cat >> $HGRCPATH <<EOF
14 14 > [alias]
15 15 > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
16 16 > [extensions]
17 17 > histedit=
18 18 > EOF
19 19
20 20
21 21 Simple folding
22 22 --------------------
23 23 $ initrepo ()
24 24 > {
25 25 > hg init r
26 26 > cd r
27 27 > for x in a b c d e f ; do
28 28 > echo $x > $x
29 29 > hg add $x
30 30 > hg ci -m $x
31 31 > done
32 32 > }
33 33
34 34 $ initrepo
35 35
36 36 log before edit
37 37 $ hg logt --graph
38 38 @ 5:652413bf663e f
39 39 |
40 40 o 4:e860deea161a e
41 41 |
42 42 o 3:055a42cdd887 d
43 43 |
44 44 o 2:177f92b77385 c
45 45 |
46 46 o 1:d2ae7f538514 b
47 47 |
48 48 o 0:cb9a9f314b8b a
49 49
50 50
51 51 $ hg histedit 177f92b77385 --commands - 2>&1 <<EOF | fixbundle
52 52 > pick e860deea161a e
53 53 > pick 652413bf663e f
54 54 > fold 177f92b77385 c
55 55 > pick 055a42cdd887 d
56 56 > EOF
57 57 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
58 58 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
59 59 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
60 60 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
61 61 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
62 62 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
63 63 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
64 64
65 65 log after edit
66 66 $ hg logt --graph
67 67 @ 4:9c277da72c9b d
68 68 |
69 69 o 3:6de59d13424a f
70 70 |
71 71 o 2:ee283cb5f2d5 e
72 72 |
73 73 o 1:d2ae7f538514 b
74 74 |
75 75 o 0:cb9a9f314b8b a
76 76
77 77
78 78 post-fold manifest
79 79 $ hg manifest
80 80 a
81 81 b
82 82 c
83 83 d
84 84 e
85 85 f
86 86
87 87
88 88 check histedit_source
89 89
90 90 $ hg log --debug --rev 3
91 91 changeset: 3:6de59d13424a8a13acd3e975514aed29dd0d9b2d
92 92 phase: draft
93 93 parent: 2:ee283cb5f2d5955443f23a27b697a04339e9a39a
94 94 parent: -1:0000000000000000000000000000000000000000
95 95 manifest: 3:81eede616954057198ead0b2c73b41d1f392829a
96 96 user: test
97 97 date: Thu Jan 01 00:00:00 1970 +0000
98 98 files+: c f
99 99 extra: branch=default
100 100 extra: histedit_source=a4f7421b80f79fcc59fff01bcbf4a53d127dd6d3,177f92b773850b59254aa5e923436f921b55483b
101 101 description:
102 102 f
103 103 ***
104 104 c
105 105
106 106
107 107
108 108 rollup will fold without preserving the folded commit's message
109 109
110 110 $ hg histedit d2ae7f538514 --commands - 2>&1 <<EOF | fixbundle
111 111 > pick d2ae7f538514 b
112 112 > roll ee283cb5f2d5 e
113 113 > pick 6de59d13424a f
114 114 > pick 9c277da72c9b d
115 115 > EOF
116 116 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
117 117 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
118 118 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
119 119 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
120 120 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
121 121 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
122 122
123 123 log after edit
124 124 $ hg logt --graph
125 125 @ 3:c4a9eb7989fc d
126 126 |
127 127 o 2:8e03a72b6f83 f
128 128 |
129 129 o 1:391ee782c689 b
130 130 |
131 131 o 0:cb9a9f314b8b a
132 132
133 133
134 134 description is taken from rollup target commit
135 135
136 136 $ hg log --debug --rev 1
137 137 changeset: 1:391ee782c68930be438ccf4c6a403daedbfbffa5
138 138 phase: draft
139 139 parent: 0:cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
140 140 parent: -1:0000000000000000000000000000000000000000
141 141 manifest: 1:b5e112a3a8354e269b1524729f0918662d847c38
142 142 user: test
143 143 date: Thu Jan 01 00:00:00 1970 +0000
144 144 files+: b e
145 145 extra: branch=default
146 146 extra: histedit_source=d2ae7f538514cd87c17547b0de4cea71fe1af9fb,ee283cb5f2d5955443f23a27b697a04339e9a39a
147 147 description:
148 148 b
149 149
150 150
151 151
152 152 check saving last-message.txt
153 153
154 154 $ cat > $TESTTMP/abortfolding.py <<EOF
155 155 > from mercurial import util
156 156 > def abortfolding(ui, repo, hooktype, **kwargs):
157 157 > ctx = repo[kwargs.get('node')]
158 158 > if set(ctx.files()) == set(['c', 'd', 'f']):
159 159 > return True # abort folding commit only
160 160 > ui.warn('allow non-folding commit\\n')
161 161 > EOF
162 162 $ cat > .hg/hgrc <<EOF
163 163 > [hooks]
164 164 > pretxncommit.abortfolding = python:$TESTTMP/abortfolding.py:abortfolding
165 165 > EOF
166 166
167 167 $ cat > $TESTTMP/editor.sh << EOF
168 168 > echo "==== before editing"
169 169 > cat \$1
170 170 > echo "===="
171 171 > echo "check saving last-message.txt" >> \$1
172 172 > EOF
173 173
174 174 $ rm -f .hg/last-message.txt
175 175 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <<EOF | fixbundle
176 176 > pick 8e03a72b6f83 f
177 177 > fold c4a9eb7989fc d
178 178 > EOF
179 179 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
180 180 allow non-folding commit
181 181 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
182 182 ==== before editing
183 183 f
184 184 ***
185 185 c
186 186 ***
187 187 d
188 188
189 189
190 190
191 191 HG: Enter commit message. Lines beginning with 'HG:' are removed.
192 192 HG: Leave message empty to abort commit.
193 193 HG: --
194 194 HG: user: test
195 195 HG: branch 'default'
196 196 HG: changed c
197 197 HG: changed d
198 198 HG: changed f
199 199 ====
200 200 transaction abort!
201 201 rollback completed
202 202 abort: pretxncommit.abortfolding hook failed
203 203
204 204 $ cat .hg/last-message.txt
205 205 f
206 206 ***
207 207 c
208 208 ***
209 209 d
210 210
211 211
212 212
213 213 check saving last-message.txt
214 214
215 215 $ cd ..
216 216 $ rm -r r
217 217
218 218 folding preserves initial author
219 219 --------------------------------
220 220
221 221 $ initrepo
222 222
223 223 $ hg ci --user "someone else" --amend --quiet
224 224
225 225 tip before edit
226 226 $ hg log --rev .
227 227 changeset: 5:a00ad806cb55
228 228 tag: tip
229 229 user: someone else
230 230 date: Thu Jan 01 00:00:00 1970 +0000
231 231 summary: f
232 232
233 233
234 234 $ hg histedit e860deea161a --commands - 2>&1 <<EOF | fixbundle
235 235 > pick e860deea161a e
236 236 > fold a00ad806cb55 f
237 237 > EOF
238 238 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
239 239 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
240 240 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
241 241 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
242 242
243 243 tip after edit
244 244 $ hg log --rev .
245 245 changeset: 4:698d4e8040a1
246 246 tag: tip
247 247 user: test
248 248 date: Thu Jan 01 00:00:00 1970 +0000
249 249 summary: e
250 250
251 251
252 252 $ cd ..
253 253 $ rm -r r
254 254
255 255 folding and creating no new change doesn't break:
256 256 -------------------------------------------------
257 257
258 258 folded content is dropped during a merge. The folded commit should properly disappear.
259 259
260 260 $ mkdir fold-to-empty-test
261 261 $ cd fold-to-empty-test
262 262 $ hg init
263 263 $ printf "1\n2\n3\n" > file
264 264 $ hg add file
265 265 $ hg commit -m '1+2+3'
266 266 $ echo 4 >> file
267 267 $ hg commit -m '+4'
268 268 $ echo 5 >> file
269 269 $ hg commit -m '+5'
270 270 $ echo 6 >> file
271 271 $ hg commit -m '+6'
272 272 $ hg logt --graph
273 273 @ 3:251d831eeec5 +6
274 274 |
275 275 o 2:888f9082bf99 +5
276 276 |
277 277 o 1:617f94f13c0f +4
278 278 |
279 279 o 0:0189ba417d34 1+2+3
280 280
281 281
282 282 $ hg histedit 1 --commands - << EOF
283 283 > pick 617f94f13c0f 1 +4
284 284 > drop 888f9082bf99 2 +5
285 285 > fold 251d831eeec5 3 +6
286 286 > EOF
287 287 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
288 288 merging file
289 289 warning: conflicts during merge.
290 290 merging file incomplete! (edit conflicts, then use 'hg resolve --mark')
291 291 Fix up the change and run hg histedit --continue
292 292 [1]
293 293 There were conflicts, we keep P1 content. This
294 294 should effectively drop the changes from +6.
295 295 $ hg status
296 296 M file
297 297 ? file.orig
298 298 $ hg resolve -l
299 299 U file
300 300 $ hg revert -r 'p1()' file
301 301 $ hg resolve --mark file
302 302 (no more unresolved files)
303 303 $ hg histedit --continue
304 304 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
305 305 saved backup bundle to $TESTTMP/*-backup.hg (glob)
306 306 $ hg logt --graph
307 307 @ 1:617f94f13c0f +4
308 308 |
309 309 o 0:0189ba417d34 1+2+3
310 310
311 311
312 312 $ cd ..
313 313
314 314
315 315 Test fold through dropped
316 316 -------------------------
317 317
318 318
319 319 Test corner case where folded revision is separated from its parent by a
320 320 dropped revision.
321 321
322 322
323 323 $ hg init fold-with-dropped
324 324 $ cd fold-with-dropped
325 325 $ printf "1\n2\n3\n" > file
326 326 $ hg commit -Am '1+2+3'
327 327 adding file
328 328 $ echo 4 >> file
329 329 $ hg commit -m '+4'
330 330 $ echo 5 >> file
331 331 $ hg commit -m '+5'
332 332 $ echo 6 >> file
333 333 $ hg commit -m '+6'
334 334 $ hg logt -G
335 335 @ 3:251d831eeec5 +6
336 336 |
337 337 o 2:888f9082bf99 +5
338 338 |
339 339 o 1:617f94f13c0f +4
340 340 |
341 341 o 0:0189ba417d34 1+2+3
342 342
343 343 $ hg histedit 1 --commands - << EOF
344 344 > pick 617f94f13c0f 1 +4
345 345 > drop 888f9082bf99 2 +5
346 346 > fold 251d831eeec5 3 +6
347 347 > EOF
348 348 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
349 349 merging file
350 350 warning: conflicts during merge.
351 351 merging file incomplete! (edit conflicts, then use 'hg resolve --mark')
352 352 Fix up the change and run hg histedit --continue
353 353 [1]
354 354 $ cat > file << EOF
355 355 > 1
356 356 > 2
357 357 > 3
358 358 > 4
359 359 > 5
360 360 > EOF
361 361 $ hg resolve --mark file
362 362 (no more unresolved files)
363 363 $ hg commit -m '+5.2'
364 364 created new head
365 365 $ echo 6 >> file
366 366 $ HGEDITOR=cat hg histedit --continue
367 367 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
368 368 +4
369 369 ***
370 370 +5.2
371 371 ***
372 372 +6
373 373
374 374
375 375
376 376 HG: Enter commit message. Lines beginning with 'HG:' are removed.
377 377 HG: Leave message empty to abort commit.
378 378 HG: --
379 379 HG: user: test
380 380 HG: branch 'default'
381 381 HG: changed file
382 382 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
383 383 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
384 384 saved backup bundle to $TESTTMP/fold-with-dropped/.hg/strip-backup/617f94f13c0f-backup.hg (glob)
385 385 $ hg logt -G
386 386 @ 1:10c647b2cdd5 +4
387 387 |
388 388 o 0:0189ba417d34 1+2+3
389 389
390 390 $ hg export tip
391 391 # HG changeset patch
392 392 # User test
393 393 # Date 0 0
394 394 # Thu Jan 01 00:00:00 1970 +0000
395 395 # Node ID 10c647b2cdd54db0603ecb99b2ff5ce66d5a5323
396 396 # Parent 0189ba417d34df9dda55f88b637dcae9917b5964
397 397 +4
398 398 ***
399 399 +5.2
400 400 ***
401 401 +6
402 402
403 403 diff -r 0189ba417d34 -r 10c647b2cdd5 file
404 404 --- a/file Thu Jan 01 00:00:00 1970 +0000
405 405 +++ b/file Thu Jan 01 00:00:00 1970 +0000
406 406 @@ -1,3 +1,6 @@
407 407 1
408 408 2
409 409 3
410 410 +4
411 411 +5
412 412 +6
413 413 $ cd ..
414 414
415 415
416 416 Folding with initial rename (issue3729)
417 417 ---------------------------------------
418 418
419 419 $ hg init fold-rename
420 420 $ cd fold-rename
421 421 $ echo a > a.txt
422 422 $ hg add a.txt
423 423 $ hg commit -m a
424 424 $ hg rename a.txt b.txt
425 425 $ hg commit -m rename
426 426 $ echo b >> b.txt
427 427 $ hg commit -m b
428 428
429 429 $ hg logt --follow b.txt
430 430 2:e0371e0426bc b
431 431 1:1c4f440a8085 rename
432 432 0:6c795aa153cb a
433 433
434 434 $ hg histedit 1c4f440a8085 --commands - 2>&1 << EOF | fixbundle
435 435 > pick 1c4f440a8085 rename
436 436 > fold e0371e0426bc b
437 437 > EOF
438 438 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
439 439 reverting b.txt
440 440 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
441 441 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
442 442 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
443 443
444 444 $ hg logt --follow b.txt
445 445 1:cf858d235c76 rename
446 446 0:6c795aa153cb a
447 447
448 448 $ cd ..
449 449
450 450 Folding with swapping
451 451 ---------------------
452 452
453 453 This is an excuse to test hook with histedit temporary commit (issue4422)
454 454
455 455
456 456 $ hg init issue4422
457 457 $ cd issue4422
458 458 $ echo a > a.txt
459 459 $ hg add a.txt
460 460 $ hg commit -m a
461 461 $ echo b > b.txt
462 462 $ hg add b.txt
463 463 $ hg commit -m b
464 464 $ echo c > c.txt
465 465 $ hg add c.txt
466 466 $ hg commit -m c
467 467
468 468 $ hg logt
469 469 2:a1a953ffb4b0 c
470 470 1:199b6bb90248 b
471 471 0:6c795aa153cb a
472 472
473 $ hg histedit 6c795aa153cb --config hooks.commit="echo commit \$HG_NODE" --commands - 2>&1 << EOF | fixbundle
473 Setup the proper environment variable symbol for the platform, to be subbed
474 into the hook command.
475 #if windows
476 $ NODE="%HG_NODE%"
477 #else
478 $ NODE="\$HG_NODE"
479 #endif
480 $ hg histedit 6c795aa153cb --config hooks.commit="echo commit $NODE" --commands - 2>&1 << EOF | fixbundle
474 481 > pick 199b6bb90248 b
475 482 > fold a1a953ffb4b0 c
476 483 > pick 6c795aa153cb a
477 484 > EOF
478 485 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
479 486 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
480 487 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
481 488 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
482 489 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
483 490 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
484 491 commit 9599899f62c05f4377548c32bf1c9f1a39634b0c
485 492
486 493 $ hg logt
487 494 1:9599899f62c0 a
488 495 0:79b99e9c8e49 b
489 496
490 497 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now