Mercurial > evolve
changeset 4444:ea336a6592cc
evolve: test a common case of public divergence
evolve: in pubdiv, handle the case when public branch is behind the mutable
In public divergence, when public branch is behind the mutable one the behaviour
that this patch added is that we relocate the draft one to public side.
This should be fine in most case, but might be an issue in some other (eg, when
the draft side of the divergence is rebase away from ancestors it relies on.)
Test written by Pierre-Yves David <pierre-yves.david@octobus.net>
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 24 Mar 2019 21:30:12 +0530 |
parents | fc2214916f50 |
children | 5205e3dedafc |
files | hgext3rd/evolve/evolvecmd.py tests/test-evolve-public-content-divergent.t |
diffstat | 2 files changed, 323 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py Sun Mar 24 21:29:44 2019 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Sun Mar 24 21:30:12 2019 +0530 @@ -378,15 +378,18 @@ # haspubdiv: to keep track if we are solving public content-divergence haspubdiv = False - if not other.mutable(): + if not (divergent.mutable() and other.mutable()): haspubdiv = True - publicdiv = other - evolvestate['public-divergent'] = other.node() - # for simplicity, lets keep public one to local side while merging the - # two csets.(local side is divergent one) - divergent, other = other, divergent - evolvestate['divergent'] = divergent.node() - evolvestate['other-divergent'] = other.node() + # for simplicity, we keep public one to local side while merging + # (as divergent is kept at local side, pinning public -> divergent) + if divergent.mutable(): + publicdiv = other + divergent, other = other, divergent + evolvestate['divergent'] = divergent.node() + evolvestate['other-divergent'] = other.node() + else: + publicdiv = divergent + evolvestate['public-divergent'] = publicdiv.node() # we don't handle merge content-divergent changesets yet if len(other.parents()) > 1: msg = _("skipping %s: %s changeset can't be " @@ -472,10 +475,20 @@ pass elif divp1 in gca and otherp1 not in gca: relocatereq = True - divergent, other = other, divergent - evolvestate['divergent'] = divergent.node() - evolvestate['other-divergent'] = other.node() - resolutionparent = divergent.p1().node() + + # When public branch is behind to the mutable branch, for now we + # relocate mutable cset to public one's side in every case. + # + # This behaviour might be sub optimal when ancestors of mutable + # cset has changes its relocated descendant rely on. + # + # Otherwise, we are going to rebase the "behind" branch up to the new + # brancmap level. + if not haspubdiv: + divergent, other = other, divergent + evolvestate['divergent'] = divergent.node() + evolvestate['other-divergent'] = other.node() + resolutionparent = divergent.p1().node() else: msg = _("skipping %s: have a different parent than %s " "(not handled yet)\n") % (divergent, other)
--- a/tests/test-evolve-public-content-divergent.t Sun Mar 24 21:29:44 2019 +0530 +++ b/tests/test-evolve-public-content-divergent.t Sun Mar 24 21:30:12 2019 +0530 @@ -1418,3 +1418,301 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: added d + + $ cd .. + +Test a pratical "rebase" case +============================= + +Initial setup + + $ hg init rebase-divergence + $ cd rebase-divergence + $ echo root >> root + $ hg add root + $ hg commit -m root + $ for x in c_A c_B c_C c_D; do + > echo $x >> $x + > hg add $x + > hg commit -m $x + > done + + $ hg up 'desc("c_A")' + 0 files updated, 0 files merged, 3 files removed, 0 files unresolved + + $ for x in c_E c_F; do + > echo $x >> $x + > hg add $x + > hg commit -m $x + > done + created new head + +(creating divergence locally for simplicity) + + $ node=`hg log --rev 'desc("c_E")' -T '{node}'` + $ hg rebase -s $node -d 'desc("c_B")' + rebasing 5:4ab2719bbab9 "c_E" + rebasing 6:77ccbf8d837e "c_F" (tip) + $ hg phase --public tip + $ hg rebase --hidden -s $node -d 'desc("c_C")' --config experimental.evolution.allowdivergence=yes + rebasing 5:4ab2719bbab9 "c_E" + rebasing 6:77ccbf8d837e "c_F" + 2 new content-divergent changesets + + $ hg sum + parent: 8:a52ac76b45f5 + c_F + branch: default + commit: (clean) + update: 4 new changesets, 3 branch heads (merge) + phases: 4 draft + content-divergent: 2 changesets + $ hg evolve --list + b4a584aea4bd: c_E + content-divergent: c7d2d47c7240 (public) (precursor 4ab2719bbab9) + + 8ae8db670b4a: c_F + content-divergent: a52ac76b45f5 (public) (precursor 77ccbf8d837e) + + $ hg log -G --patch + * changeset: 10:8ae8db670b4a + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | instability: content-divergent + | summary: c_F + | + | diff -r b4a584aea4bd -r 8ae8db670b4a c_F + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_F Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_F + | + * changeset: 9:b4a584aea4bd + | parent: 3:abb77b893f28 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | instability: content-divergent + | summary: c_E + | + | diff -r abb77b893f28 -r b4a584aea4bd c_E + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_E Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_E + | + | @ changeset: 8:a52ac76b45f5 + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: c_F + | | + | | diff -r c7d2d47c7240 -r a52ac76b45f5 c_F + | | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | | +++ b/c_F Thu Jan 01 00:00:00 1970 +0000 + | | @@ -0,0 +1,1 @@ + | | +c_F + | | + | o changeset: 7:c7d2d47c7240 + | | parent: 2:eb1b4e1205b8 + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: c_E + | | + | | diff -r eb1b4e1205b8 -r c7d2d47c7240 c_E + | | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | | +++ b/c_E Thu Jan 01 00:00:00 1970 +0000 + | | @@ -0,0 +1,1 @@ + | | +c_E + | | + +---o changeset: 4:dbb960d6c97c + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: c_D + | | + | | diff -r abb77b893f28 -r dbb960d6c97c c_D + | | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | | +++ b/c_D Thu Jan 01 00:00:00 1970 +0000 + | | @@ -0,0 +1,1 @@ + | | +c_D + | | + o | changeset: 3:abb77b893f28 + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: c_C + | + | diff -r eb1b4e1205b8 -r abb77b893f28 c_C + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_C Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_C + | + o changeset: 2:eb1b4e1205b8 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: c_B + | + | diff -r e31751786014 -r eb1b4e1205b8 c_B + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_B Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_B + | + o changeset: 1:e31751786014 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: c_A + | + | diff -r 1e4be0697311 -r e31751786014 c_A + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_A Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_A + | + o changeset: 0:1e4be0697311 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: root + + diff -r 000000000000 -r 1e4be0697311 root + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/root Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +root + + +Run automatic evolution + + $ hg evolve --content-divergent --rev 'not public() and desc("c_E")::' + merge:[7] c_E + with: [9] c_E + base: [5] c_E + rebasing "other" content-divergent changeset b4a584aea4bd on eb1b4e1205b8 + updating to "local" side of the conflict: c7d2d47c7240 + merging "other" content-divergent changeset '0773642cfa95' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 new orphan changesets + merge:[8] c_F + with: [10] c_F + base: [6] c_F + rebasing "other" content-divergent changeset 8ae8db670b4a on c7d2d47c7240 + updating to "local" side of the conflict: a52ac76b45f5 + merging "other" content-divergent changeset '6a87ed4aa317' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg sum + parent: 8:a52ac76b45f5 tip + c_F + branch: default + commit: (clean) + update: 2 new changesets, 2 branch heads (merge) + phases: 2 draft + + $ hg evolve --list + + $ hg log -G --patch + @ changeset: 8:a52ac76b45f5 + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: c_F + | + | diff -r c7d2d47c7240 -r a52ac76b45f5 c_F + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_F Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_F + | + o changeset: 7:c7d2d47c7240 + | parent: 2:eb1b4e1205b8 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: c_E + | + | diff -r eb1b4e1205b8 -r c7d2d47c7240 c_E + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_E Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_E + | + | o changeset: 4:dbb960d6c97c + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: c_D + | | + | | diff -r abb77b893f28 -r dbb960d6c97c c_D + | | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | | +++ b/c_D Thu Jan 01 00:00:00 1970 +0000 + | | @@ -0,0 +1,1 @@ + | | +c_D + | | + | o changeset: 3:abb77b893f28 + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: c_C + | + | diff -r eb1b4e1205b8 -r abb77b893f28 c_C + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_C Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_C + | + o changeset: 2:eb1b4e1205b8 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: c_B + | + | diff -r e31751786014 -r eb1b4e1205b8 c_B + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_B Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_B + | + o changeset: 1:e31751786014 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: c_A + | + | diff -r 1e4be0697311 -r e31751786014 c_A + | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + | +++ b/c_A Thu Jan 01 00:00:00 1970 +0000 + | @@ -0,0 +1,1 @@ + | +c_A + | + o changeset: 0:1e4be0697311 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: root + + diff -r 000000000000 -r 1e4be0697311 root + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/root Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +root + + $ hg export tip + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 +0000 + # Node ID a52ac76b45f523a039fc4a938d79874f4bdb1a85 + # Parent c7d2d47c7240562be5cbd1a24080dd0396178709 + c_F + + diff -r c7d2d47c7240 -r a52ac76b45f5 c_F + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/c_F Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +c_F + + $ hg obslog --rev a52ac76b45f5 + @ a52ac76b45f5 (8) c_F + |\ + x | 6a87ed4aa317 (12) c_F + | | rewritten as a52ac76b45f5 using evolve by test (Thu Jan 01 00:00:00 1970 +0000) + | | + x | 8ae8db670b4a (10) c_F + |/ rewritten(parent) as 6a87ed4aa317 using evolve by test (Thu Jan 01 00:00:00 1970 +0000) + | + x 77ccbf8d837e (6) c_F + rewritten(parent) as 8ae8db670b4a using rebase by test (Thu Jan 01 00:00:00 1970 +0000) + rewritten(parent) as a52ac76b45f5 using rebase by test (Thu Jan 01 00:00:00 1970 +0000) +