changeset 7709:0572d5d132c2

setup: bump Mercurial minimum version to 4.5 - that allow us to drop some hacks, and it was released more than one year ago
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 26 May 2019 23:20:58 +0200
parents ab30729c735c
children eda137096b3f
files kallithea/lib/vcs/backends/hg/changeset.py kallithea/lib/vcs/utils/hgcompat.py setup.py
diffstat 3 files changed, 7 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/vcs/backends/hg/changeset.py	Wed May 01 22:44:51 2019 +0200
+++ b/kallithea/lib/vcs/backends/hg/changeset.py	Sun May 26 23:20:58 2019 +0200
@@ -14,7 +14,7 @@
 from kallithea.lib.vcs.utils import safe_str, safe_unicode, date_fromtimestamp
 from kallithea.lib.vcs.utils.lazy import LazyProperty
 from kallithea.lib.vcs.utils.paths import get_dirs_for_path
-from kallithea.lib.vcs.utils.hgcompat import archival, hex
+from kallithea.lib.vcs.utils.hgcompat import archival, hex, obsutil
 
 from mercurial import obsolete
 
@@ -88,13 +88,7 @@
 
     @LazyProperty
     def successors(self):
-        try:
-            # This works starting from Mercurial 4.3: the function `successorssets` was moved to the mercurial.obsutil module and gained the `closest` parameter.
-            from mercurial import obsutil
-            successors = obsutil.successorssets(self._ctx._repo, self._ctx.node(), closest=True)
-        except ImportError:
-            # fallback for older versions
-            successors = obsolete.successorssets(self._ctx._repo, self._ctx.node())
+        successors = obsutil.successorssets(self._ctx._repo, self._ctx.node(), closest=True)
         if successors:
             # flatten the list here handles both divergent (len > 1)
             # and the usual case (len = 1)
@@ -104,19 +98,7 @@
 
     @LazyProperty
     def predecessors(self):
-        try:
-            # This works starting from Mercurial 4.3: the function `closestpredecessors` was added.
-            from mercurial import obsutil
-            return [hex(n)[:12] for n in obsutil.closestpredecessors(self._ctx._repo, self._ctx.node())]
-        except ImportError:
-            # fallback for older versions
-            predecessors = set()
-            nm = self._ctx._repo.changelog.nodemap
-            for p in self._ctx._repo.obsstore.precursors.get(self._ctx.node(), ()):
-                pr = nm.get(p[0])
-                if pr is not None:
-                    predecessors.add(hex(p[0])[:12])
-            return predecessors
+        return [hex(n)[:12] for n in obsutil.closestpredecessors(self._ctx._repo, self._ctx.node())]
 
     @LazyProperty
     def bookmarks(self):
@@ -320,10 +302,7 @@
         try:
             annotation_lines = [(annotateline.fctx, annotateline.text) for annotateline in annotations]
         except AttributeError: # annotateline was introduced in Mercurial 4.6 (b33b91ca2ec2)
-            try:
-                annotation_lines = [(aline.fctx, l) for aline, l in annotations]
-            except AttributeError: # aline.fctx was introduced in Mercurial 4.4
-                annotation_lines = [(aline[0], l) for aline, l in annotations]
+            annotation_lines = [(aline.fctx, l) for aline, l 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/utils/hgcompat.py	Wed May 01 22:44:51 2019 +0200
+++ b/kallithea/lib/vcs/utils/hgcompat.py	Sun May 26 23:20:58 2019 +0200
@@ -12,9 +12,10 @@
 from mercurial import unionrepo
 from mercurial import scmutil
 from mercurial import config
-from mercurial import tags as tagsmod
+from mercurial.tags import tag
 from mercurial import httppeer
 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
@@ -32,23 +33,7 @@
 from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
 
 
-# Mercurial 4.5 8a0cac20a1ad introduced an extra memctx changectx argument
-# - introduce an optional wrapper factory that doesn't pass it on
-import inspect
-if inspect.getargspec(memfilectx.__init__).args[2] != 'changectx':
-    __org_memfilectx = memfilectx
-    memfilectx = lambda repo, changectx, *args, **kwargs: __org_memfilectx(repo, *args, **kwargs)
-
-
 # workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly
 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
-
-# Mercurial 4.2 moved tag from localrepo to the tags module
-def tag(repo, *args):
-    try:
-        tag_f  = tagsmod.tag
-    except AttributeError:
-        return repo.tag(*args)
-    tag_f(repo, *args)
--- a/setup.py	Wed May 01 22:44:51 2019 +0200
+++ b/setup.py	Sun May 26 23:20:58 2019 +0200
@@ -57,7 +57,7 @@
     "URLObject >= 2.3.4, < 2.5",
     "Routes >= 1.13, < 2",
     "dulwich >= 0.14.1, < 0.20",
-    "mercurial >= 4.1.1, < 4.10",
+    "mercurial >= 4.5, < 4.10",
     "decorator >= 3.3.2, < 4.4",
     "Paste >= 2.0.3, < 3.1",
     "bleach >= 3.0, < 3.1",