changeset 7234:0bf6ccd6f67c

setup: support Mercurial 4.5.x This requires passing an extra parameter to memctx __init__ after https://www.mercurial-scm.org/repo/hg/rev/8a0cac20a1ad .
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 02 Apr 2018 14:22:11 +0200
parents 0e83a1bf6e49
children 06c7273e2086
files kallithea/lib/vcs/backends/hg/inmemory.py kallithea/lib/vcs/utils/hgcompat.py setup.py
diffstat 3 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/vcs/backends/hg/inmemory.py	Mon Apr 02 14:14:55 2018 +0200
+++ b/kallithea/lib/vcs/backends/hg/inmemory.py	Mon Apr 02 14:22:11 2018 +0200
@@ -52,7 +52,7 @@
             # check if this path is added
             for node in self.added:
                 if node.path == path:
-                    return memfilectx(_repo, path=node.path,
+                    return memfilectx(_repo, memctx, path=node.path,
                         data=(node.content.encode('utf8')
                               if not node.is_binary else node.content),
                         islink=False,
@@ -62,7 +62,7 @@
             # or changed
             for node in self.changed:
                 if node.path == path:
-                    return memfilectx(_repo, path=node.path,
+                    return memfilectx(_repo, memctx, path=node.path,
                         data=(node.content.encode('utf8')
                               if not node.is_binary else node.content),
                         islink=False,
--- a/kallithea/lib/vcs/utils/hgcompat.py	Mon Apr 02 14:14:55 2018 +0200
+++ b/kallithea/lib/vcs/utils/hgcompat.py	Mon Apr 02 14:22:11 2018 +0200
@@ -32,6 +32,15 @@
 from mercurial.node import nullrev
 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
 localrepository._lfstatuswriters = [lambda *msg, **opts: None]
 # 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive
--- a/setup.py	Mon Apr 02 14:14:55 2018 +0200
+++ b/setup.py	Mon Apr 02 14:22:11 2018 +0200
@@ -57,7 +57,7 @@
     "URLObject==2.3.4",
     "Routes==1.13",
     "dulwich>=0.14.1",
-    "mercurial>=4.0,<4.5",
+    "mercurial>=4.0,<4.6",
     "decorator >= 3.3.2",
     "Paste >= 2.0.3, < 3.0",
 ]