Changeset - c662d42e1f9c
[Not reviewed]
default
0 2 0
Mads Kiilerich - 6 years ago 2019-05-27 00:12:15
mads@kiilerich.com
Grafted from: de56f63a3c3c
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.
2 files changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -26,13 +26,13 @@ from kallithea.lib.vcs.utils import (
 
    author_email, author_name, date_fromtimestamp, makedate, safe_unicode, safe_str,
 
)
 
from kallithea.lib.vcs.utils.lazy import LazyProperty
 
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
 
)
 

	
 
from .changeset import MercurialChangeset
 
from .inmemory import MercurialInMemoryChangeset
 
@@ -261,13 +261,13 @@ class MercurialRepository(BaseRepository
 
        # Check if given revisions are present at repository (may raise
 
        # ChangesetDoesNotExistError)
 
        if rev1 != self.EMPTY_CHANGESET:
 
            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
 

	
 
        return ''.join(patch.diff(self._repo, rev1, rev2, match=file_filter,
 
                          opts=diffopts(git=True,
 
                                        showfunc=True,
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
@@ -18,13 +18,13 @@ from mercurial import sshpeer
 
from mercurial import obsutil
 
from mercurial.commands import clone, nullid, pull
 
from mercurial.context import memctx, memfilectx
 
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
 
from mercurial.discovery import findcommonoutgoing
 
from mercurial.hg import peer
 
from mercurial.util import url as hg_url
 
@@ -42,6 +42,10 @@ localrepo.localrepository.lfstatus = Fal
 
import inspect
 
if inspect.getargspec(memfilectx.__init__).args[7] != 'copysource':
 
    assert inspect.getargspec(memfilectx.__init__).args[7] == 'copied', inspect.getargspec(memfilectx.__init__).args
 
    __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)
0 comments (0 inline, 0 general)