[PATCH 3 of 9 V3] obsolete: track markers in _succs

Boris Feld boris.feld at octobus.net
Mon Aug 21 04:43:55 EDT 2017


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1499045278 -7200
#      Mon Jul 03 03:27:58 2017 +0200
# Node ID 89a659e236b906e58a48dfed8a4e3b89372d7184
# Parent  60a7a3ca1dae7dc99b8b018b4aefa24b74d3b149
# EXP-Topic obsfatetemplate
obsolete: track markers in _succs

We now also store markers in _succs. It will be useful for the obsfate template that
will use them to display more meaningful information like the list of users
that have evolved a changeset into its successors.

diff -r 60a7a3ca1dae -r 89a659e236b9 mercurial/obsutil.py
--- a/mercurial/obsutil.py	Mon Jul 03 03:13:17 2017 +0200
+++ b/mercurial/obsutil.py	Mon Jul 03 03:27:58 2017 +0200
@@ -330,8 +330,14 @@
 class _succs(list):
     """small class to represent a successors with some metadata about it"""
 
+    def __init__(self, *args, **kwargs):
+        super(_succs, self).__init__(*args, **kwargs)
+        self.markers = set()
+
     def copy(self):
-        return _succs(self)
+        new = _succs(self)
+        new.markers = self.markers.copy()
+        return new
 
 def successorssets(repo, initialnode, closest=False, cache=None):
     """Return set of all latest successors of initial nodes
@@ -527,13 +533,16 @@
                 succssets = []
                 for mark in sorted(succmarkers[current]):
                     # successors sets contributed by this marker
-                    markss = [_succs()]
+                    base = _succs()
+                    base.markers.add(mark)
+                    markss = [base]
                     for suc in mark[1]:
                         # cardinal product with previous successors
                         productresult = []
                         for prefix in markss:
                             for suffix in cache[suc]:
                                 newss = prefix.copy()
+                                newss.markers.update(suffix.markers)
                                 for part in suffix:
                                     # do not duplicated entry in successors set
                                     # first entry wins.
@@ -548,12 +557,13 @@
                 candidate = sorted(((set(s), s) for s in succssets if s),
                                    key=lambda x: len(x[1]), reverse=True)
                 for setversion, listversion in candidate:
-                    for seenset in seen:
+                    for seenset, seensuccs in seen:
                         if setversion.issubset(seenset):
+                            seensuccs.markers.update(listversion.markers)
                             break
                     else:
                         final.append(listversion)
-                        seen.append(setversion)
+                        seen.append((setversion, listversion))
                 final.reverse() # put small successors set first
                 cache[current] = final
     return cache[initialnode]


More information about the Mercurial-devel mailing list