blackbox: unindent a try block
authorJun Wu <quark@fb.com>
Wed, 06 Sep 2017 21:23:38 -0700
changeset 34275 86a5df995880
parent 34274 a37e18b5f055
child 34276 b90bd9a98c8b
blackbox: unindent a try block The try block is no longer necessary. Differential Revision: https://phab.mercurial-scm.org/D654
hgext/blackbox.py
--- a/hgext/blackbox.py	Mon Sep 18 15:56:08 2017 -0700
+++ b/hgext/blackbox.py	Wed Sep 06 21:23:38 2017 -0700
@@ -142,40 +142,37 @@
             if getattr(ui, '_bbinlog', False):
                 # recursion and failure guard
                 return
+            ui._bbinlog = True
+            default = self.configdate('devel', 'default-date')
+            date = util.datestr(default, '%Y/%m/%d %H:%M:%S')
+            user = util.getuser()
+            pid = '%d' % util.getpid()
+            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 = '+'
+            if ui.configbool('blackbox', 'logsource'):
+                src = ' [%s]' % event
+            else:
+                src = ''
             try:
-                ui._bbinlog = True
-                default = self.configdate('devel', 'default-date')
-                date = util.datestr(default, '%Y/%m/%d %H:%M:%S')
-                user = util.getuser()
-                pid = '%d' % util.getpid()
-                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 = '+'
-                if ui.configbool('blackbox', 'logsource'):
-                    src = ' [%s]' % event
-                else:
-                    src = ''
-                try:
-                    fmt = '%s %s @%s%s (%s)%s> %s'
-                    args = (date, user, rev, changed, pid, src, formattedmsg)
-                    with ui._openlogfile() as fp:
-                        fp.write(fmt % args)
-                except (IOError, OSError) as err:
-                    self.debug('warning: cannot write to blackbox.log: %s\n' %
-                               err.strerror)
-                    # do not restore _bbinlog intentionally to avoid failed
-                    # logging again
-                else:
-                    ui._bbinlog = False
-            finally:
-                pass
+                fmt = '%s %s @%s%s (%s)%s> %s'
+                args = (date, user, rev, changed, pid, src, formattedmsg)
+                with ui._openlogfile() as fp:
+                    fp.write(fmt % args)
+            except (IOError, OSError) as err:
+                self.debug('warning: cannot write to blackbox.log: %s\n' %
+                           err.strerror)
+                # do not restore _bbinlog intentionally to avoid failed
+                # logging again
+            else:
+                ui._bbinlog = False
 
         def setrepo(self, repo):
             self._bbrepo = repo