Commit a8163176 authored by Anton Shestakov's avatar Anton Shestakov
Browse files

obshistory: add a function to group predsets by fold-id

parent b1a564cb18d0
......@@ -136,6 +136,30 @@
b"patch": TEMPLATE_PATCH,
}
def groupbyfoldid(predsets):
""" Group nodes and related obsmarkers by fold-id metadata.
"""
groups = {}
for (nodes, markers) in predsets:
grouped = False
for marker in markers:
metadata = dict(marker[3])
foldid = metadata.get(b'fold-id')
if foldid is not None:
groups.setdefault(foldid, []).append((nodes, markers))
grouped = True
if not grouped:
yield (nodes, markers)
for foldid in sorted(groups):
groupnodes = set()
groupmarkers = set()
for (nodes, markers) in groups[foldid]:
groupnodes.update(nodes)
groupmarkers.update(markers)
yield (tuple(sorted(groupnodes)), tuple(sorted(groupmarkers)))
def _nodesandmarkers(repo, ctx, filternonlocal):
if filternonlocal:
r = obsutil.successorsandmarkers(repo, ctx)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment