Exemplo n.º 1
0
    def run(self):
        RepoHookCommand.run(self)

        if self.hook.is_remote_debug_enabled:
            args = (
                self.hook.remote_debug_host,
                self.hook.remote_debug_port,
                self.hook_name,
                self.hook_dir,
                self.options,
                self.conf,
            )
            self.rdb = RemoteDebugSession(*args)
            self.rdb.set_trace()

        with RepositoryHook(**self.repo_kwds) as r:
            try:
                r.run_hook(self.hook_name, self.hook_args)
            except Exception as exc:
                (exc_type, exc_value, exc_tb) = sys.exc_info()
                # XXX TODO: if it's a pre-commit, try extract info about the
                # incoming commit, i.e. svn log -v type output for the txn.

                if isinstance(exc, RepositoryError):
                    self._err(exc.args[0])
                    sys.exit(1)
                else:
                    m = "Repository %s hook failed (hook args: %s):%s%s"
                    args = ', '.join('%s' % repr(a) for a in self.hook_args)
                    e = ''.join(traceback.format_exception(*sys.exc_info()))
                    err = m % (self.hook_name, args, os.linesep, e)
                    # XXX TODO: err, log this somewhere.
                    raise exc
Exemplo n.º 2
0
    def run(self):
        RepoHookCommand.run(self)

        h = self.hook_file(self.hook_name)
        if not h.needs_fixing:
            raise CommandError(
                "Hook '%s' for repository '%s' "
                "does not need fixing." % (
                    self.hook_name,
                    self.name,
                )
            )

        self._out("Fixing repository hook '%s'..." % self.hook_name)
        if not h.exists or h.is_empty:
            self._out("    Creating new file.")
            h.create()

        if not h.executable:
            self._out("    Setting correct file permissions.")
            h.fix_perms()

        if not h.configured:
            self._out("    Configuring for use with Enversion.")
            h.configure()

        assert not h.needs_fixing
        self._out("Done!")
Exemplo n.º 3
0
    def run(self):
        RepoHookCommand.run(self)

        if self.hook.is_remote_debug_enabled:
            args = (
                self.hook.remote_debug_host,
                self.hook.remote_debug_port,
                self.hook_name,
                self.hook_dir,
                self.options,
                self.conf,
            )
            self.rdb = RemoteDebugSession(*args)
            self.rdb.set_trace()

        with RepositoryHook(**self.repo_kwds) as r:
            r.rdb = self.rdb
            try:
                r.run_hook(self.hook_name, self.hook_args)
            except Exception as exc:
                (exc_type, exc_value, exc_tb) = sys.exc_info()
                # XXX TODO: if it's a pre-commit, try extract info about the
                # incoming commit, i.e. svn log -v type output for the txn.

                if isinstance(exc, RepositoryError):
                    self._err(exc.args[0])
                    sys.exit(1)
                else:
                    m = "Repository %s hook failed (hook args: %s):%s%s"
                    args = ', '.join('%s' % repr(a) for a in self.hook_args)
                    e = ''.join(traceback.format_exception(*sys.exc_info()))
                    err = m % (self.hook_name, args, os.linesep, e)
                    sys.stderr.write(err)
                    raise exc
Exemplo n.º 4
0
    def run(self):
        RepoHookCommand.run(self)

        h = self.hook_file(self.hook_name)
        if not h.needs_fixing:
            raise CommandError(
                "Hook '%s' for repository '%s' "
                "does not need fixing." % (
                    self.hook_name,
                    self.name,
                )
            )

        self._out("Fixing repository hook '%s'..." % self.hook_name)
        if not h.exists or h.is_empty:
            self._out("    Creating new file.")
            h.create()

        if not h.executable:
            self._out("    Setting correct file permissions.")
            h.fix_perms()

        if not h.configured:
            self._out("    Configuring for use with Enversion.")
            h.configure()

        assert not h.needs_fixing
        self._out("Done!")
Exemplo n.º 5
0
    def run(self):
        RepoHookCommand.run(self)

        assert self.action in ('enable', 'disable', 'toggle')

        h = self.hook_file(self.hook_name)

        if self.toggle:
            self.action = self._invert(h.is_remote_debug_enabled)

        if self.enable:
            host = self.options.remote_debug_host
            port = self.options.remote_debug_port

        if h.is_remote_debug_enabled:
            if self.enable:
                (rhost, rport) = (h.remote_debug_host, h.remote_debug_port)
                args = (h.name, host, port)
                if host != rhost or port != rport:
                    m = (
                        "Updating %s hook to listen on "
                        "%s:%d instead of %s:%d."
                    )
                    self._out(m % (h.name, host, port, rhost, rport))
                    h.disable_remote_debug()
                    h.enable_remote_debug(host, port)
                else:
                    m = "%s hook already configured to listen on %s:%d."
                    self._warn(m % (h.name, host, port))
            else:
                self._out("Disabling remote debug for %s hook." % h.name)
                h.disable_remote_debug()
        else:
            if self.enable:
                m = (
                    "Enabling remote debug for %s hook "
                    "(listening for connections on %s:%d)."
                )
                self._out(m % (h.name, host, port))
                h.enable_remote_debug(host, port)
            else:
                m = "Remote debug not enabled for %s hook." % h.name
                self._warn(m)
Exemplo n.º 6
0
    def run(self):
        RepoHookCommand.run(self)

        assert self.action in ('enable', 'disable', 'toggle')

        h = self.hook_file(self.hook_name)

        if self.toggle:
            self.action = self._invert(h.is_remote_debug_enabled)

        if self.enable:
            host = self.options.remote_debug_host
            port = self.options.remote_debug_port

        if h.is_remote_debug_enabled:
            if self.enable:
                (rhost, rport) = (h.remote_debug_host, h.remote_debug_port)
                args = (h.name, host, port)
                if host != rhost or port != rport:
                    m = (
                        "Updating %s hook to listen on "
                        "%s:%d instead of %s:%d."
                    )
                    self._out(m % (h.name, host, port, rhost, rport))
                    h.disable_remote_debug()
                    h.enable_remote_debug(host, port)
                else:
                    m = "%s hook already configured to listen on %s:%d."
                    self._warn(m % (h.name, host, port))
            else:
                self._out("Disabling remote debug for %s hook." % h.name)
                h.disable_remote_debug()
        else:
            if self.enable:
                m = (
                    "Enabling remote debug for %s hook "
                    "(listening for connections on %s:%d)."
                )
                self._out(m % (h.name, host, port))
                h.enable_remote_debug(host, port)
            else:
                m = "Remote debug not enabled for %s hook." % h.name
                self._warn(m)