hgext/evolve.py
changeset 955 72670e282460
parent 954 ef155e3ead8f
child 956 b107f3549ec2
--- a/hgext/evolve.py	Tue Jun 03 01:22:31 2014 -0700
+++ b/hgext/evolve.py	Tue Jun 03 01:37:08 2014 -0700
@@ -36,13 +36,9 @@
         obsolete._enabled = True
     from mercurial import wireproto
     gboptslist = getattr(wireproto, 'gboptslist', None)
+    gboptsmap = getattr(wireproto, 'gboptsmap', None)
 except (ImportError, AttributeError):
-    gboptslist = None
-
-if gboptslist is None:
-    raise util.Abort('Your Mercurial is too old for this version of Evolve\n'
-                     'requires version 3.0.1 or above')
-
+    gboptslist = gboptsmap = None
 
 
 from mercurial import base85
@@ -73,7 +69,16 @@
 
 _pack = struct.pack
 
-memfilectx = context.memfilectx
+if gboptsmap is not None:
+    memfilectx = context.memfilectx
+elif gboptslist is not None:
+    oldmemfilectx = context.memfilectx
+    def memfilectx(repo, *args, **kwargs):
+        return oldmemfilectx(*args, **kwargs)
+else:
+    raise util.Abort('Your Mercurial is too old for this version of Evolve\n'
+                     'requires version 3.0.1 or above')
+
 
 # This extension contains the following code
 #
@@ -756,7 +761,7 @@
             if path in headmf:
                 fctx = head[path]
                 flags = fctx.flags()
-                mctx = memfilectx(fctx.path(), fctx.data(),
+                mctx = memfilectx(repo, fctx.path(), fctx.data(),
                                   islink='l' in flags,
                                   isexec='x' in flags,
                                   copied=copied.get(path))
@@ -1406,7 +1411,7 @@
                         if path in bumped:
                             fctx = bumped[path]
                             flags = fctx.flags()
-                            mctx = memfilectx(fctx.path(), fctx.data(),
+                            mctx = memfilectx(repo, fctx.path(), fctx.data(),
                                               islink='l' in flags,
                                               isexec='x' in flags,
                                               copied=copied.get(path))
@@ -1836,7 +1841,7 @@
             raise IOError()
         fctx = ctx[path]
         flags = fctx.flags()
-        mctx = memfilectx(fctx.path(), fctx.data(),
+        mctx = memfilectx(repo, fctx.path(), fctx.data(),
                           islink='l' in flags,
                           isexec='x' in flags,
                           copied=copied.get(path))