hgext/blackbox.py
changeset 18831 17f6644a2fbc
parent 18810 ac0336471ba7
child 19052 63a783d1ac85
equal deleted inserted replaced
18830:6b827d84d286 18831:17f6644a2fbc
    45             if not '*' in self.track and not event in self.track:
    45             if not '*' in self.track and not event in self.track:
    46                 return
    46                 return
    47 
    47 
    48             if util.safehasattr(self, '_blackbox'):
    48             if util.safehasattr(self, '_blackbox'):
    49                 blackbox = self._blackbox
    49                 blackbox = self._blackbox
       
    50             elif util.safehasattr(self, '_bbopener'):
       
    51                 try:
       
    52                     self._blackbox = self._bbopener('blackbox.log', 'a')
       
    53                 except (IOError, OSError), err:
       
    54                     self.debug('warning: cannot write to blackbox.log: %s\n' %
       
    55                                err.strerror)
       
    56                     del self._bbopener
       
    57                     self._blackbox = None
       
    58                 blackbox = self._blackbox
    50             else:
    59             else:
    51                 # certain ui instances exist outside the context of
    60                 # certain ui instances exist outside the context of
    52                 # a repo, so just default to the last blackbox that
    61                 # a repo, so just default to the last blackbox that
    53                 # was seen.
    62                 # was seen.
    54                 blackbox = lastblackbox
    63                 blackbox = lastblackbox
    63                     self.debug('warning: cannot write to blackbox.log: %s\n' %
    72                     self.debug('warning: cannot write to blackbox.log: %s\n' %
    64                                err.strerror)
    73                                err.strerror)
    65                 lastblackbox = blackbox
    74                 lastblackbox = blackbox
    66 
    75 
    67         def setrepo(self, repo):
    76         def setrepo(self, repo):
    68             try:
    77             self._bbopener = repo.opener
    69                 self._blackbox = repo.opener('blackbox.log', 'a')
       
    70             except (IOError, OSError), err:
       
    71                 self.debug('warning: cannot write to blackbox.log: %s\n' %
       
    72                            err.strerror)
       
    73                 self._blackbox = None
       
    74 
    78 
    75     ui.__class__ = blackboxui
    79     ui.__class__ = blackboxui
    76 
    80 
    77 def uisetup(ui):
    81 def uisetup(ui):
    78     wrapui(ui)
    82     wrapui(ui)