D3716: ui: add an uninterruptable context manager that can block SIGINT

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Thu Jun 28 08:16:32 EDT 2018


yuja added a comment.


  > +    @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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3716

To: durin42, #hg-reviewers, indygreg
Cc: spectral, indygreg, yuja, martinvonz, mercurial-devel


More information about the Mercurial-devel mailing list