Mercurial > evolve
changeset 5726:1319abf8d8c4
divergence-resolution: pre-indent some code
This will make the coming change clearer.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 22 Jan 2021 03:59:49 +0100 |
parents | e6b0ed34bc18 |
children | bc323205241b |
files | hgext3rd/evolve/evolvecmd.py |
diffstat | 1 files changed, 41 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- 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):