comparison mercurial/obsolete.py @ 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 b0c14c5d44b1
children cd62532c62a1
comparison
equal deleted inserted replaced
20205:d67a7758da6d 20206:cdcbe103b69a
453 continue 453 continue
454 for suc in mark[1]: 454 for suc in mark[1]:
455 if suc not in seen: 455 if suc not in seen:
456 seen.add(suc) 456 seen.add(suc)
457 remaining.add(suc) 457 remaining.add(suc)
458
459 def allprecursors(obsstore, nodes, ignoreflags=0):
460 """Yield node for every precursors of <nodes>.
461
462 Some precursors may be unknown locally.
463
464 This is a linear yield unsuited to detecting folded changesets. It includes
465 initial nodes too."""
466
467 remaining = set(nodes)
468 seen = set(remaining)
469 while remaining:
470 current = remaining.pop()
471 yield current
472 for mark in obsstore.precursors.get(current, ()):
473 # ignore marker flagged with specified flag
474 if mark[2] & ignoreflags:
475 continue
476 suc = mark[0]
477 if suc not in seen:
478 seen.add(suc)
479 remaining.add(suc)
458 480
459 def foreground(repo, nodes): 481 def foreground(repo, nodes):
460 """return all nodes in the "foreground" of other node 482 """return all nodes in the "foreground" of other node
461 483
462 The foreground of a revision is anything reachable using parent -> children 484 The foreground of a revision is anything reachable using parent -> children