Mercurial > public > mercurial-scm > hg
comparison mercurial/obsolete.py @ 33144: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
33143:d09ae850296d | 33144:d0e5bf12f314 |
---|---|
888 for suc in mark[1]: | 888 for suc in mark[1]: |
889 if suc not in seen: | 889 if suc not in seen: |
890 seen.add(suc) | 890 seen.add(suc) |
891 remaining.add(suc) | 891 remaining.add(suc) |
892 | 892 |
893 def allprecursors(obsstore, nodes, ignoreflags=0): | |
894 """Yield node for every precursors of <nodes>. | |
895 | |
896 Some precursors may be unknown locally. | |
897 | |
898 This is a linear yield unsuited to detecting folded changesets. It includes | |
899 initial nodes too.""" | |
900 | |
901 remaining = set(nodes) | |
902 seen = set(remaining) | |
903 while remaining: | |
904 current = remaining.pop() | |
905 yield current | |
906 for mark in obsstore.precursors.get(current, ()): | |
907 # ignore marker flagged with specified flag | |
908 if mark[2] & ignoreflags: | |
909 continue | |
910 suc = mark[0] | |
911 if suc not in seen: | |
912 seen.add(suc) | |
913 remaining.add(suc) | |
914 | |
915 def foreground(repo, nodes): | 893 def foreground(repo, nodes): |
916 """return all nodes in the "foreground" of other node | 894 """return all nodes in the "foreground" of other node |
917 | 895 |
918 The foreground of a revision is anything reachable using parent -> children | 896 The foreground of a revision is anything reachable using parent -> children |
919 or precursor -> successor relation. It is very similar to "descendant" but | 897 or precursor -> successor relation. It is very similar to "descendant" but |
936 succs.update(allsuccessors(repo.obsstore, mutable)) | 914 succs.update(allsuccessors(repo.obsstore, mutable)) |
937 known = (n for n in succs if n in nm) | 915 known = (n for n in succs if n in nm) |
938 foreground = set(repo.set('%ln::', known)) | 916 foreground = set(repo.set('%ln::', known)) |
939 return set(c.node() for c in foreground) | 917 return set(c.node() for c in foreground) |
940 | 918 |
919 # keep compatibility for the 4.3 cycle | |
920 def allprecursors(obsstore, nodes, ignoreflags=0): | |
921 movemsg = 'obsolete.allprecursors moved to obsutil.allprecursors' | |
922 util.nouideprecwarn(movemsg, '4.3') | |
923 return obsutil.allprecursors(obsstore, nodes, ignoreflags) | |
924 | |
941 def exclusivemarkers(repo, nodes): | 925 def exclusivemarkers(repo, nodes): |
942 movemsg = 'obsolete.exclusivemarkers moved to obsutil.exclusivemarkers' | 926 movemsg = 'obsolete.exclusivemarkers moved to obsutil.exclusivemarkers' |
943 repo.ui.deprecwarn(movemsg, '4.3') | 927 repo.ui.deprecwarn(movemsg, '4.3') |
944 return obsutil.exclusivemarkers(repo, nodes) | 928 return obsutil.exclusivemarkers(repo, nodes) |
945 | 929 |
1043 for ctx in repo.set('(not public()) and (not obsolete())'): | 1027 for ctx in repo.set('(not public()) and (not obsolete())'): |
1044 rev = ctx.rev() | 1028 rev = ctx.rev() |
1045 # We only evaluate mutable, non-obsolete revision | 1029 # We only evaluate mutable, non-obsolete revision |
1046 node = ctx.node() | 1030 node = ctx.node() |
1047 # (future) A cache of precursors may worth if split is very common | 1031 # (future) A cache of precursors may worth if split is very common |
1048 for pnode in allprecursors(repo.obsstore, [node], | 1032 for pnode in obsutil.allprecursors(repo.obsstore, [node], |
1049 ignoreflags=bumpedfix): | 1033 ignoreflags=bumpedfix): |
1050 prev = torev(pnode) # unfiltered! but so is phasecache | 1034 prev = torev(pnode) # unfiltered! but so is phasecache |
1051 if (prev is not None) and (phase(repo, prev) <= public): | 1035 if (prev is not None) and (phase(repo, prev) <= public): |
1052 # we have a public precursor | 1036 # we have a public precursor |
1053 bumped.add(rev) | 1037 bumped.add(rev) |