Patchwork [2,of,5] blackbox: consolidate conditions for early return

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 14, 2018, 1:32 p.m.
Message ID <e5def171282a30ea82ba.1542202359@mimosa>
Download mbox | patch
Permalink /patch/36574/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 14, 2018, 1:32 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1541921923 -32400
#      Sun Nov 11 16:38:43 2018 +0900
# Node ID e5def171282a30ea82bad7b5319308d655224685
# Parent  cac5ea779ab85b840da04b2947d11b7ec2de9f61
blackbox: consolidate conditions for early return

Just pick the lastui only if it is usable.

Patch

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -157,18 +157,15 @@  def wrapui(ui):
 
             if self._bbvfs:
                 ui = self
-            else:
+            elif lastui and lastui._bbvfs:
                 # certain ui instances exist outside the context of
                 # a repo, so just default to the last blackbox that
                 # was seen.
                 ui = lastui
-
-            if not ui:
-                return
-            vfs = ui._bbvfs
-            if not vfs:
+            else:
                 return
 
+            vfs = ui._bbvfs
             repo = ui._bbrepo
             lastui = ui