view tests/notcapable @ 51685:0eb515c7bec8

typing: add trivial type hints to the convert extension's common modules This started as ensuring that the `encoding` and `orig_encoding` attributes has a type other than `Any`, so pytype can catch problems where it needs to be str for stdlib encoding and decoding. It turns out that adding the hint in `mercurial.encoding` is what was needed, but I picked a bunch of low hanging fruit while here. There's definitely more to do, and I see a problem where `shlex.shlex` is being fed bytes instead of str, but there are not enough type hints yet to make pytype notice.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 11 Jul 2024 20:54:06 -0400
parents 3a2df812e1c7
children
line wrap: on
line source

# Disable the $CAP wire protocol capability.

if test -z "$CAP"
then
    echo "CAP environment variable not set."
fi

cat > notcapable-$CAP.py << EOF
from mercurial import extensions, localrepo
from mercurial.interfaces import repository
def extsetup(ui):
    extensions.wrapfunction(repository.peer, 'capable', wrapcapable)
    extensions.wrapfunction(localrepo.localrepository, 'peer', wrappeer)
def wrapcapable(orig, self, name, *args, **kwargs):
    if name in b'$CAP'.split(b' '):
        return False
    return orig(self, name, *args, **kwargs)
def wrappeer(orig, self, *args, **kwargs):
    # Since we're disabling some newer features, we need to make sure local
    # repos add in the legacy features again.
    return localrepo.locallegacypeer(self, *args, **kwargs)
EOF

echo '[extensions]' >> $HGRCPATH
echo "notcapable-$CAP = `pwd`/notcapable-$CAP.py" >> $HGRCPATH