Changeset - 1e8b300b0540
[Not reviewed]
default
0 7 0
Mads Kiilerich - 6 years ago 2019-12-25 15:39:33
mads@kiilerich.com
Grafted from: 812dba3a7a54
hg: bump minimum version to 5.1

We will soon move to Python 3 which only will support 5.1 or later.

Remove old hacks and tech debt.

Also avoids future warning:
DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
7 files changed with 11 insertions and 66 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/compare.py
Show inline comments
 
@@ -97,12 +97,7 @@ class CompareController(BaseRepoControll
 
        elif alias == 'hg':
 
            # case two independent repos
 
            if org_repo != other_repo:
 
                try:
 
                    hgrepo = unionrepo.makeunionrepository(other_repo.baseui,
 
                                                           other_repo.path,
 
                                                           org_repo.path)
 
                except AttributeError: # makeunionrepository was introduced in Mercurial 4.8 23f2299e9e53
 
                    hgrepo = unionrepo.unionrepository(other_repo.baseui,
 
                hgrepo = unionrepo.makeunionrepository(other_repo.baseui,
 
                                                       other_repo.path,
 
                                                       org_repo.path)
 
                # all ancestors of other_rev will be in other_repo and
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -535,12 +535,7 @@ class PullrequestsController(BaseRepoCon
 
                            # Note: org_scm_instance.path must come first so all
 
                            # valid revision numbers are 100% org_scm compatible
 
                            # - both for avail_revs and for revset results
 
                            try:
 
                                hgrepo = unionrepo.makeunionrepository(org_scm_instance.baseui,
 
                                                                       org_scm_instance.path,
 
                                                                       other_scm_instance.path)
 
                            except AttributeError: # makeunionrepository was introduced in Mercurial 4.8 23f2299e9e53
 
                                hgrepo = unionrepo.unionrepository(org_scm_instance.baseui,
 
                            hgrepo = unionrepo.makeunionrepository(org_scm_instance.baseui,
 
                                                                   org_scm_instance.path,
 
                                                                   other_scm_instance.path)
 
                        else:
kallithea/lib/vcs/backends/hg/changeset.py
Show inline comments
 
@@ -47,17 +47,11 @@ class MercurialChangeset(BaseChangeset):
 

	
 
    @LazyProperty
 
    def bumped(self):
 
        try:
 
            return self._ctx.phasedivergent()
 
        except AttributeError: # renamed in Mercurial 4.6 (9fa874fb34e1)
 
            return self._ctx.bumped()
 
        return self._ctx.phasedivergent()
 

	
 
    @LazyProperty
 
    def divergent(self):
 
        try:
 
            return self._ctx.contentdivergent()
 
        except AttributeError: # renamed in Mercurial 4.6 (8b2d7684407b)
 
            return self._ctx.divergent()
 
        return self._ctx.contentdivergent()
 

	
 
    @LazyProperty
 
    def extinct(self):
 
@@ -65,10 +59,7 @@ class MercurialChangeset(BaseChangeset):
 

	
 
    @LazyProperty
 
    def unstable(self):
 
        try:
 
            return self._ctx.orphan()
 
        except AttributeError: # renamed in Mercurial 4.6 (03039ff3082b)
 
            return self._ctx.unstable()
 
        return self._ctx.orphan()
 

	
 
    @LazyProperty
 
    def phase(self):
 
@@ -292,10 +283,7 @@ class MercurialChangeset(BaseChangeset):
 
            lineno, sha, changeset lazy loader and line
 
        """
 
        annotations = self._get_filectx(path).annotate()
 
        try:
 
            annotation_lines = [(annotateline.fctx, annotateline.text) for annotateline in annotations]
 
        except AttributeError: # annotateline was introduced in Mercurial 4.6 (b33b91ca2ec2)
 
            annotation_lines = [(aline.fctx, l) for aline, l in annotations]
 
        annotation_lines = [(annotateline.fctx, annotateline.text) for annotateline in annotations]
 
        for i, (fctx, l) in enumerate(annotation_lines):
 
            sha = fctx.hex()
 
            yield (i + 1, sha, lambda sha=sha, l=l: self.repository.get_changeset(sha), l)
kallithea/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -422,10 +422,7 @@ class MercurialRepository(BaseRepository
 
        try:
 
            if isinstance(revision, int):
 
                return self._repo[revision].hex()
 
            try:
 
                return scmutil.revsymbol(self._repo, revision).hex()
 
            except AttributeError: # revsymbol was introduced in Mercurial 4.6
 
                return self._repo[revision].hex()
 
            return scmutil.revsymbol(self._repo, revision).hex()
 
        except (IndexError, ValueError, RepoLookupError, TypeError):
 
            msg = ("Revision %s does not exist for %s" % (revision, self))
 
            raise ChangesetDoesNotExistError(msg)
 
@@ -458,11 +455,7 @@ class MercurialRepository(BaseRepository
 
            msg = ("Revision %s:%s does not exist for %s" % (ref_type, ref_name, self.name))
 
            raise ChangesetDoesNotExistError(msg)
 
        if revs:
 
            try:
 
                revision = revs.last()
 
            except AttributeError:
 
                # removed in hg 3.2
 
                revision = revs[-1]
 
            revision = revs.last()
 
        else:
 
            # TODO: just report 'not found'?
 
            revision = ref_name
 
@@ -565,11 +558,8 @@ class MercurialRepository(BaseRepository
 
        url = self._get_url(url)
 
        other = peer(self._repo, {}, url)
 
        try:
 
            # hg 3.2 moved push / pull to exchange module
 
            from mercurial import exchange
 
            exchange.pull(self._repo, other, heads=None, force=None)
 
        except ImportError:
 
            self._repo.pull(other, heads=None, force=None)
 
        except Abort as err:
 
            # Propagate error but with vcs's type
 
            raise RepositoryError(str(err))
kallithea/lib/vcs/backends/hg/ssh.py
Show inline comments
 
@@ -15,19 +15,13 @@
 
import logging
 

	
 
from mercurial import hg
 
from mercurial.wireprotoserver import sshserver
 

	
 
from kallithea.lib.utils import make_ui
 
from kallithea.lib.utils2 import safe_str, safe_unicode
 
from kallithea.lib.vcs.backends.ssh import BaseSshHandler
 

	
 

	
 
try:
 
    from mercurial.wireprotoserver import sshserver
 
except ImportError:
 
    from mercurial.sshserver import sshserver # moved in Mercurial 4.6 (1bf5263fe5cc)
 

	
 

	
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
@@ -2,9 +2,6 @@
 
Mercurial libs compatibility
 
"""
 

	
 
# Mercurial 5.0 550a172a603b renamed memfilectx argument `copied` to `copysource`
 
import inspect
 

	
 
import mercurial
 
from mercurial import archival, config, demandimport, discovery, httppeer, localrepo
 
from mercurial import merge as hg_merge
 
@@ -27,21 +24,7 @@ from mercurial.url import httpbasicauthh
 
from mercurial.util import url as hg_url
 

	
 

	
 
# patch demandimport, due to bug in mercurial when it always triggers demandimport.enable()
 
demandimport.enable = lambda *args, **kwargs: 1
 

	
 

	
 
# workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly
 
# workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly, and test_archival failing
 
localrepo.localrepository._lfstatuswriters = [lambda *msg, **opts: None]
 
# 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive
 
localrepo.localrepository.lfstatus = False
 

	
 
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)
setup.py
Show inline comments
 
@@ -62,7 +62,7 @@ requirements = [
 
    "URLObject >= 2.3.4, < 2.5",
 
    "Routes >= 2.0, < 2.5",
 
    "dulwich >= 0.14.1, < 0.20",
 
    "mercurial >= 4.5, < 5.3",
 
    "mercurial >= 5.1, < 5.3",
 
    "decorator >= 3.3.2, < 4.5",
 
    "Paste >= 2.0.3, < 3.1",
 
    "bleach >= 3.0, < 3.2",
0 comments (0 inline, 0 general)