Mercurial > evolve
changeset 5280:a81631766575
obshistory: add a function to group predsets by fold-id
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 24 Apr 2020 01:09:30 +0800 |
parents | b1a564cb18d0 |
children | 0dc4c16506fc |
files | hgext3rd/evolve/obshistory.py |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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)