comparison mercurial/obsutil.py @ 33145:0a370b93cca2

obsutil: move 'allsuccessors' to the new modules We have a new 'obsutil' module now. We move the high level utility there to bring 'obsolete.py' back to a more reasonable size.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 27 Jun 2017 01:36:20 +0200
parents d0e5bf12f314
children 7017567ebdf2
comparison
equal deleted inserted replaced
33144:d0e5bf12f314 33145:0a370b93cca2
54 continue 54 continue
55 suc = mark[0] 55 suc = mark[0]
56 if suc not in seen: 56 if suc not in seen:
57 seen.add(suc) 57 seen.add(suc)
58 remaining.add(suc) 58 remaining.add(suc)
59
60 def allsuccessors(obsstore, nodes, ignoreflags=0):
61 """Yield node for every successor of <nodes>.
62
63 Some successors may be unknown locally.
64
65 This is a linear yield unsuited to detecting split changesets. It includes
66 initial nodes too."""
67 remaining = set(nodes)
68 seen = set(remaining)
69 while remaining:
70 current = remaining.pop()
71 yield current
72 for mark in obsstore.successors.get(current, ()):
73 # ignore marker flagged with specified flag
74 if mark[2] & ignoreflags:
75 continue
76 for suc in mark[1]:
77 if suc not in seen:
78 seen.add(suc)
79 remaining.add(suc)
59 80
60 def _filterprunes(markers): 81 def _filterprunes(markers):
61 """return a set with no prune markers""" 82 """return a set with no prune markers"""
62 return set(m for m in markers if m[1]) 83 return set(m for m in markers if m[1])
63 84