diff --git a/mercurial/osutil.c b/mercurial/osutil.c --- a/mercurial/osutil.c +++ b/mercurial/osutil.c @@ -613,6 +613,11 @@ static PyObject *statfiles(PyObject *sel int ret, kind; char *path; + /* With a large file count or on a slow filesystem, + don't block signals for long (issue4878). */ + if ((i % 1000) == 999 && PyErr_CheckSignals() == -1) + goto bail; + pypath = PySequence_GetItem(names, i); if (!pypath) goto bail;