obshistory: add _originmarkers() function to be used for obslog --origin
authorAnton Shestakov <av6@dwimlabs.net>
Fri, 24 Apr 2020 01:15:38 +0800
changeset 5346 b117e4732656
parent 5345 a73cdef2e33f
child 5347 2d48fc2c47fc
obshistory: add _originmarkers() function to be used for obslog --origin
hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/obshistory.py	Fri May 08 04:02:22 2020 +0200
+++ b/hgext3rd/evolve/obshistory.py	Fri Apr 24 01:15:38 2020 +0800
@@ -192,6 +192,24 @@
             else:
                 stack.append((prednode, path + (marker,)))
 
+def _originmarkers(repo, ctx, filternonlocal):
+    predecessors = repo.obsstore.predecessors
+    successors = repo.obsstore.successors
+    if filternonlocal:
+        r = predecessorsandmarkers(repo, ctx.node())
+        for (nodes, markers) in sorted(groupbyfoldid(r)):
+            yield (nodes, markers)
+    else:
+        markers = predecessors.get(ctx.node(), ())
+        data = (((marker[0],), (marker,)) for marker in markers)
+        for (nodes, markers) in sorted(groupbyfoldid(data)):
+            yield (nodes, markers)
+
+    # finding prune markers
+    for marker in successors.get(ctx.node(), ()):
+        if not marker[1]:
+            yield ((), (marker,))
+
 def _nodesandmarkers(repo, ctx, filternonlocal):
     if filternonlocal:
         r = obsutil.successorsandmarkers(repo, ctx)