# HG changeset patch # User Pierre-Yves David # Date 1611284389 -3600 # Node ID 1319abf8d8c4d981204ede07eb89f3e0be56a787 # Parent e6b0ed34bc18eee0a481f5afded08c70663f1875 divergence-resolution: pre-indent some code This will make the coming change clearer. diff -r e6b0ed34bc18 -r 1319abf8d8c4 hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py Thu Oct 22 21:12:50 2020 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Fri Jan 22 03:59:49 2021 +0100 @@ -336,15 +336,6 @@ # the changeset on which resolution changeset will be based on resolutionparent = succsdivp1 - # the nullrev has to be handled specially because -1 is overloaded to both - # mean nullrev (this meaning is used for the result of changectx.rev(), as - # called above) and the tipmost revision (this meaning is used for the %d - # format specifier, as used below) - if nodemod.nullrev in (succsotherp1, succsdivp1): - # nullrev is the only possible ancestor if succsotherp1 or succsdivp1 is nullrev - gca = [nodemod.nullrev] - else: - gca = repo.revs(b"ancestor(%d, %d)" % (succsotherp1, succsdivp1)) # divonly: non-obsolete csets which are topological ancestor of "divergent" # but not "other" divonly = repo.revs(b"only(%d, %d) - obsolete()" % (divergent.rev(), @@ -376,39 +367,49 @@ elif divergent == other.p1(): # both are in parent-child relation pass - elif succsotherp1 in gca and succsdivp1 in gca: - # both are not on the same parent but have same parents's succs. - if otheronly and divonly: - # case: we have visible csets on both side diverging from - # tca of "divergent" and "other". We still need to decide what - # to do in this case - pass - if otheronly: - resolutionparent = succsotherp1 - elif divonly: - pass + else: + # the nullrev has to be handled specially because -1 is overloaded to both + # mean nullrev (this meaning is used for the result of changectx.rev(), as + # called above) and the tipmost revision (this meaning is used for the %d + # format specifier, as used below) + if nodemod.nullrev in (succsotherp1, succsdivp1): + # nullrev is the only possible ancestor if succsotherp1 or succsdivp1 is nullrev + gca = [nodemod.nullrev] else: - # no extra cset on either side + gca = repo.revs(b"ancestor(%d, %d)" % (succsotherp1, succsdivp1)) + + if succsotherp1 in gca and succsdivp1 in gca: + # both are not on the same parent but have same parents's succs. + if otheronly and divonly: + # case: we have visible csets on both side diverging from + # tca of "divergent" and "other". We still need to decide what + # to do in this case + pass + if otheronly: + resolutionparent = succsotherp1 + elif divonly: + pass + else: + # no extra cset on either side + pass + elif succsotherp1 in gca and succsdivp1 not in gca: pass - elif succsotherp1 in gca and succsdivp1 not in gca: - pass - elif succsdivp1 in gca and succsotherp1 not in gca: - resolutionparent = succsotherp1 - else: - msg = _(b"skipping %s: have a different parent than %s " - b"(not handled yet)\n") % (divergent, other) - hint = _(b"| %(d)s, %(o)s are not based on the same changeset.\n" - b"| With the current state of its implementation,\n" - b"| evolve does not work in that case.\n" - b"| rebase one of them next to the other and run\n" - b"| this command again.\n" - b"| - either: hg rebase --dest 'p1(%(d)s)' -r %(o)s\n" - b"| - or: hg rebase --dest 'p1(%(o)s)' -r %(d)s\n" - ) % {b'd': divergent, b'o': other} - ui.write_err(msg) - ui.write_err(hint) - return (False, b".") - + elif succsdivp1 in gca and succsotherp1 not in gca: + resolutionparent = succsotherp1 + else: + msg = _(b"skipping %s: have a different parent than %s " + b"(not handled yet)\n") % (divergent, other) + hint = _(b"| %(d)s, %(o)s are not based on the same changeset.\n" + b"| With the current state of its implementation,\n" + b"| evolve does not work in that case.\n" + b"| rebase one of them next to the other and run\n" + b"| this command again.\n" + b"| - either: hg rebase --dest 'p1(%(d)s)' -r %(o)s\n" + b"| - or: hg rebase --dest 'p1(%(o)s)' -r %(d)s\n" + ) % {b'd': divergent, b'o': other} + ui.write_err(msg) + ui.write_err(hint) + return (False, b".") return (True, resolutionparent) def _relocatedivergent(repo, orig, dest, evolvestate):