Mercurial > evolve
changeset 4467:6fc5e162ea84
evolve: refactor the code which swap two nodes (in divergence resolution)
I see that we are using the code to swap the "divergent" and "other" node;
and updating the evolvestate accordingly at many places in divergence
resolution. This patch extract that code to a function.
Although I don't have strong opinion on this patch. It's a volunteered
patch to remove some redundancy.
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Wed, 03 Apr 2019 01:00:33 +0530 |
parents | cc4506838589 |
children | a2273aa71a4b |
files | hgext3rd/evolve/evolvecmd.py |
diffstat | 1 files changed, 8 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py Tue Apr 02 18:01:43 2019 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Wed Apr 03 01:00:33 2019 +0530 @@ -376,6 +376,11 @@ evolvestate['other-divergent'] = other.node() evolvestate['base'] = base.node() + def swapnodes(div, other): + div, other = other, div + evolvestate['divergent'] = div.node() + evolvestate['other-divergent'] = other.node() + return div, other # haspubdiv: to keep track if we are solving public content-divergence haspubdiv = False if not (divergent.mutable() and other.mutable()): @@ -384,9 +389,7 @@ # (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() + divergent, other = swapnodes(divergent, other) else: publicdiv = divergent evolvestate['public-divergent'] = publicdiv.node() @@ -461,9 +464,7 @@ relocatereq = True if not haspubdiv: # can't swap when public divergence, as public can't move - divergent, other = other, divergent - evolvestate['divergent'] = divergent.node() - evolvestate['other-divergent'] = other.node() + divergent, other = swapnodes(divergent, other) resolutionparent = repo[otherp1].node() elif divonly: relocatereq = True @@ -485,9 +486,7 @@ # 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() + divergent, other = swapnodes(divergent, other) resolutionparent = divergent.p1().node() else: msg = _("skipping %s: have a different parent than %s "