[PATCH 1 of 5] blackbox: remove redundant check for unassigned repo

Yuya Nishihara yuya at tcha.org
Wed Nov 14 13:32:38 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1541921689 -32400
#      Sun Nov 11 16:34:49 2018 +0900
# Node ID cac5ea779ab85b840da04b2947d11b7ec2de9f61
# Parent  29e4a77b5305df7b14d04b99cba03f1a079dd1fc
blackbox: remove redundant check for unassigned repo

Since ui._bbvfs is looked through ui._bbrepo, the repo instance should
exist if ui._bbvfs isn't None.

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -169,9 +169,9 @@ def wrapui(ui):
             if not vfs:
                 return
 
-            repo = getattr(ui, '_bbrepo', None)
-            if not lastui or repo:
-                lastui = ui
+            repo = ui._bbrepo
+            lastui = ui
+
             if getattr(ui, '_bbinlog', False):
                 # recursion and failure guard
                 return
@@ -184,13 +184,12 @@ def wrapui(ui):
             formattedmsg = msg[0] % msg[1:]
             rev = '(unknown)'
             changed = ''
-            if repo:
-                ctx = repo[None]
-                parents = ctx.parents()
-                rev = ('+'.join([hex(p.node()) for p in parents]))
-                if (ui.configbool('blackbox', 'dirty') and
-                    ctx.dirty(missing=True, merge=False, branch=False)):
-                    changed = '+'
+            ctx = repo[None]
+            parents = ctx.parents()
+            rev = ('+'.join([hex(p.node()) for p in parents]))
+            if (ui.configbool('blackbox', 'dirty') and
+                ctx.dirty(missing=True, merge=False, branch=False)):
+                changed = '+'
             if ui.configbool('blackbox', 'logsource'):
                 src = ' [%s]' % event
             else:


More information about the Mercurial-devel mailing list