--- a/hgext3rd/evolve/obshistory.py Tue Apr 21 23:40:44 2020 +0800
+++ b/hgext3rd/evolve/obshistory.py Fri Apr 24 01:09:30 2020 +0800
@@ -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)