Mercurial > evolve
changeset 5281:0dc4c16506fc
obshistory: add predecessorsandmarkers()
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 24 Apr 2020 01:14:34 +0800 |
parents | a81631766575 |
children | 0bc31f853862 |
files | hgext3rd/evolve/obshistory.py |
diffstat | 1 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obshistory.py Fri Apr 24 01:09:30 2020 +0800 +++ b/hgext3rd/evolve/obshistory.py Fri Apr 24 01:14:34 2020 +0800 @@ -160,6 +160,34 @@ groupmarkers.update(markers) yield (tuple(sorted(groupnodes)), tuple(sorted(groupmarkers))) +def predecessorsandmarkers(repo, node): + """ Compute data needed for obsorigin. + + Return a generator of (nodes, markers) tuples, where nodes is a tuple of + predecessor nodes and markers is a tuple of obsolescence markers. + + Using tuples for everything means no problems with sorted(). + """ + predecessors = repo.obsstore.predecessors + stack = [(node, ())] + seen = {node} + + while stack: + node, path = stack.pop() + + for marker in sorted(predecessors.get(node, ())): + prednode = marker[0] + + # Basic cycle protection + if prednode in seen: + continue + seen.add(prednode) + + if prednode in repo: + yield ((prednode,), path + (marker,)) + else: + stack.append((prednode, path + (marker,))) + def _nodesandmarkers(repo, ctx, filternonlocal): if filternonlocal: r = obsutil.successorsandmarkers(repo, ctx)