comparison mercurial/obsutil.py @ 33150:d0e5bf12f314

obsutil: move 'allprecursors' 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:31:18 +0200
parents d09ae850296d
children 0a370b93cca2
comparison
equal deleted inserted replaced
33149:d09ae850296d 33150:d0e5bf12f314
32 32
33 if precnodeid in repo: 33 if precnodeid in repo:
34 yield precnodeid 34 yield precnodeid
35 else: 35 else:
36 stack.append(precnodeid) 36 stack.append(precnodeid)
37
38 def allprecursors(obsstore, nodes, ignoreflags=0):
39 """Yield node for every precursors of <nodes>.
40
41 Some precursors may be unknown locally.
42
43 This is a linear yield unsuited to detecting folded changesets. It includes
44 initial nodes too."""
45
46 remaining = set(nodes)
47 seen = set(remaining)
48 while remaining:
49 current = remaining.pop()
50 yield current
51 for mark in obsstore.precursors.get(current, ()):
52 # ignore marker flagged with specified flag
53 if mark[2] & ignoreflags:
54 continue
55 suc = mark[0]
56 if suc not in seen:
57 seen.add(suc)
58 remaining.add(suc)
37 59
38 def _filterprunes(markers): 60 def _filterprunes(markers):
39 """return a set with no prune markers""" 61 """return a set with no prune markers"""
40 return set(m for m in markers if m[1]) 62 return set(m for m in markers if m[1])
41 63