##// END OF EJS Templates
obsutil: move 'allsuccessors' to the new modules...
marmoute -
r33146:0a370b93 default
parent child Browse files
Show More
@@ -40,6 +40,7 b' from mercurial import ('
40 merge as mergemod,
40 merge as mergemod,
41 mergeutil,
41 mergeutil,
42 obsolete,
42 obsolete,
43 obsutil,
43 patch,
44 patch,
44 phases,
45 phases,
45 registrar,
46 registrar,
@@ -1454,7 +1455,7 b' def _computeobsoletenotrebased(repo, reb'
1454 cl = repo.changelog
1455 cl = repo.changelog
1455 for r in rebaseobsrevs:
1456 for r in rebaseobsrevs:
1456 node = cl.node(r)
1457 node = cl.node(r)
1457 for s in obsolete.allsuccessors(repo.obsstore, [node]):
1458 for s in obsutil.allsuccessors(repo.obsstore, [node]):
1458 try:
1459 try:
1459 allsuccessors[cl.rev(s)] = cl.rev(node)
1460 allsuccessors[cl.rev(s)] = cl.rev(node)
1460 except LookupError:
1461 except LookupError:
@@ -869,27 +869,6 b' def successormarkers(ctx):'
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
@@ -911,7 +890,7 b' def foreground(repo, nodes):'
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)
@@ -922,6 +901,11 b' def allprecursors(obsstore, nodes, ignor'
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)
924
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)
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')
@@ -57,6 +57,27 b' def allprecursors(obsstore, nodes, ignor'
57 seen.add(suc)
57 seen.add(suc)
58 remaining.add(suc)
58 remaining.add(suc)
59
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)
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])
General Comments 0
You need to be logged in to leave comments. Login now