D3716: ui: add an uninterruptable context manager that can block SIGINT
Yuya Nishihara
yuya at tcha.org
Thu Jun 28 12:15:59 UTC 2018
> + @contextlib.contextmanager
> + def uninterruptable(self):
> + """Mark an operation as unsafe.
> +
> + Most operations on a repository are safe to interrupt, but a
> + few are risky (for example repair.strip). This context manager
> + lets you advise Mercurial that something risky is happening so
> + that control-C etc can be blocked if desired.
> + """
> + enabled = self.configbool('experimental', 'nointerrupt')
> + if (enabled and
> + self.configbool('experimental', 'nointerrupt-interactiveonly')):
> + enabled = self.interactive()
> + if self._uninterruptible or not enabled:
> + # if nointerrupt support is turned off, the process isn't
> + # interactive, or we're already in an uninterruptable
> + # block, do nothing.
> + yield
> + return
> + def warn():
> + self.warn(_("shutting down cleanly\n"))
> + self.warn(
> + _("press ^C again to terminate immediately (dangerous)\n"))
Missed `return True` ?
Other that that, the patch looks good to me.
More information about the Mercurial-devel
mailing list