# HG changeset patch # User Mads Kiilerich # Date 2019-05-27 00:12:15 # Node ID c662d42e1f9c29844eb7cc6dbd893bed4c16deca # Parent eda137096b3f9592c3193b28add69b50de8fd5ca hg: prepare for Mercurial 5.0 changing "exact" arguments In the backward compat wrapper, we use root=None. That might seem a bit risky. But it seems to work for the single use case we have, and the changeset dropped it in Mercurial https://www.mercurial-scm.org/repo/hg/rev/0531dff73d0b hint that this parameter really is unused. diff --git a/kallithea/lib/vcs/backends/hg/repository.py b/kallithea/lib/vcs/backends/hg/repository.py --- a/kallithea/lib/vcs/backends/hg/repository.py +++ b/kallithea/lib/vcs/backends/hg/repository.py @@ -29,7 +29,7 @@ from kallithea.lib.vcs.utils.lazy import from kallithea.lib.vcs.utils.ordered_dict import OrderedDict from kallithea.lib.vcs.utils.paths import abspath from kallithea.lib.vcs.utils.hgcompat import ( - ui, nullid, match, patch, diffopts, clone, get_contact, + ui, nullid, match, match_exact, patch, diffopts, clone, get_contact, localrepo, RepoLookupError, Abort, RepoError, hex, scmutil, hg_url, httpbasicauthhandler, httpdigestauthhandler, peer, httppeer, sshpeer, tag ) @@ -264,7 +264,7 @@ class MercurialRepository(BaseRepository self.get_changeset(rev1) self.get_changeset(rev2) if path: - file_filter = match(self.path, '', [path], exact=True) + file_filter = match_exact(path) else: file_filter = None diff --git a/kallithea/lib/vcs/utils/hgcompat.py b/kallithea/lib/vcs/utils/hgcompat.py --- a/kallithea/lib/vcs/utils/hgcompat.py +++ b/kallithea/lib/vcs/utils/hgcompat.py @@ -21,7 +21,7 @@ from mercurial.context import memctx, me from mercurial.error import RepoError, RepoLookupError, Abort from mercurial.hgweb import hgweb_mod from mercurial.hgweb.common import get_contact -from mercurial.match import match +from mercurial.match import match, exact as match_exact from mercurial.mdiff import diffopts from mercurial.node import hex from mercurial.encoding import tolocal @@ -45,3 +45,7 @@ if inspect.getargspec(memfilectx.__init_ __org_memfilectx_ = memfilectx memfilectx = lambda repo, changectx, path, data, islink=False, isexec=False, copysource=None: \ __org_memfilectx_(repo, changectx, path, data, islink=islink, isexec=isexec, copied=copysource) + +# Mercurial 5.0 dropped exact argument for match in 635a12c53ea6, and 0531dff73d0b made the exact function stable with a single parameter +if inspect.getargspec(match_exact).args[0] != 'files': + match_exact = lambda path: match(None, '', [path], exact=True)