Mercurial > evolve
diff tests/test-fold.t @ 4723:41885988921e
fold: allow operations on merge commits with some conditions
It's possible to fold revision chains that include a single merge commit: just
fold everything into the merge commit while saving its other parent (so it
continues being a merge commit). It's also possible to fold revisions that
include multiple merge commits, on the condition that they merge with not more
than 2 external changesets (i.e. a changesets that aren't going to be folded).
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 11 Jul 2019 18:07:03 +0800 |
parents | 5300be965515 |
children | f7bf347a17bb 0852dcba82f6 |
line wrap: on
line diff
--- a/tests/test-fold.t Thu Jul 11 17:04:08 2019 +0800 +++ b/tests/test-fold.t Thu Jul 11 18:07:03 2019 +0800 @@ -7,9 +7,17 @@ > fold=-d "0 0" > [extensions] > evolve= + > [alias] + > glog = log -GT "{rev}: {desc}" + > glf = log -GT "{rev}: {desc} ({files})" > [ui] > logtemplate = '{rev} - {node|short} {desc|firstline} [{author}] ({phase}) {bookmarks}\n' > EOF + $ mkcommit() { + > echo "$1" > "$1" + > hg add "$1" + > hg ci -qm "$1" + > } $ hg init fold-tests $ cd fold-tests/ @@ -270,3 +278,106 @@ $ cd .. +One merge commit + + $ hg init fold-a-merge + $ cd fold-a-merge + + $ mkcommit zebra + + $ hg up null + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ mkcommit apple + $ mkcommit banana + + $ hg merge + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (branch merge, don't forget to commit) + $ hg ci -m merge + + $ mkcommit coconut + + $ hg glf + @ 4: coconut (coconut) + | + o 3: merge () + |\ + | o 2: banana (banana) + | | + | o 1: apple (apple) + | + o 0: zebra (zebra) + + +now we merge some of the fruits + + $ hg fold --exact -r 'desc("banana")::desc("coconut")' -m 'banana+coconut in a merge with zebra' + 3 changesets folded + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg glf + @ 5: banana+coconut in a merge with zebra (banana coconut) + |\ + | o 1: apple (apple) + | + o 0: zebra (zebra) + + +let's go even further: zebra becomes a parent of the squashed fruit commit + + $ hg fold --from -r 'desc("apple")' -m 'apple+banana+coconut is a child of zebra' + 2 changesets folded + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg glf + @ 6: apple+banana+coconut is a child of zebra (apple banana coconut) + | + o 0: zebra (zebra) + + +make sure zebra exists at tip and has expected contents + + $ hg cat -r tip zebra + zebra + + $ cd .. + +Multiple merge commits + + $ hg init fold-many-merges + $ cd fold-many-merges + + $ hg debugbuilddag '+3 *3 /3 /4 /4' + $ hg glog + o 6: r6 + |\ + | o 5: r5 + | |\ + | | o 4: r4 + | |/| + | | o 3: r3 + | | | + o | | 2: r2 + |/ / + o / 1: r1 + |/ + o 0: r0 + + +cannot fold 5 and 6 because they have 3 external parents in total: 1, 2, 4 + + $ hg fold --exact -r 5:6 -m r5+r6 + abort: cannot fold revisions that merge with more than one external changeset (not in revisions) + [255] + +now many of the parents are included in the revisions to fold, only 0 and 3 are external + + $ hg fold --exact -r 1+2+4+5+6 -m r1+r2+r4+r5+r6 + 5 changesets folded + + $ hg glog + o 7: r1+r2+r4+r5+r6 + |\ + | o 3: r3 + |/ + o 0: r0 + + $ cd ..