obsolete: track markers in _succs
authorBoris Feld <boris.feld@octobus.net>
Mon, 03 Jul 2017 03:27:58 +0200
changeset 33911 34e10e09afa5
parent 33910 dba493981284
child 33912 e278d6d2d7d2
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.
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]