memfilectx: changectx argument is not mandatory
As changectx argument is now mandatory for memfilectx, add a compatibility
layer to pass it when necessary.
The commit that made the parament mandatory in core is 8a0cac20a1ad
--- a/hgext3rd/evolve/__init__.py Sat Dec 16 23:52:32 2017 +0100
+++ b/hgext3rd/evolve/__init__.py Fri Dec 15 10:14:42 2017 +0100
@@ -1830,10 +1830,7 @@
if path in bumped:
fctx = bumped[path]
flags = fctx.flags()
- mctx = context.memfilectx(repo, fctx.path(), fctx.data(),
- islink='l' in flags,
- isexec='x' in flags,
- copied=copied.get(path))
+ mctx = compat.memfilectx(repo, ctx, fctx, flags, copied, path)
return mctx
return None
text = 'bumped update to %s:\n\n' % prec
--- a/hgext3rd/evolve/cmdrewrite.py Sat Dec 16 23:52:32 2017 +0100
+++ b/hgext3rd/evolve/cmdrewrite.py Fri Dec 15 10:14:42 2017 +0100
@@ -179,10 +179,7 @@
return None
fctx = contentctx[path]
flags = fctx.flags()
- mctx = context.memfilectx(repo, fctx.path(), fctx.data(),
- islink='l' in flags,
- isexec='x' in flags,
- copied=copied.get(path))
+ mctx = compat.memfilectx(repo, memctx, fctx, flags, copied, path)
return mctx
if message is None:
--- a/hgext3rd/evolve/compat.py Sat Dec 16 23:52:32 2017 +0100
+++ b/hgext3rd/evolve/compat.py Fri Dec 15 10:14:42 2017 +0100
@@ -195,3 +195,20 @@
copies.duplicatecopies(repo, rev, fromrev, skiprev=skiprev)
else:
copies.duplicatecopies(repo, wctx, rev, fromrev, skiprev=skiprev)
+
+def memfilectx(repo, ctx, fctx, flags, copied, path):
+ # XXX Would it be better at the module level?
+ varnames = context.memfilectx.__init__.__code__.co_varnames
+ ctxmandatory = varnames[2] == "changectx"
+
+ if ctxmandatory:
+ mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
+ islink='l' in flags,
+ isexec='x' in flags,
+ copied=copied.get(path))
+ else:
+ mctx = context.memfilectx(repo, fctx.path(), fctx.data(),
+ islink='l' in flags,
+ isexec='x' in flags,
+ copied=copied.get(path))
+ return mctx
--- a/hgext3rd/evolve/rewriteutil.py Sat Dec 16 23:52:32 2017 +0100
+++ b/hgext3rd/evolve/rewriteutil.py Fri Dec 15 10:14:42 2017 +0100
@@ -201,10 +201,7 @@
if path in headmf:
fctx = head[path]
flags = fctx.flags()
- mctx = context.memfilectx(repo, fctx.path(), fctx.data(),
- islink='l' in flags,
- isexec='x' in flags,
- copied=copied.get(path))
+ mctx = compat.memfilectx(repo, ctx, fctx, flags, copied, path)
return mctx
return None