changeset 955:72670e282460

evolve: compatibility with memfilectx change The future 3.1 have have more sophisticated memfilectx object. We add a compatibility layer for them.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 03 Jun 2014 01:37:08 -0700
parents ef155e3ead8f
children b107f3549ec2
files README hgext/evolve.py
diffstat 2 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/README	Tue Jun 03 01:22:31 2014 -0700
+++ b/README	Tue Jun 03 01:37:08 2014 -0700
@@ -50,6 +50,7 @@
 4.0.0 --
 
 - require Mercurial version 3.0.1 or above
+- some compatibility fixes with future 3.1.0
 - deprecated `gup` and `gdown` in favor of prev and next
 - record parent of pruned parent at prune time
 - added a `debugobsstorestat` command to gather data on obsmarker content.
--- 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))