2019-02-13 08:39:24 +03:00
|
|
|
$ enable rebase strip
|
|
|
|
$ setconfig phases.publish=0
|
2010-10-01 18:10:06 +04:00
|
|
|
|
|
|
|
Create repo a:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo a
|
|
|
|
$ drawdag <<'EOS'
|
|
|
|
> o H
|
|
|
|
> |
|
|
|
|
> | o G
|
|
|
|
> |/|
|
|
|
|
> o | F
|
|
|
|
> | |
|
|
|
|
> | o E
|
|
|
|
> |/
|
|
|
|
> | o D
|
|
|
|
> | |
|
|
|
|
> | o C
|
|
|
|
> | |
|
|
|
|
> | o B
|
|
|
|
> |/
|
|
|
|
> o A
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ cd $TESTTMP
|
|
|
|
|
|
|
|
Rebasing B onto H and collapsing changesets:
|
|
|
|
|
|
|
|
|
|
|
|
$ hg clone -q -u $D a a1
|
2010-10-01 18:10:06 +04:00
|
|
|
$ cd a1
|
|
|
|
|
2014-03-18 20:07:41 +04:00
|
|
|
$ cat > $TESTTMP/editor.sh <<EOF
|
|
|
|
> echo "==== before editing"
|
|
|
|
> cat \$1
|
|
|
|
> echo "===="
|
|
|
|
> echo "edited manually" >> \$1
|
|
|
|
> EOF
|
2019-02-13 08:39:24 +03:00
|
|
|
$ HGEDITOR="sh $TESTTMP/editor.sh" hg rebase --collapse -e --dest $H
|
|
|
|
rebasing 1:112478962961 "B"
|
|
|
|
rebasing 4:26805aba1e60 "C"
|
|
|
|
rebasing 7:f585351a92f8 "D" (tip)
|
2014-03-18 20:07:41 +04:00
|
|
|
==== before editing
|
|
|
|
Collapsed revision
|
|
|
|
* B
|
|
|
|
* C
|
|
|
|
* D
|
|
|
|
|
|
|
|
|
|
|
|
HG: Enter commit message. Lines beginning with 'HG:' are removed.
|
|
|
|
HG: Leave message empty to abort commit.
|
|
|
|
HG: --
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: user: test
|
2014-03-18 20:07:41 +04:00
|
|
|
HG: branch 'default'
|
2014-10-10 22:05:50 +04:00
|
|
|
HG: added B
|
|
|
|
HG: added C
|
|
|
|
HG: added D
|
2014-03-18 20:07:41 +04:00
|
|
|
====
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -Gr 'all()' -T '{desc}'
|
|
|
|
@ Collapsed revision
|
2010-10-01 18:10:06 +04:00
|
|
|
| * B
|
|
|
|
| * C
|
2014-03-18 20:07:41 +04:00
|
|
|
| * D
|
|
|
|
|
|
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
| edited manually
|
|
|
|
o H
|
2010-10-01 18:10:06 +04:00
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
| o G
|
2010-10-01 18:10:06 +04:00
|
|
|
|/|
|
2019-02-13 08:39:24 +03:00
|
|
|
o | F
|
2010-10-01 18:10:06 +04:00
|
|
|
| |
|
2019-02-13 08:39:24 +03:00
|
|
|
| o E
|
2010-10-01 18:10:06 +04:00
|
|
|
|/
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg manifest --rev tip
|
2010-10-01 18:10:06 +04:00
|
|
|
A
|
|
|
|
B
|
|
|
|
C
|
|
|
|
D
|
|
|
|
F
|
|
|
|
H
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ cd $TESTTMP
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2011-10-15 21:07:51 +04:00
|
|
|
Rebasing E onto H:
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg clone -q -u $H a a2
|
2010-10-01 18:10:06 +04:00
|
|
|
$ cd a2
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg rebase --source $E --collapse --dest $H
|
|
|
|
rebasing 2:7fb047a69f22 "E"
|
|
|
|
rebasing 5:c6001eacfde5 "G"
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -Gr 'all()' -T '{desc}'
|
|
|
|
o Collapsed revision
|
2010-10-01 18:10:06 +04:00
|
|
|
| * E
|
2019-02-13 08:39:24 +03:00
|
|
|
| * G
|
|
|
|
| o D
|
|
|
|
| |
|
|
|
|
@ | H
|
|
|
|
| |
|
|
|
|
| o C
|
2010-10-01 18:10:06 +04:00
|
|
|
| |
|
2019-02-13 08:39:24 +03:00
|
|
|
o | F
|
2010-10-01 18:10:06 +04:00
|
|
|
| |
|
2019-02-13 08:39:24 +03:00
|
|
|
| o B
|
2010-10-01 18:10:06 +04:00
|
|
|
|/
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg manifest --rev tip
|
2010-10-01 18:10:06 +04:00
|
|
|
A
|
|
|
|
E
|
|
|
|
F
|
|
|
|
H
|
|
|
|
|
|
|
|
$ cd ..
|
|
|
|
|
2011-03-15 20:33:36 +03:00
|
|
|
Rebasing G onto H with custom message:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg clone -q -u $H a a3
|
2011-03-15 20:33:36 +03:00
|
|
|
$ cd a3
|
|
|
|
|
|
|
|
$ hg rebase --base 6 -m 'custom message'
|
|
|
|
abort: message can only be specified with collapse
|
|
|
|
[255]
|
|
|
|
|
2014-08-15 18:05:53 +04:00
|
|
|
$ cat > $TESTTMP/checkeditform.sh <<EOF
|
|
|
|
> env | grep HGEDITFORM
|
|
|
|
> true
|
|
|
|
> EOF
|
2019-02-13 08:39:24 +03:00
|
|
|
$ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg rebase --source $E --collapse -m 'custom message' -e --dest $H
|
|
|
|
rebasing 2:7fb047a69f22 "E"
|
|
|
|
rebasing 5:c6001eacfde5 "G"
|
2014-08-15 18:05:53 +04:00
|
|
|
HGEDITFORM=rebase.collapse
|
2011-03-15 20:33:36 +03:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -Gr 'all()' -T '{desc}'
|
|
|
|
o custom message
|
2011-03-15 20:33:36 +03:00
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
| o D
|
|
|
|
| |
|
|
|
|
@ | H
|
2011-03-15 20:33:36 +03:00
|
|
|
| |
|
2019-02-13 08:39:24 +03:00
|
|
|
| o C
|
2011-03-15 20:33:36 +03:00
|
|
|
| |
|
2019-02-13 08:39:24 +03:00
|
|
|
o | F
|
|
|
|
| |
|
|
|
|
| o B
|
2011-03-15 20:33:36 +03:00
|
|
|
|/
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
2011-03-15 20:33:36 +03:00
|
|
|
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg manifest --rev tip
|
2011-03-15 20:33:36 +03:00
|
|
|
A
|
|
|
|
E
|
|
|
|
F
|
|
|
|
H
|
|
|
|
|
|
|
|
$ cd ..
|
2010-10-01 18:10:06 +04:00
|
|
|
|
|
|
|
Create repo b:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo b
|
|
|
|
$ drawdag <<'EOS'
|
|
|
|
> o H
|
|
|
|
> |
|
|
|
|
> | o G
|
|
|
|
> | |\
|
|
|
|
> | | o F
|
|
|
|
> | | |
|
|
|
|
> | | o E
|
|
|
|
> | | |
|
|
|
|
> | o | D # D/D=D
|
|
|
|
> | |\|
|
|
|
|
> | o | C
|
|
|
|
> |/ /
|
|
|
|
> | o B
|
|
|
|
> |/
|
|
|
|
> o A
|
|
|
|
> EOS
|
|
|
|
$ cd $TESTTMP
|
2010-10-01 18:10:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
Rebase and collapse - more than one external (fail):
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg clone -q -u $H b b1
|
2010-10-01 18:10:06 +04:00
|
|
|
$ cd b1
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg rebase -s $C --dest $H --collapse
|
|
|
|
abort: unable to collapse on top of 3, there is more than one external parent: 1, 6
|
2010-10-01 18:10:06 +04:00
|
|
|
[255]
|
|
|
|
|
|
|
|
Rebase and collapse - E onto H:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg rebase -s $E --dest $H --collapse # root (E) is not a merge
|
|
|
|
rebasing 5:49cb92066bfd "E"
|
|
|
|
rebasing 6:11abe3fb10b8 "F"
|
|
|
|
rebasing 7:202d1982ae8b "G" (tip)
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -Gr 'all()' -T '{desc}'
|
|
|
|
o Collapsed revision
|
2010-10-01 18:10:06 +04:00
|
|
|
|\ * E
|
|
|
|
| | * F
|
2019-02-13 08:39:24 +03:00
|
|
|
| | * G
|
|
|
|
| o D
|
|
|
|
| |\
|
|
|
|
@ | | H
|
|
|
|
| | |
|
|
|
|
+---o C
|
2010-10-01 18:10:06 +04:00
|
|
|
| |
|
2019-02-13 08:39:24 +03:00
|
|
|
| o B
|
2010-10-01 18:10:06 +04:00
|
|
|
|/
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg manifest --rev tip
|
2010-10-01 18:10:06 +04:00
|
|
|
A
|
|
|
|
C
|
|
|
|
D
|
|
|
|
E
|
|
|
|
F
|
|
|
|
H
|
|
|
|
|
|
|
|
Create repo c:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo c
|
|
|
|
$ drawdag <<'EOS'
|
|
|
|
> o I
|
|
|
|
> |
|
|
|
|
> | o H
|
|
|
|
> | |\
|
|
|
|
> | | o G
|
|
|
|
> | | |
|
|
|
|
> | | o F # F/E=F\n
|
|
|
|
> | | | # F/F=(removed)
|
|
|
|
> | | o E
|
|
|
|
> | | |
|
|
|
|
> | o | D # D/D=D
|
|
|
|
> | |\|
|
|
|
|
> | o | C
|
|
|
|
> |/ /
|
|
|
|
> | o B
|
|
|
|
> |/
|
|
|
|
> o A
|
|
|
|
> EOS
|
|
|
|
$ cd $TESTTMP
|
2010-10-01 18:10:06 +04:00
|
|
|
|
|
|
|
Rebase and collapse - E onto I:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg clone -q -u $I c c1
|
2010-10-01 18:10:06 +04:00
|
|
|
$ cd c1
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg rebase -s $E --dest $I --collapse # root (E) is not a merge
|
|
|
|
rebasing 5:49cb92066bfd "E"
|
|
|
|
rebasing 6:3cf8a9483881 "F"
|
2010-10-01 18:10:06 +04:00
|
|
|
merging E
|
2019-02-13 08:39:24 +03:00
|
|
|
rebasing 7:066fd31e12b9 "G"
|
|
|
|
rebasing 8:c8947cb2e149 "H" (tip)
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -Gr 'all()' -T '{desc}'
|
|
|
|
o Collapsed revision
|
2010-10-01 18:10:06 +04:00
|
|
|
|\ * E
|
|
|
|
| | * F
|
|
|
|
| | * G
|
2019-02-13 08:39:24 +03:00
|
|
|
| | * H
|
|
|
|
| o D
|
|
|
|
| |\
|
|
|
|
@ | | I
|
|
|
|
| | |
|
|
|
|
+---o C
|
2010-10-01 18:10:06 +04:00
|
|
|
| |
|
2019-02-13 08:39:24 +03:00
|
|
|
| o B
|
2010-10-01 18:10:06 +04:00
|
|
|
|/
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg manifest --rev tip
|
2010-10-01 18:10:06 +04:00
|
|
|
A
|
|
|
|
C
|
|
|
|
D
|
|
|
|
E
|
|
|
|
G
|
|
|
|
I
|
|
|
|
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg up tip -q
|
2010-10-01 18:10:06 +04:00
|
|
|
$ cat E
|
|
|
|
F
|
|
|
|
|
|
|
|
Create repo d:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo d
|
|
|
|
$ drawdag <<'EOS'
|
|
|
|
> o F
|
|
|
|
> |
|
|
|
|
> | o E
|
|
|
|
> | |\
|
|
|
|
> | | o D
|
|
|
|
> | | |
|
|
|
|
> | o | C
|
|
|
|
> | |/
|
|
|
|
> | o B
|
|
|
|
> |/
|
|
|
|
> o A
|
|
|
|
> EOS
|
|
|
|
$ cd $TESTTMP
|
2010-10-01 18:10:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
Rebase and collapse - B onto F:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg clone -q -u $F d d1
|
2010-10-01 18:10:06 +04:00
|
|
|
$ cd d1
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg rebase -s $B --collapse --dest $F
|
|
|
|
rebasing 1:112478962961 "B"
|
|
|
|
rebasing 3:26805aba1e60 "C"
|
|
|
|
rebasing 4:be0ef73c17ad "D"
|
|
|
|
rebasing 5:02c4367d6973 "E" (tip)
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -Gr 'all()' -T '{desc}'
|
|
|
|
o Collapsed revision
|
2010-10-01 18:10:06 +04:00
|
|
|
| * B
|
|
|
|
| * C
|
|
|
|
| * D
|
2019-02-13 08:39:24 +03:00
|
|
|
| * E
|
|
|
|
@ F
|
2010-10-01 18:10:06 +04:00
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
2010-10-01 18:10:06 +04:00
|
|
|
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg manifest --rev tip
|
2010-10-01 18:10:06 +04:00
|
|
|
A
|
|
|
|
B
|
|
|
|
C
|
|
|
|
D
|
|
|
|
F
|
|
|
|
|
2012-04-30 00:25:55 +04:00
|
|
|
Rebase, collapse and copies
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo copies
|
|
|
|
$ drawdag << 'EOS'
|
|
|
|
> Q # Q/c=c\n (renamed from f)
|
|
|
|
> | # Q/g=b\n (renamed from e)
|
|
|
|
> |
|
|
|
|
> P # P/d=a\n (copied from a)
|
|
|
|
> | # P/e=b\n (renamed from b)
|
|
|
|
> | # P/f=c\n (renamed from c)
|
|
|
|
> |
|
|
|
|
> | Y # Y/a=a\na\n
|
|
|
|
> |/ # Y/b=b\nb\n
|
|
|
|
> | # Y/c=c\nc\n
|
|
|
|
> |
|
|
|
|
> | # X/a=a\n
|
|
|
|
> X # X/b=b\n
|
|
|
|
> # X/c=c\n
|
|
|
|
> # drawdag.defaultfiles=false
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ hg up -q $Q
|
|
|
|
$ hg rebase --collapse -d $Y
|
|
|
|
rebasing 1:24b95cf2173d "P"
|
2012-04-30 00:25:55 +04:00
|
|
|
merging a and d to d
|
|
|
|
merging b and e to e
|
|
|
|
merging c and f to f
|
2019-02-13 08:39:24 +03:00
|
|
|
rebasing 3:2ccc3426bf6d "Q" (tip)
|
2012-04-30 00:25:55 +04:00
|
|
|
merging f and c to c
|
2014-03-02 21:52:16 +04:00
|
|
|
merging e and g to g
|
2012-04-30 00:25:55 +04:00
|
|
|
$ hg st
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg st --copies --change tip
|
2012-04-30 00:25:55 +04:00
|
|
|
A d
|
|
|
|
a
|
|
|
|
A g
|
|
|
|
b
|
|
|
|
R b
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg up tip -q
|
2012-04-30 00:25:55 +04:00
|
|
|
$ cat c
|
|
|
|
c
|
|
|
|
c
|
|
|
|
$ cat d
|
|
|
|
a
|
|
|
|
a
|
|
|
|
$ cat g
|
|
|
|
b
|
|
|
|
b
|
|
|
|
$ hg log -r . --template "{file_copies}\n"
|
|
|
|
d (a)g (b)
|
rebase: allow collapsing branches in place (issue3111)
We allow rebase plus collapse, but not collapse only? I imagine people would
rebase first then collapse once they are sure the rebase is correct and it is
the right time to finish it.
I was reluctant to submit this patch for reasons detailed below, but it
improves rebase --collapse usefulness so much it is worth the ugliness.
The fix is ugly because we should be fixing the collapse code path rather than
the merge. Collapsing by merging changesets repeatedly is inefficient compared
to what commit --amend does: commitctx(), update, strip. The problem with the
latter is, to generate the synthetic changeset, copy records are gathered with
copies.pathcopies(). copies.pathcopies() is still implemented with merging in
mind and discards information like file replaced by the copy of another,
criss-cross copies and so forth. I believe this information should not be lost,
even if we decide not to interpret it fully later, at merge time.
The second issue with improving rebase --collapse is the option should not be
there to begin with. Rebasing and collapsing are orthogonal and a dedicated
command would probably enable a better, simpler ui. We should avoid advertizing
rebase --collapse, but with this fix it becomes the best shipped solution to
collapse changesets.
And for the record, available techniques are:
- revert + commit + strip: lose copies
- mq/qfold: repeated patching() (mostly correct, fragile)
- rebase: repeated merges (mostly correct, fragile)
- collapse: revert + tag rewriting wizardry, lose copies
- histedit: repeated patching() (mostly correct, fragile)
- amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -Gr 'all()' -T '{desc}'
|
|
|
|
@ Collapsed revision
|
|
|
|
| * P
|
|
|
|
| * Q
|
|
|
|
o Y
|
rebase: allow collapsing branches in place (issue3111)
We allow rebase plus collapse, but not collapse only? I imagine people would
rebase first then collapse once they are sure the rebase is correct and it is
the right time to finish it.
I was reluctant to submit this patch for reasons detailed below, but it
improves rebase --collapse usefulness so much it is worth the ugliness.
The fix is ugly because we should be fixing the collapse code path rather than
the merge. Collapsing by merging changesets repeatedly is inefficient compared
to what commit --amend does: commitctx(), update, strip. The problem with the
latter is, to generate the synthetic changeset, copy records are gathered with
copies.pathcopies(). copies.pathcopies() is still implemented with merging in
mind and discards information like file replaced by the copy of another,
criss-cross copies and so forth. I believe this information should not be lost,
even if we decide not to interpret it fully later, at merge time.
The second issue with improving rebase --collapse is the option should not be
there to begin with. Rebasing and collapsing are orthogonal and a dedicated
command would probably enable a better, simpler ui. We should avoid advertizing
rebase --collapse, but with this fix it becomes the best shipped solution to
collapse changesets.
And for the record, available techniques are:
- revert + commit + strip: lose copies
- mq/qfold: repeated patching() (mostly correct, fragile)
- rebase: repeated merges (mostly correct, fragile)
- collapse: revert + tag rewriting wizardry, lose copies
- histedit: repeated patching() (mostly correct, fragile)
- amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
o X
|
rebase: allow collapsing branches in place (issue3111)
We allow rebase plus collapse, but not collapse only? I imagine people would
rebase first then collapse once they are sure the rebase is correct and it is
the right time to finish it.
I was reluctant to submit this patch for reasons detailed below, but it
improves rebase --collapse usefulness so much it is worth the ugliness.
The fix is ugly because we should be fixing the collapse code path rather than
the merge. Collapsing by merging changesets repeatedly is inefficient compared
to what commit --amend does: commitctx(), update, strip. The problem with the
latter is, to generate the synthetic changeset, copy records are gathered with
copies.pathcopies(). copies.pathcopies() is still implemented with merging in
mind and discards information like file replaced by the copy of another,
criss-cross copies and so forth. I believe this information should not be lost,
even if we decide not to interpret it fully later, at merge time.
The second issue with improving rebase --collapse is the option should not be
there to begin with. Rebasing and collapsing are orthogonal and a dedicated
command would probably enable a better, simpler ui. We should avoid advertizing
rebase --collapse, but with this fix it becomes the best shipped solution to
collapse changesets.
And for the record, available techniques are:
- revert + commit + strip: lose copies
- mq/qfold: repeated patching() (mostly correct, fragile)
- rebase: repeated merges (mostly correct, fragile)
- collapse: revert + tag rewriting wizardry, lose copies
- histedit: repeated patching() (mostly correct, fragile)
- amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
|
|
|
|
|
|
|
Test collapsing in place
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg rebase --collapse -b . -d $X
|
|
|
|
rebasing 2:71cf332de4cf "Y"
|
|
|
|
rebasing 4:c2a9a5beba1a "Collapsed revision" (tip)
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg st --change tip --copies
|
rebase: allow collapsing branches in place (issue3111)
We allow rebase plus collapse, but not collapse only? I imagine people would
rebase first then collapse once they are sure the rebase is correct and it is
the right time to finish it.
I was reluctant to submit this patch for reasons detailed below, but it
improves rebase --collapse usefulness so much it is worth the ugliness.
The fix is ugly because we should be fixing the collapse code path rather than
the merge. Collapsing by merging changesets repeatedly is inefficient compared
to what commit --amend does: commitctx(), update, strip. The problem with the
latter is, to generate the synthetic changeset, copy records are gathered with
copies.pathcopies(). copies.pathcopies() is still implemented with merging in
mind and discards information like file replaced by the copy of another,
criss-cross copies and so forth. I believe this information should not be lost,
even if we decide not to interpret it fully later, at merge time.
The second issue with improving rebase --collapse is the option should not be
there to begin with. Rebasing and collapsing are orthogonal and a dedicated
command would probably enable a better, simpler ui. We should avoid advertizing
rebase --collapse, but with this fix it becomes the best shipped solution to
collapse changesets.
And for the record, available techniques are:
- revert + commit + strip: lose copies
- mq/qfold: repeated patching() (mostly correct, fragile)
- rebase: repeated merges (mostly correct, fragile)
- collapse: revert + tag rewriting wizardry, lose copies
- histedit: repeated patching() (mostly correct, fragile)
- amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
|
|
|
M a
|
|
|
|
M c
|
|
|
|
A d
|
|
|
|
a
|
|
|
|
A g
|
|
|
|
b
|
|
|
|
R b
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg up tip -q
|
rebase: allow collapsing branches in place (issue3111)
We allow rebase plus collapse, but not collapse only? I imagine people would
rebase first then collapse once they are sure the rebase is correct and it is
the right time to finish it.
I was reluctant to submit this patch for reasons detailed below, but it
improves rebase --collapse usefulness so much it is worth the ugliness.
The fix is ugly because we should be fixing the collapse code path rather than
the merge. Collapsing by merging changesets repeatedly is inefficient compared
to what commit --amend does: commitctx(), update, strip. The problem with the
latter is, to generate the synthetic changeset, copy records are gathered with
copies.pathcopies(). copies.pathcopies() is still implemented with merging in
mind and discards information like file replaced by the copy of another,
criss-cross copies and so forth. I believe this information should not be lost,
even if we decide not to interpret it fully later, at merge time.
The second issue with improving rebase --collapse is the option should not be
there to begin with. Rebasing and collapsing are orthogonal and a dedicated
command would probably enable a better, simpler ui. We should avoid advertizing
rebase --collapse, but with this fix it becomes the best shipped solution to
collapse changesets.
And for the record, available techniques are:
- revert + commit + strip: lose copies
- mq/qfold: repeated patching() (mostly correct, fragile)
- rebase: repeated merges (mostly correct, fragile)
- collapse: revert + tag rewriting wizardry, lose copies
- histedit: repeated patching() (mostly correct, fragile)
- amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
|
|
|
$ cat a
|
|
|
|
a
|
|
|
|
a
|
|
|
|
$ cat c
|
|
|
|
c
|
|
|
|
c
|
|
|
|
$ cat d
|
|
|
|
a
|
|
|
|
a
|
|
|
|
$ cat g
|
|
|
|
b
|
|
|
|
b
|
2019-02-13 08:39:24 +03:00
|
|
|
$ cd $TESTTMP
|
2012-05-18 23:45:47 +04:00
|
|
|
|
|
|
|
|
2013-03-15 22:23:29 +04:00
|
|
|
Test collapsing changes that add then remove a file
|
2012-05-18 23:45:47 +04:00
|
|
|
|
2013-03-15 22:23:29 +04:00
|
|
|
$ hg init collapseaddremove
|
|
|
|
$ cd collapseaddremove
|
2012-05-18 23:45:47 +04:00
|
|
|
|
2013-03-15 22:23:29 +04:00
|
|
|
$ touch base
|
|
|
|
$ hg commit -Am base
|
|
|
|
adding base
|
|
|
|
$ touch a
|
|
|
|
$ hg commit -Am a
|
|
|
|
adding a
|
|
|
|
$ hg rm a
|
|
|
|
$ touch b
|
|
|
|
$ hg commit -Am b
|
|
|
|
adding b
|
2013-11-02 04:08:06 +04:00
|
|
|
$ hg book foo
|
2013-03-15 22:23:29 +04:00
|
|
|
$ hg rebase -d 0 -r "1::2" --collapse -m collapsed
|
2014-12-09 05:45:26 +03:00
|
|
|
rebasing 1:6d8d9f24eec3 "a"
|
2017-09-20 08:06:26 +03:00
|
|
|
rebasing 2:1cc73eca5ecc "b" (foo tip)
|
2013-11-02 04:08:06 +04:00
|
|
|
$ hg log -G --template "{rev}: '{desc}' {bookmarks}"
|
2019-02-13 08:39:24 +03:00
|
|
|
@ 3: 'collapsed' foo
|
2013-03-15 22:23:29 +04:00
|
|
|
|
|
2013-11-02 04:08:06 +04:00
|
|
|
o 0: 'base'
|
2013-03-15 22:23:29 +04:00
|
|
|
|
2013-10-14 18:49:54 +04:00
|
|
|
$ hg manifest --rev tip
|
2013-03-15 22:23:29 +04:00
|
|
|
b
|
|
|
|
base
|
2012-05-18 23:45:47 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ cd $TESTTMP
|
2016-02-18 00:45:01 +03:00
|
|
|
|
|
|
|
Test that rebase --collapse will remember message after
|
|
|
|
running into merge conflict and invoking rebase --continue.
|
|
|
|
|
|
|
|
$ hg init collapse_remember_message
|
|
|
|
$ cd collapse_remember_message
|
|
|
|
$ touch a
|
|
|
|
$ hg add a
|
|
|
|
$ hg commit -m "a"
|
|
|
|
$ echo "a-default" > a
|
|
|
|
$ hg commit -m "a-default"
|
|
|
|
$ hg update -r 0
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ echo "a-dev" > a
|
|
|
|
$ hg commit -m "a-dev"
|
|
|
|
$ hg rebase --collapse -m "a-default-dev" -d 1
|
2019-02-13 08:39:24 +03:00
|
|
|
rebasing 2:1fb04abbc715 "a-dev" (tip)
|
2016-02-18 00:45:01 +03:00
|
|
|
merging a
|
2018-10-22 22:45:46 +03:00
|
|
|
warning: 1 conflicts while merging a! (edit, then use 'hg resolve --mark')
|
2016-02-18 00:45:01 +03:00
|
|
|
unresolved conflicts (see hg resolve, then hg rebase --continue)
|
|
|
|
[1]
|
|
|
|
$ rm a.orig
|
|
|
|
$ hg resolve --mark a
|
|
|
|
(no more unresolved files)
|
|
|
|
continue: hg rebase --continue
|
|
|
|
$ hg rebase --continue
|
2019-02-13 08:39:24 +03:00
|
|
|
rebasing 2:1fb04abbc715 "a-dev" (tip)
|
2016-02-18 00:45:01 +03:00
|
|
|
$ hg log
|
2019-02-13 08:39:24 +03:00
|
|
|
changeset: 3:3f6f2136305e
|
2016-02-18 00:45:01 +03:00
|
|
|
tag: tip
|
2019-02-13 08:39:24 +03:00
|
|
|
parent: 1:3c8db56a44bc
|
2016-02-18 00:45:01 +03:00
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: a-default-dev
|
|
|
|
|
|
|
|
changeset: 1:3c8db56a44bc
|
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: a-default
|
|
|
|
|
|
|
|
changeset: 0:3903775176ed
|
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: a
|
|
|
|
|
|
|
|
$ cd ..
|