comparison mercurial/phases.py @ 39147:b95b48a55c36

merge with stable
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 17 Aug 2018 16:11:35 -0700
parents e7aa113b14f7 f736fdbe546a
children 5b9f116104f9
comparison
equal deleted inserted replaced
39145:b623c7b23695 39147:b95b48a55c36
662 def newheads(repo, heads, roots): 662 def newheads(repo, heads, roots):
663 """compute new head of a subset minus another 663 """compute new head of a subset minus another
664 664
665 * `heads`: define the first subset 665 * `heads`: define the first subset
666 * `roots`: define the second we subtract from the first""" 666 * `roots`: define the second we subtract from the first"""
667 # prevent an import cycle
668 # phases > dagop > patch > copies > scmutil > obsolete > obsutil > phases
669 from . import dagop
670
667 repo = repo.unfiltered() 671 repo = repo.unfiltered()
668 revs = repo.revs('heads(::%ln - (%ln::%ln))', heads, roots, heads) 672 cl = repo.changelog
669 return pycompat.maplist(repo.changelog.node, revs) 673 rev = cl.nodemap.get
674 if not roots:
675 return heads
676 if not heads or heads == [nullrev]:
677 return []
678 # The logic operated on revisions, convert arguments early for convenience
679 new_heads = set(rev(n) for n in heads if n != nullid)
680 roots = [rev(n) for n in roots]
681 if not heads or not roots:
682 return heads
683 # compute the area we need to remove
684 affected_zone = repo.revs("(%ld::%ld)", roots, new_heads)
685 # heads in the area are no longer heads
686 new_heads.difference_update(affected_zone)
687 # revisions in the area have children outside of it,
688 # They might be new heads
689 candidates = repo.revs("parents(%ld + (%ld and merge())) and not null",
690 roots, affected_zone)
691 candidates -= affected_zone
692 if new_heads or candidates:
693 # remove candidate that are ancestors of other heads
694 new_heads.update(candidates)
695 prunestart = repo.revs("parents(%ld) and not null", new_heads)
696 pruned = dagop.reachableroots(repo, candidates, prunestart)
697 new_heads.difference_update(pruned)
698
699 return pycompat.maplist(cl.node, sorted(new_heads))
670 700
671 def newcommitphase(ui): 701 def newcommitphase(ui):
672 """helper to get the target phase of new commit 702 """helper to get the target phase of new commit
673 703
674 Handle all possible values for the phases.new-commit options. 704 Handle all possible values for the phases.new-commit options.