##// END OF EJS Templates
git: drop the zope `repository.ifilestorage` decoration on `gitlog.filelog`...
git: drop the zope `repository.ifilestorage` decoration on `gitlog.filelog` The next logical step is to disable the conditional import of `zope` in the `mercurial.interfaces.util` module, and just run with the no-op decorators. But doing that then generates these pytype errors: File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 485, in read: No attribute 'gitrepo' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 495, in lookup: No attribute 'gitrepo' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 505, in add: No attribute 'gitrepo' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 508, in __iter__: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 522, in rev: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 534, in node: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 549, in parents: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 556, in parents: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 564, in parents: No attribute 'gitrepo' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 564, in parents: No attribute '_db' on filelog [attribute-error] I'm not sure what exactly the issue is, but the pyi file that was being generated up to this point has `filelog` typed as `Any` (because it had a decorator, and pytype chokes on that), and `baselog` was typed as a class. So it apparently can't see the `_db` and `gitrepo` attributes of the subclass, because it doesn't think `filelog` is a class. Leave the decorator commented out so it hits when searching for the remaining zope things that need to be updated to Protocol.

File last commit:

r53247:d4e30c15 default
r53341:cdb45eb7 default
Show More
ps_util.py
53 lines | 1.3 KiB | text/x-python | PythonLexer
# This python code can be imported into tests in order to terminate a process
# with signal.SIGKILL on posix, or a roughly equivalent procedure on Windows.
from __future__ import annotations
import os
import signal
import subprocess
import sys
import tempfile
from .. import (
encoding,
pycompat,
)
from ..utils import procutil
def kill_nt(pid: int, exit_code: int):
fd, pidfile = tempfile.mkstemp(
prefix=b"sigkill-", dir=encoding.environ[b"HGTMP"], text=False
)
try:
os.write(fd, b'%d\n' % pid)
finally:
os.close(fd)
env = dict(encoding.environ)
env[b"DAEMON_EXITCODE"] = b"%d" % exit_code
# Simulate the message written to stderr for this process on non-Windows
# platforms, for test consistency.
print("Killed!", file=sys.stderr)
subprocess.run(
[
encoding.environ[b"PYTHON"],
b"%s/killdaemons.py"
% encoding.environ[b'RUNTESTDIR_FORWARD_SLASH'],
pidfile,
],
env=procutil.tonativeenv(env),
)
def kill(pid: int):
"""Kill the process with the given PID with SIGKILL or equivalent."""
if pycompat.iswindows:
exit_code = 128 + 9
kill_nt(pid, exit_code)
else:
os.kill(pid, signal.SIGKILL)