evolve: reduce indentation with an early return statement
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 23 Apr 2019 11:02:08 -0700
changeset 4589 5ba885e2ef5e
parent 4588 5450c8069a37
child 4590 784ad6f60571
evolve: reduce indentation with an early return statement
hgext3rd/evolve/evolvecmd.py
--- a/hgext3rd/evolve/evolvecmd.py	Tue Apr 23 11:01:44 2019 -0700
+++ b/hgext3rd/evolve/evolvecmd.py	Tue Apr 23 11:02:08 2019 -0700
@@ -1932,38 +1932,40 @@
             return
 
         # make sure we are continuing evolve and not `hg next --evolve`
-        if evolvestate['command'] == 'evolve':
-            category = evolvestate['category']
-            confirm = evolvestate['confirm']
-            unfi = repo.unfiltered()
-            # lastsolved: keep track of successor of last troubled cset we
-            # evolved to confirm that if atop msg should be suppressed to remove
-            # redundancy
-            lastsolved = None
-            activetopic = getattr(repo, 'currenttopic', '')
-            for rev in evolvestate['revs']:
-                # XXX: prevent this lookup by storing nodes instead of revnums
-                curctx = unfi[rev]
+        if evolvestate['command'] != 'evolve':
+            return
+
+        category = evolvestate['category']
+        confirm = evolvestate['confirm']
+        unfi = repo.unfiltered()
+        # lastsolved: keep track of successor of last troubled cset we
+        # evolved to confirm that if atop msg should be suppressed to remove
+        # redundancy
+        lastsolved = None
+        activetopic = getattr(repo, 'currenttopic', '')
+        for rev in evolvestate['revs']:
+            # XXX: prevent this lookup by storing nodes instead of revnums
+            curctx = unfi[rev]
 
-                # check if we can use stack template
-                revtopic = getattr(curctx, 'topic', lambda: '')()
-                topicidx = getattr(curctx, 'topicidx', lambda: None)()
-                stacktmplt = False
-                if (activetopic and (activetopic == revtopic)
-                    and topicidx is not None):
-                    stacktmplt = True
+            # check if we can use stack template
+            revtopic = getattr(curctx, 'topic', lambda: '')()
+            topicidx = getattr(curctx, 'topicidx', lambda: None)()
+            stacktmplt = False
+            if (activetopic and (activetopic == revtopic)
+                and topicidx is not None):
+                stacktmplt = True
 
-                if (curctx.node() not in evolvestate['replacements']
-                    and curctx.node() not in evolvestate['skippedrevs']):
-                    newnode = _solveone(ui, repo, curctx, evolvestate, False,
-                                        confirm, progresscb, category,
-                                        lastsolved=lastsolved,
-                                        stacktmplt=stacktmplt)
-                    if newnode[0]:
-                        evolvestate['replacements'][curctx.node()] = newnode[1]
-                        lastsolved = newnode[1]
-                    else:
-                        evolvestate['skippedrevs'].append(curctx.node())
+            if (curctx.node() not in evolvestate['replacements']
+                and curctx.node() not in evolvestate['skippedrevs']):
+                newnode = _solveone(ui, repo, curctx, evolvestate, False,
+                                    confirm, progresscb, category,
+                                    lastsolved=lastsolved,
+                                    stacktmplt=stacktmplt)
+                if newnode[0]:
+                    evolvestate['replacements'][curctx.node()] = newnode[1]
+                    lastsolved = newnode[1]
+                else:
+                    evolvestate['skippedrevs'].append(curctx.node())
 
 def _continuecontentdivergent(ui, repo, evolvestate, progresscb):
     """function to continue the interrupted content-divergence resolution."""