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

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

Comments

Yuya Nishihara - Nov. 14, 2018, 1:32 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.
Pulkit Goyal - Nov. 14, 2018, 5:57 p.m.
On Wed, Nov 14, 2018 at 4:34 PM Yuya Nishihara <yuya@tcha.org> wrote:

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

Queued this series, many thanks!

Patch

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: