##// 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:

r52756:f4733654 default
r53341:cdb45eb7 default
Show More
mpatch.py
51 lines | 1.5 KiB | text/x-python | PythonLexer
# mpatch.py - CFFI implementation of mpatch.c
#
# Copyright 2016 Maciej Fijalkowski <fijall@gmail.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import annotations
from typing import List
from ..pure.mpatch import *
from ..pure.mpatch import mpatchError # silence pyflakes
from . import _mpatch # pytype: disable=import-error
ffi = _mpatch.ffi
lib = _mpatch.lib
@ffi.def_extern()
def cffi_get_next_item(arg, pos):
all, bins = ffi.from_handle(arg)
container = ffi.new("struct mpatch_flist*[1]")
to_pass = ffi.new("char[]", bytes(bins[pos]))
all.append(to_pass)
r = lib.mpatch_decode(to_pass, len(to_pass) - 1, container)
if r < 0:
return ffi.NULL
return container[0]
def patches(text: bytes, bins: List[bytes]) -> bytes:
lgt = len(bins)
all = []
if not lgt:
return text
arg = (all, bins)
patch = lib.mpatch_fold(ffi.new_handle(arg), lib.cffi_get_next_item, 0, lgt)
if not patch:
raise mpatchError(b"cannot decode chunk")
outlen = lib.mpatch_calcsize(len(text), patch)
if outlen < 0:
lib.mpatch_lfree(patch)
raise mpatchError(b"inconsistency detected")
buf = ffi.new("char[]", outlen)
if lib.mpatch_apply(buf, text, len(text), patch) < 0:
lib.mpatch_lfree(patch)
raise mpatchError(b"error applying patches")
res = ffi.buffer(buf, outlen)[:]
lib.mpatch_lfree(patch)
return res