# HG changeset patch # User Martin von Zweigbergk # Date 1556042528 25200 # Node ID 5ba885e2ef5e086531eb6406d2bda6d7ccb83c7c # Parent 5450c8069a37504ad4960a0a871cbd8aef3a97b4 evolve: reduce indentation with an early return statement diff -r 5450c8069a37 -r 5ba885e2ef5e 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."""