diff hgext/simple4server.py @ 1067:5d063fed9e3d

evolve: yield to relevant markers handling in core The handling of obsolescence marker is now performed in core. If we detect a mercurial with such power we skip the wrapping from evolve. This changeset also suffer from massive diff from the change in display of obsolescence marker with parent information introduced at the same time in core.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 20 Aug 2014 20:49:48 -0700
parents f80e8e3c3726
children f15f02007a0b
line wrap: on
line diff
--- a/hgext/simple4server.py	Wed Aug 20 21:14:49 2014 -0700
+++ b/hgext/simple4server.py	Wed Aug 20 20:49:48 2014 -0700
@@ -108,61 +108,62 @@
     obsdata.seek(0)
     return obsdata
 
-# from evolve extension: 1a23c7c52a43
-class pruneobsstore(obsolete.obsstore):
-    """And extended obsstore class that read parent information from v1 format
+if not util.safehasattr(obsolete.obsstore, 'relevantmarkers'):
+    # from evolve extension: 1a23c7c52a43
+    class pruneobsstore(obsolete.obsstore):
+        """And extended obsstore class that read parent information from v1 format
 
-    Evolve extension adds parent information in prune marker. We use it to make
-    markers relevant to pushed changeset."""
+        Evolve extension adds parent information in prune marker. We use it to make
+        markers relevant to pushed changeset."""
 
-    def __init__(self, *args, **kwargs):
-        self.prunedchildren = {}
-        return super(pruneobsstore, self).__init__(*args, **kwargs)
+        def __init__(self, *args, **kwargs):
+            self.prunedchildren = {}
+            return super(pruneobsstore, self).__init__(*args, **kwargs)
 
-    def _load(self, markers):
-        markers = self._prunedetectingmarkers(markers)
-        return super(pruneobsstore, self)._load(markers)
+        def _load(self, markers):
+            markers = self._prunedetectingmarkers(markers)
+            return super(pruneobsstore, self)._load(markers)
 
 
-    def _prunedetectingmarkers(self, markers):
-        for m in markers:
-            if not m[1]: # no successors
-                meta = obsolete.decodemeta(m[3])
-                if 'p1' in meta:
-                    p1 = node.bin(meta['p1'])
-                    self.prunedchildren.setdefault(p1, set()).add(m)
-                if 'p2' in meta:
-                    p2 = node.bin(meta['p2'])
-                    self.prunedchildren.setdefault(p2, set()).add(m)
-            yield m
+        def _prunedetectingmarkers(self, markers):
+            for m in markers:
+                if not m[1]: # no successors
+                    meta = obsolete.decodemeta(m[3])
+                    if 'p1' in meta:
+                        p1 = node.bin(meta['p1'])
+                        self.prunedchildren.setdefault(p1, set()).add(m)
+                    if 'p2' in meta:
+                        p2 = node.bin(meta['p2'])
+                        self.prunedchildren.setdefault(p2, set()).add(m)
+                yield m
 
-# from evolve extension: 1a23c7c52a43
-def relevantmarkers(self, nodes):
-    """return a set of all obsolescence marker relevant to a set of node.
+    # from evolve extension: 1a23c7c52a43
+    def relevantmarkers(self, nodes):
+        """return a set of all obsolescence marker relevant to a set of node.
 
-    "relevant" to a set of node mean:
+        "relevant" to a set of node mean:
 
-    - marker that use this changeset as successors
-    - prune marker of direct children on this changeset.
-    - recursive application of the two rules on precursors of these markers
+        - marker that use this changeset as successors
+        - prune marker of direct children on this changeset.
+        - recursive application of the two rules on precursors of these markers
 
-    It is a set so you cannot rely on order"""
-    seennodes = set(nodes)
-    seenmarkers = set()
-    pendingnodes = set(nodes)
-    precursorsmarkers = self.precursors
-    prunedchildren = self.prunedchildren
-    while pendingnodes:
-        direct = set()
-        for current in pendingnodes:
-            direct.update(precursorsmarkers.get(current, ()))
-            direct.update(prunedchildren.get(current, ()))
-        direct -= seenmarkers
-        pendingnodes = set([m[0] for m in direct])
-        seenmarkers |= direct
-        pendingnodes -= seennodes
-        seennodes |= pendingnodes
-    return seenmarkers
+        It is a set so you cannot rely on order"""
+        seennodes = set(nodes)
+        seenmarkers = set()
+        pendingnodes = set(nodes)
+        precursorsmarkers = self.precursors
+        prunedchildren = self.prunedchildren
+        while pendingnodes:
+            direct = set()
+            for current in pendingnodes:
+                direct.update(precursorsmarkers.get(current, ()))
+                direct.update(prunedchildren.get(current, ()))
+            direct -= seenmarkers
+            pendingnodes = set([m[0] for m in direct])
+            seenmarkers |= direct
+            pendingnodes -= seennodes
+            seennodes |= pendingnodes
+        return seenmarkers
 
 # from evolve extension: cf35f38d6a10
 def srv_pullobsmarkers(repo, proto, others):
@@ -259,8 +260,9 @@
         gboptslist.append('evo_obsheads')
         gboptslist.append('evo_obscommon')
         gboptslist.append('evo_obsmarker')
-    obsolete.obsstore = pruneobsstore
-    obsolete.obsstore.relevantmarkers = relevantmarkers
+    if not util.safehasattr(obsolete.obsstore, 'relevantmarkers'):
+        obsolete.obsstore = pruneobsstore
+        obsolete.obsstore.relevantmarkers = relevantmarkers
     hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push'
     hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull'
     hgweb_mod.perms['evoext_obshash'] = 'pull'