evolve: make sure we consider all cases in if-else
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 18 Mar 2018 01:27:02 +0530
changeset 3545 6aff754c2457
parent 3544 329056287ef5
child 3546 d197e6f0d0e3
evolve: make sure we consider all cases in if-else The part of code which is touched decides on evolution of merge changeset. We need proper handling of each case there, so before adding logic, let's add conditional for each case so that upcoming patches are easy to understand.
hgext3rd/evolve/evolvecmd.py
--- a/hgext3rd/evolve/evolvecmd.py	Mon Mar 19 14:03:41 2018 +0100
+++ b/hgext3rd/evolve/evolvecmd.py	Sun Mar 18 01:27:02 2018 +0530
@@ -91,10 +91,14 @@
     pctx = orig.p1()
     keepbranch = orig.p1().branch() != orig.branch()
     if len(orig.parents()) == 2:
-        if not pctx.obsolete():
+        p1obs = orig.p1().obsolete()
+        p2obs = orig.p2().obsolete()
+        if not p1obs and p2obs:
             pctx = orig.p2()  # second parent is obsolete ?
             keepbranch = orig.p2().branch() != orig.branch()
-        elif orig.p2().obsolete():
+        elif not p2obs and p1obs:
+            pass
+        else:
             hint = _("Redo the merge (%s) and use `hg prune <old> "
                      "--succ <new>` to obsolete the old one") % orig.hex()[:12]
             ui.warn(_("warning: no support for evolving merge changesets "