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

Yuya Nishihara yuya at tcha.org
Wed Nov 14 08:32:39 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at 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.

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
 


More information about the Mercurial-devel mailing list