Skip to content
Snippets Groups Projects
Commit 8315175f authored by Matt Harbison's avatar Matt Harbison
Browse files

unionrepo: fix mismatches with revlog classes

This is a subset of cfd30df0f8e4, applied to `unionrepository`.  There are none
of the `write()` method overrides here, like `bundlerepository`.

With these changes, pytype flags the `unionrevlog` constructor:

    File "/mnt/c/Users/Matt/hg/mercurial/unionrepo.py", line 55, in __init__:
        No attribute '_revlog' on mercurial.changelog.changelog [attribute-error]
    Called from (traceback):
      line 207, in __init__
    File "/mnt/c/Users/Matt/hg/mercurial/unionrepo.py", line 55, in __init__:
        No attribute '_revlog' on mercurial.revlog.revlog [attribute-error]
    Called from (traceback):
      line 232, in __init__

But it turns out that both `changelog.changelog` and `revlog.revlog` do have a
`target` attribute, so they wouldn't trip over this.  It seems weird that the
second caller to be flagged is passing the private `_revlog`, but maybe that's
how it needs to be.
parent 1b17309c
No related branches found
No related tags found
3 merge requests!1041Merge default into stable,!997tests: use shlex.quote instead of pipes.quote,!951Apply recent BundleRepository fixes to UnionRepository
......@@ -39,7 +39,9 @@
class unionrevlog(revlog.revlog):
def __init__(self, opener, radix, revlog2, linkmapper):
def __init__(self, opener: typing.Any, radix, revlog2, linkmapper):
# TODO: figure out real type of opener
#
# How it works:
# To retrieve a revision, we just need to know the node id so we can
# look it up in revlog2.
......@@ -49,6 +51,10 @@
opener = vfsmod.readonlyvfs(opener)
target = getattr(revlog2, 'target', None)
if target is None:
# Help pytype- changelog and revlog are not possible here because
# they both have a 'target' attr.
assert not isinstance(revlog2, (changelog.changelog, revlog.revlog))
# a revlog wrapper, eg: the manifestlog that is not an actual revlog
target = revlog2._revlog.target
revlog.revlog.__init__(self, opener, target=target, radix=radix)
......@@ -131,7 +137,7 @@
def _chunk(self, rev):
if rev <= self.repotiprev:
return revlog.revlog._chunk(self, rev)
return super(unionrevlog, self)._inner._chunk(rev)
return self.revlog2._chunk(self.node(rev))
def revdiff(self, rev1, rev2):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment