Mercurial > hg
comparison mercurial/obsolete.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 |
---|---|
867 def successormarkers(ctx): | 867 def successormarkers(ctx): |
868 """obsolete marker making this changeset obsolete""" | 868 """obsolete marker making this changeset obsolete""" |
869 for data in ctx.repo().obsstore.successors.get(ctx.node(), ()): | 869 for data in ctx.repo().obsstore.successors.get(ctx.node(), ()): |
870 yield marker(ctx.repo(), data) | 870 yield marker(ctx.repo(), data) |
871 | 871 |
872 def allsuccessors(obsstore, nodes, ignoreflags=0): | |
873 """Yield node for every successor of <nodes>. | |
874 | |
875 Some successors may be unknown locally. | |
876 | |
877 This is a linear yield unsuited to detecting split changesets. It includes | |
878 initial nodes too.""" | |
879 remaining = set(nodes) | |
880 seen = set(remaining) | |
881 while remaining: | |
882 current = remaining.pop() | |
883 yield current | |
884 for mark in obsstore.successors.get(current, ()): | |
885 # ignore marker flagged with specified flag | |
886 if mark[2] & ignoreflags: | |
887 continue | |
888 for suc in mark[1]: | |
889 if suc not in seen: | |
890 seen.add(suc) | |
891 remaining.add(suc) | |
892 | |
893 def foreground(repo, nodes): | 872 def foreground(repo, nodes): |
894 """return all nodes in the "foreground" of other node | 873 """return all nodes in the "foreground" of other node |
895 | 874 |
896 The foreground of a revision is anything reachable using parent -> children | 875 The foreground of a revision is anything reachable using parent -> children |
897 or precursor -> successor relation. It is very similar to "descendant" but | 876 or precursor -> successor relation. It is very similar to "descendant" but |
909 # compute the whole set of successors or descendants | 888 # compute the whole set of successors or descendants |
910 while len(foreground) != plen: | 889 while len(foreground) != plen: |
911 plen = len(foreground) | 890 plen = len(foreground) |
912 succs = set(c.node() for c in foreground) | 891 succs = set(c.node() for c in foreground) |
913 mutable = [c.node() for c in foreground if c.mutable()] | 892 mutable = [c.node() for c in foreground if c.mutable()] |
914 succs.update(allsuccessors(repo.obsstore, mutable)) | 893 succs.update(obsutil.allsuccessors(repo.obsstore, mutable)) |
915 known = (n for n in succs if n in nm) | 894 known = (n for n in succs if n in nm) |
916 foreground = set(repo.set('%ln::', known)) | 895 foreground = set(repo.set('%ln::', known)) |
917 return set(c.node() for c in foreground) | 896 return set(c.node() for c in foreground) |
918 | 897 |
919 # keep compatibility for the 4.3 cycle | 898 # keep compatibility for the 4.3 cycle |
920 def allprecursors(obsstore, nodes, ignoreflags=0): | 899 def allprecursors(obsstore, nodes, ignoreflags=0): |
921 movemsg = 'obsolete.allprecursors moved to obsutil.allprecursors' | 900 movemsg = 'obsolete.allprecursors moved to obsutil.allprecursors' |
922 util.nouideprecwarn(movemsg, '4.3') | 901 util.nouideprecwarn(movemsg, '4.3') |
923 return obsutil.allprecursors(obsstore, nodes, ignoreflags) | 902 return obsutil.allprecursors(obsstore, nodes, ignoreflags) |
903 | |
904 def allsuccessors(obsstore, nodes, ignoreflags=0): | |
905 movemsg = 'obsolete.allsuccessors moved to obsutil.allsuccessors' | |
906 util.nouideprecwarn(movemsg, '4.3') | |
907 return obsutil.allsuccessors(obsstore, nodes, ignoreflags) | |
924 | 908 |
925 def exclusivemarkers(repo, nodes): | 909 def exclusivemarkers(repo, nodes): |
926 movemsg = 'obsolete.exclusivemarkers moved to obsutil.exclusivemarkers' | 910 movemsg = 'obsolete.exclusivemarkers moved to obsutil.exclusivemarkers' |
927 repo.ui.deprecwarn(movemsg, '4.3') | 911 repo.ui.deprecwarn(movemsg, '4.3') |
928 return obsutil.exclusivemarkers(repo, nodes) | 912 return obsutil.exclusivemarkers(repo, nodes) |