Mercurial > hg
changeset 20206:cdcbe103b69a
obsolete: add an allprecursors method mirroring allsuccessors one.
Detection of bumped changeset should use `allprecursors(<mutable>)` instead or
`allsuccessors(<immutable>)` so we need the all precursors function to exists.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 23 Dec 2013 13:36:13 -0800 |
parents | d67a7758da6d |
children | cd62532c62a1 |
files | mercurial/obsolete.py |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/obsolete.py Mon Dec 23 16:04:51 2013 -0800 +++ b/mercurial/obsolete.py Mon Dec 23 13:36:13 2013 -0800 @@ -456,6 +456,28 @@ seen.add(suc) remaining.add(suc) +def allprecursors(obsstore, nodes, ignoreflags=0): + """Yield node for every precursors of <nodes>. + + Some precursors may be unknown locally. + + This is a linear yield unsuited to detecting folded changesets. It includes + initial nodes too.""" + + remaining = set(nodes) + seen = set(remaining) + while remaining: + current = remaining.pop() + yield current + for mark in obsstore.precursors.get(current, ()): + # ignore marker flagged with specified flag + if mark[2] & ignoreflags: + continue + suc = mark[0] + if suc not in seen: + seen.add(suc) + remaining.add(suc) + def foreground(repo, nodes): """return all nodes in the "foreground" of other node