Mercurial > kallithea
changeset 8033:1e8b300b0540
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()
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Wed, 25 Dec 2019 15:39:33 +0100 |
parents | 287b5f1cb40a |
children | ed78b4fbe2a3 |
files | kallithea/controllers/compare.py kallithea/controllers/pullrequests.py kallithea/lib/vcs/backends/hg/changeset.py kallithea/lib/vcs/backends/hg/repository.py kallithea/lib/vcs/backends/hg/ssh.py kallithea/lib/vcs/utils/hgcompat.py setup.py |
diffstat | 7 files changed, 11 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/compare.py Mon Dec 16 00:02:34 2019 +0100 +++ b/kallithea/controllers/compare.py Wed Dec 25 15:39:33 2019 +0100 @@ -97,12 +97,7 @@ 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
--- a/kallithea/controllers/pullrequests.py Mon Dec 16 00:02:34 2019 +0100 +++ b/kallithea/controllers/pullrequests.py Wed Dec 25 15:39:33 2019 +0100 @@ -535,12 +535,7 @@ # 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:
--- a/kallithea/lib/vcs/backends/hg/changeset.py Mon Dec 16 00:02:34 2019 +0100 +++ b/kallithea/lib/vcs/backends/hg/changeset.py Wed Dec 25 15:39:33 2019 +0100 @@ -47,17 +47,11 @@ @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 @@ @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 @@ 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)
--- a/kallithea/lib/vcs/backends/hg/repository.py Mon Dec 16 00:02:34 2019 +0100 +++ b/kallithea/lib/vcs/backends/hg/repository.py Wed Dec 25 15:39:33 2019 +0100 @@ -422,10 +422,7 @@ 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 @@ 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 @@ 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))
--- a/kallithea/lib/vcs/backends/hg/ssh.py Mon Dec 16 00:02:34 2019 +0100 +++ b/kallithea/lib/vcs/backends/hg/ssh.py Wed Dec 25 15:39:33 2019 +0100 @@ -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__)
--- a/kallithea/lib/vcs/utils/hgcompat.py Mon Dec 16 00:02:34 2019 +0100 +++ b/kallithea/lib/vcs/utils/hgcompat.py Wed Dec 25 15:39:33 2019 +0100 @@ -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.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)
--- a/setup.py Mon Dec 16 00:02:34 2019 +0100 +++ b/setup.py Wed Dec 25 15:39:33 2019 +0100 @@ -62,7 +62,7 @@ "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",