Newer
Older
$ cat >> $HGRCPATH <<EOF
> [extensions]
> graphlog=
> rebase=
>
> [phases]
> publish=False
>
> [alias]
> tglog = log -G --template "{rev}: '{desc}' {branches}\n"
> tglogp = log -G --template "{rev}:{phase} '{desc}' {branches}\n"
> EOF
Create repo a:
$ hg init a
$ cd a
$ hg unbundle "$TESTDIR/bundles/rebase.hg"
adding changesets
adding manifests
adding file changes
added 8 changesets with 7 changes to 7 files (+2 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg up tip
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg tglog
@ 7: 'H'
|
| o 6: 'G'
|/|
o | 5: 'F'
| |
| o 4: 'E'
|/
| o 3: 'D'
| |
| o 2: 'C'
| |
| o 1: 'B'
|/
o 0: 'A'
$ cd ..
Rebasing B onto H and collapsing changesets with different phases:
saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
$ hg tglogp
@ 5:secret 'Collapsed revision
$ hg manifest
A
B
C
D
F
H
$ cd ..
Rebasing E onto H:
$ hg rebase --source 4 --collapse
saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
$ hg tglog
@ 6: 'Collapsed revision
| * E
| * G'
o 5: 'H'
|
o 4: 'F'
|
| o 3: 'D'
| |
| o 2: 'C'
| |
| o 1: 'B'
|/
o 0: 'A'
$ hg manifest
A
E
F
H
$ cd ..
Rebasing G onto H with custom message:
$ hg clone -q -u . a a3
$ cd a3
$ hg rebase --base 6 -m 'custom message'
abort: message can only be specified with collapse
[255]
$ hg rebase --source 4 --collapse -m 'custom message'
saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)
$ hg tglog
@ 6: 'custom message'
|
o 5: 'H'
|
o 4: 'F'
|
| o 3: 'D'
| |
| o 2: 'C'
| |
| o 1: 'B'
|/
o 0: 'A'
$ hg manifest
A
E
F
H
$ cd ..
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
Create repo b:
$ hg init b
$ cd b
$ echo A > A
$ hg ci -Am A
adding A
$ echo B > B
$ hg ci -Am B
adding B
$ hg up -q 0
$ echo C > C
$ hg ci -Am C
adding C
created new head
$ hg merge
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ echo D > D
$ hg ci -Am D
adding D
$ hg up -q 1
$ echo E > E
$ hg ci -Am E
adding E
created new head
$ echo F > F
$ hg ci -Am F
adding F
$ hg merge
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m G
$ hg up -q 0
$ echo H > H
$ hg ci -Am H
adding H
created new head
$ hg tglog
@ 7: 'H'
|
| o 6: 'G'
| |\
| | o 5: 'F'
| | |
| | o 4: 'E'
| | |
| o | 3: 'D'
| |\|
| o | 2: 'C'
|/ /
| o 1: 'B'
|/
o 0: 'A'
$ cd ..
Rebase and collapse - more than one external (fail):
$ hg clone -q -u . b b1
$ cd b1
$ hg rebase -s 2 --collapse
abort: unable to collapse, there is more than one external parent
[255]
Rebase and collapse - E onto H:
Pierre-Yves David
committed
$ hg rebase -s 4 --collapse # root (4) is not a merge
saved backup bundle to $TESTTMP/b1/.hg/strip-backup/*-backup.hg (glob)
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
$ hg tglog
@ 5: 'Collapsed revision
|\ * E
| | * F
| | * G'
| o 4: 'H'
| |
o | 3: 'D'
|\ \
| o | 2: 'C'
| |/
o / 1: 'B'
|/
o 0: 'A'
$ hg manifest
A
C
D
E
F
H
$ cd ..
Create repo c:
$ hg init c
$ cd c
$ echo A > A
$ hg ci -Am A
adding A
$ echo B > B
$ hg ci -Am B
adding B
$ hg up -q 0
$ echo C > C
$ hg ci -Am C
adding C
created new head
$ hg merge
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ echo D > D
$ hg ci -Am D
adding D
$ hg up -q 1
$ echo E > E
$ hg ci -Am E
adding E
created new head
$ echo F > E
$ hg ci -m 'F'
$ echo G > G
$ hg ci -Am G
adding G
$ hg merge
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m H
$ hg up -q 0
$ echo I > I
$ hg ci -Am I
adding I
created new head
$ hg tglog
@ 8: 'I'
|
| o 7: 'H'
| |\
| | o 6: 'G'
| | |
| | o 5: 'F'
| | |
| | o 4: 'E'
| | |
| o | 3: 'D'
| |\|
| o | 2: 'C'
|/ /
| o 1: 'B'
|/
o 0: 'A'
$ cd ..
Rebase and collapse - E onto I:
$ hg clone -q -u . c c1
$ cd c1
Pierre-Yves David
committed
$ hg rebase -s 4 --collapse # root (4) is not a merge
saved backup bundle to $TESTTMP/c1/.hg/strip-backup/*-backup.hg (glob)
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
$ hg tglog
@ 5: 'Collapsed revision
|\ * E
| | * F
| | * G
| | * H'
| o 4: 'I'
| |
o | 3: 'D'
|\ \
| o | 2: 'C'
| |/
o / 1: 'B'
|/
o 0: 'A'
$ hg manifest
A
C
D
E
G
I
$ cat E
F
$ cd ..
Create repo d:
$ hg init d
$ cd d
$ echo A > A
$ hg ci -Am A
adding A
$ echo B > B
$ hg ci -Am B
adding B
$ echo C > C
$ hg ci -Am C
adding C
$ hg up -q 1
$ echo D > D
$ hg ci -Am D
adding D
created new head
$ hg merge
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m E
$ hg up -q 0
$ echo F > F
$ hg ci -Am F
adding F
created new head
$ hg tglog
@ 5: 'F'
|
| o 4: 'E'
| |\
| | o 3: 'D'
| | |
| o | 2: 'C'
| |/
| o 1: 'B'
|/
o 0: 'A'
$ cd ..
Rebase and collapse - B onto F:
$ hg clone -q -u . d d1
$ cd d1
$ hg rebase -s 1 --collapse
saved backup bundle to $TESTTMP/d1/.hg/strip-backup/*-backup.hg (glob)
$ hg tglog
@ 2: 'Collapsed revision
| * B
| * C
| * D
| * E'
o 1: 'F'
|
o 0: 'A'
$ hg manifest
A
B
C
D
F
Stefano Tortarolo
committed
Interactions between collapse and keepbranches
$ cd ..
$ hg init e
$ cd e
$ echo 'a' > a
$ hg ci -Am 'A'
adding a
$ hg branch '1'
marked working directory as branch 1
(branches are permanent and global, did you want a bookmark?)
Stefano Tortarolo
committed
$ echo 'b' > b
$ hg ci -Am 'B'
adding b
$ hg branch '2'
marked working directory as branch 2
(branches are permanent and global, did you want a bookmark?)
Stefano Tortarolo
committed
$ echo 'c' > c
$ hg ci -Am 'C'
adding c
$ hg up -q 0
$ echo 'd' > d
$ hg ci -Am 'D'
adding d
$ hg tglog
@ 3: 'D'
|
| o 2: 'C' 2
| |
| o 1: 'B' 1
|/
o 0: 'A'
$ hg rebase --keepbranches --collapse -s 1 -d 3
abort: cannot collapse multiple named branches
[255]
Augie Fackler
committed
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
$ repeatchange() {
> hg checkout $1
> hg cp d z
> echo blah >> z
> hg commit -Am "$2" --user "$3"
> }
$ repeatchange 3 "E" "user1"
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ repeatchange 3 "E" "user2"
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
created new head
$ hg tglog
@ 5: 'E'
|
| o 4: 'E'
|/
o 3: 'D'
|
| o 2: 'C' 2
| |
| o 1: 'B' 1
|/
o 0: 'A'
$ hg rebase -s 5 -d 4
saved backup bundle to $TESTTMP/e/.hg/strip-backup/*-backup.hg (glob)
$ hg tglog
@ 4: 'E'
|
o 3: 'D'
|
| o 2: 'C' 2
| |
| o 1: 'B' 1
|/
o 0: 'A'
$ hg export tip
# HG changeset patch
# User user1
# Date 0 0
# Node ID f338eb3c2c7cc5b5915676a2376ba7ac558c5213
# Parent 41acb9dca9eb976e84cd21fcb756b4afa5a35c09
E
diff -r 41acb9dca9eb -r f338eb3c2c7c z
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/z Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,2 @@
+d
+blah
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
$ cd ..
Rebase, collapse and copies
$ hg init copies
$ cd copies
$ hg unbundle "$TESTDIR/bundles/renames.hg"
adding changesets
adding manifests
adding file changes
added 4 changesets with 11 changes to 7 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg up -q tip
$ hg tglog
@ 3: 'move2'
|
o 2: 'move1'
|
| o 1: 'change'
|/
o 0: 'add'
$ hg rebase --collapse -d 1
merging a and d to d
merging b and e to e
merging c and f to f
merging e and g to g
merging f and c to c
saved backup bundle to $TESTTMP/copies/.hg/strip-backup/*-backup.hg (glob)
$ hg st
$ hg st --copies --change .
A d
a
A g
b
R b
$ cat c
c
c
$ cat d
a
a
$ cat g
b
b
$ hg log -r . --template "{file_copies}\n"
d (a)g (b)
Test collapsing a middle revision in-place
$ hg tglog
@ 2: 'Collapsed revision
| * move1
| * move2'
o 1: 'change'
|
o 0: 'add'
$ hg rebase --collapse -r 1 -d 0
abort: can't remove original changesets with unrebased descendants
(use --keep to keep original changesets)
[255]
Test collapsing in place
$ hg rebase --collapse -b . -d 0
saved backup bundle to $TESTTMP/copies/.hg/strip-backup/*-backup.hg (glob)
$ hg st --change . --copies
M a
M c
A d
a
A g
b
R b
$ cat a
a
a
$ cat c
c
c
$ cat d
a
a
$ cat g
b
b