effect-flag: remove wrapping of createmarkers for Mercurial 4.4
authorBoris Feld <boris.feld@octobus.net>
Fri, 20 Oct 2017 14:00:30 +0200
changeset 3086 611ac10f1fae
parent 3085 3eca2cbdc498
child 3087 504f914efd29
effect-flag: remove wrapping of createmarkers for Mercurial 4.4 Now that effect-flag has landed in Mercurial 4.4, we don't need to wrap createmarkers for this version anymore.
hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/obshistory.py	Fri Oct 20 14:56:03 2017 +0200
+++ b/hgext3rd/evolve/obshistory.py	Fri Oct 20 14:00:30 2017 +0200
@@ -631,46 +631,48 @@
             return False
     return True
 
-@eh.wrapfunction(obsolete, 'createmarkers')
-def createmarkerswithbits(orig, repo, relations, flag=0, date=None,
-                          metadata=None, **kwargs):
-    """compute 'effect-flag' and augment the created markers
+# Wrap pre Mercurial 4.4 createmarkers that didn't included effect-flag
+if not util.safehasattr(obsutil, 'geteffectflag'):
+    @eh.wrapfunction(obsolete, 'createmarkers')
+    def createmarkerswithbits(orig, repo, relations, flag=0, date=None,
+                              metadata=None, **kwargs):
+        """compute 'effect-flag' and augment the created markers
 
-    Wrap obsolete.createmarker in order to compute the effect of each
-    relationship and store them as flag in the metadata.
+        Wrap obsolete.createmarker in order to compute the effect of each
+        relationship and store them as flag in the metadata.
 
-    While we experiment, we store flag in a metadata field. This field is
-    "versionned" to easilly allow moving to other meaning for flags.
+        While we experiment, we store flag in a metadata field. This field is
+        "versionned" to easilly allow moving to other meaning for flags.
 
-    The comparison of description or other infos just before creating the obs
-    marker might induce overhead in some cases. However it is a good place to
-    start since it automatically makes all markers creation recording more
-    meaningful data. In the future, we can introduce way for commands to
-    provide precomputed effect to avoid the overhead.
-    """
-    if not repo.ui.configbool('experimental', 'evolution.effect-flags', **efd):
-        return orig(repo, relations, flag, date, metadata, **kwargs)
-    if metadata is None:
-        metadata = {}
-    tr = repo.transaction('add-obsolescence-marker')
-    try:
-        for r in relations:
-            # Compute the effect flag for each obsmarker
-            effect = geteffectflag(r)
+        The comparison of description or other infos just before creating the obs
+        marker might induce overhead in some cases. However it is a good place to
+        start since it automatically makes all markers creation recording more
+        meaningful data. In the future, we can introduce way for commands to
+        provide precomputed effect to avoid the overhead.
+        """
+        if not repo.ui.configbool('experimental', 'evolution.effect-flags', **efd):
+            return orig(repo, relations, flag, date, metadata, **kwargs)
+        if metadata is None:
+            metadata = {}
+        tr = repo.transaction('add-obsolescence-marker')
+        try:
+            for r in relations:
+                # Compute the effect flag for each obsmarker
+                effect = geteffectflag(r)
 
-            # Copy the metadata in order to add them, we copy because the
-            # effect flag might be different per relation
-            m = metadata.copy()
-            # we store the effect even if "0". This disctinct markers created
-            # without the feature with markers recording a no-op.
-            m['ef1'] = "%d" % effect
+                # Copy the metadata in order to add them, we copy because the
+                # effect flag might be different per relation
+                m = metadata.copy()
+                # we store the effect even if "0". This disctinct markers created
+                # without the feature with markers recording a no-op.
+                m['ef1'] = "%d" % effect
 
-            # And call obsolete.createmarkers for creating the obsmarker for real
-            orig(repo, [r], flag, date, m, **kwargs)
+                # And call obsolete.createmarkers for creating the obsmarker for real
+                orig(repo, [r], flag, date, m, **kwargs)
 
-        tr.close()
-    finally:
-        tr.release()
+            tr.close()
+        finally:
+            tr.release()
 
 def _getobsfate(successorssets):
     """ Compute a changeset obsolescence fate based on his successorssets.