Ejemplo n.º 1
0
        def log(self, event, *msg, **opts):
            global lastblackbox
            super(blackboxui, self).log(event, *msg, **opts)

            if not '*' in self.track and not event in self.track:
                return

            if util.safehasattr(self, '_blackbox'):
                blackbox = self._blackbox
            elif util.safehasattr(self, '_bbopener'):
                try:
                    self._blackbox = self._openlogfile()
                except (IOError, OSError) as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                    del self._bbopener
                    self._blackbox = None
                blackbox = self._blackbox
            else:
                # certain ui instances exist outside the context of
                # a repo, so just default to the last blackbox that
                # was seen.
                blackbox = lastblackbox

            if blackbox:
                date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
                user = util.getuser()
                formattedmsg = msg[0] % msg[1:]
                try:
                    blackbox.write('%s %s> %s' % (date, user, formattedmsg))
                except IOError as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                lastblackbox = blackbox
Ejemplo n.º 2
0
        def log(self, event, *msg, **opts):
            global lastui
            super(blackboxui, self).log(event, *msg, **opts)
            self._partialinit()

            if not '*' in self.track and not event in self.track:
                return

            if self._bbfp:
                ui = self
            elif self._bbvfs:
                try:
                    self._bbfp = self._openlogfile()
                except (IOError, OSError) as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                    del self._bbvfs
                    self._bbfp = None
                ui = self
            else:
                # 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 or not ui._bbfp:
                return
            if not lastui or ui._bbrepo:
                lastui = ui
            if ui._bbinlog:
                # recursion guard
                return
            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 ui._bbrepo:
                    ctx = ui._bbrepo[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._bbwrite('%s %s @%s%s (%s)%s> %s', date, user, rev,
                                changed, pid, src, formattedmsg)
                except IOError as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
            finally:
                ui._bbinlog = False
Ejemplo n.º 3
0
        def log(self, event, *msg, **opts):
            global lastblackbox
            super(blackboxui, self).log(event, *msg, **opts)

            if not '*' in self.track and not event in self.track:
                return

            if util.safehasattr(self, '_blackbox'):
                blackbox = self._blackbox
            elif util.safehasattr(self, '_bbopener'):
                try:
                    self._blackbox = self._openlogfile()
                except (IOError, OSError) as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                    del self._bbopener
                    self._blackbox = None
                blackbox = self._blackbox
            else:
                # certain ui instances exist outside the context of
                # a repo, so just default to the last blackbox that
                # was seen.
                blackbox = lastblackbox

            if blackbox:
                date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
                user = util.getuser()
                formattedmsg = msg[0] % msg[1:]
                try:
                    blackbox.write('%s %s> %s' % (date, user, formattedmsg))
                except IOError as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                lastblackbox = blackbox
Ejemplo n.º 4
0
    def __init__(self, repo):
        self.user = util.getuser()
        self.ui = repo.ui
        self.vfs = repo.vfs

        # is this working copy using a shared storage?
        self.sharedfeatures = self.sharedvfs = None
        if repo.shared():
            features = _readsharedfeatures(repo)
            sharedrepo = share._getsrcrepo(repo)
            if sharedrepo is not None and 'journal' in features:
                self.sharedvfs = sharedrepo.vfs
                self.sharedfeatures = features
Ejemplo n.º 5
0
    def __init__(self, repo):
        self.user = util.getuser()
        self.ui = repo.ui
        self.vfs = repo.vfs

        # is this working copy using a shared storage?
        self.sharedfeatures = self.sharedvfs = None
        if repo.shared():
            features = _readsharedfeatures(repo)
            sharedrepo = share._getsrcrepo(repo)
            if sharedrepo is not None and 'journal' in features:
                self.sharedvfs = sharedrepo.vfs
                self.sharedfeatures = features
Ejemplo n.º 6
0
        def log(self, event, *msg, **opts):
            global lastui
            super(blackboxui, self).log(event, *msg, **opts)
            self._partialinit()

            if not '*' in self.track and not event in self.track:
                return

            if self._bbfp:
                ui = self
            elif self._bbvfs:
                try:
                    self._bbfp = self._openlogfile()
                except (IOError, OSError) as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                    del self._bbvfs
                    self._bbfp = None
                ui = self
            else:
                # 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 or not ui._bbfp:
                return
            if not lastui or ui._bbrepo:
                lastui = ui
            if ui._bbinlog:
                # recursion guard
                return
            try:
                ui._bbinlog = True
                date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
                user = util.getuser()
                pid = str(util.getpid())
                formattedmsg = msg[0] % msg[1:]
                rev = '(unknown)'
                changed = ''
                if ui._bbrepo:
                    ctx = ui._bbrepo[None]
                    parents = ctx.parents()
                    rev = ('+'.join([hex(p.node()) for p in parents]))
                    if (ui.configbool('blackbox', 'dirty', False) and (
                        any(ui._bbrepo.status()) or
                        any(ctx.sub(s).dirty() for s in ctx.substate)
                    )):
                        changed = '+'
                if ui.configbool('blackbox', 'logsource', False):
                    src = ' [%s]' % event
                else:
                    src = ''
                try:
                    ui._bbwrite('%s %s @%s%s (%s)%s> %s',
                        date, user, rev, changed, pid, src, formattedmsg)
                except IOError as err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
            finally:
                ui._bbinlog = False
Ejemplo n.º 7
0
                    self._blackbox = self._openlogfile()
                except (IOError, OSError), err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                    del self._bbopener
                    self._blackbox = None
                blackbox = self._blackbox
            else:
                # certain ui instances exist outside the context of
                # a repo, so just default to the last blackbox that
                # was seen.
                blackbox = lastblackbox

            if blackbox:
                date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
                user = util.getuser()
                formattedmsg = msg[0] % msg[1:]
                try:
                    blackbox.write('%s %s> %s' % (date, user, formattedmsg))
                except IOError, err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                lastblackbox = blackbox

        def setrepo(self, repo):
            self._bbopener = repo.opener

    ui.__class__ = blackboxui

def uisetup(ui):
    wrapui(ui)
Ejemplo n.º 8
0
                    self._blackbox = self._openlogfile()
                except (IOError, OSError), err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                    del self._bbopener
                    self._blackbox = None
                blackbox = self._blackbox
            else:
                # certain ui instances exist outside the context of
                # a repo, so just default to the last blackbox that
                # was seen.
                blackbox = lastblackbox

            if blackbox:
                date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
                user = util.getuser()
                formattedmsg = msg[0] % msg[1:]
                try:
                    blackbox.write('%s %s> %s' % (date, user, formattedmsg))
                except IOError, err:
                    self.debug('warning: cannot write to blackbox.log: %s\n' %
                               err.strerror)
                lastblackbox = blackbox

        def setrepo(self, repo):
            self._bbopener = repo.opener

    ui.__class__ = blackboxui


def uisetup(ui):