##// END OF EJS Templates
obsutil: move 'foreground' to the new modules...
marmoute -
r33147:7017567e default
parent child Browse files
Show More
@@ -19,7 +19,7 b' from . import ('
19 19 encoding,
20 20 error,
21 21 lock as lockmod,
22 obsolete,
22 obsutil,
23 23 pycompat,
24 24 scmutil,
25 25 txnutil,
@@ -682,7 +682,7 b' def validdest(repo, old, new):'
682 682 # (new != nullrev has been excluded by the previous check)
683 683 return True
684 684 elif repo.obsstore:
685 return new.node() in obsolete.foreground(repo, [old.node()])
685 return new.node() in obsutil.foreground(repo, [old.node()])
686 686 else:
687 687 # still an independent clause as it is lazier (and therefore faster)
688 688 return old.descendant(new)
@@ -28,7 +28,7 b' from . import ('
28 28 error,
29 29 filemerge,
30 30 match as matchmod,
31 obsolete,
31 obsutil,
32 32 pycompat,
33 33 scmutil,
34 34 subrepo,
@@ -1588,8 +1588,8 b' def update(repo, node, branchmerge, forc'
1588 1588 dirty = wc.dirty(missing=True)
1589 1589 if dirty:
1590 1590 # Branching is a bit strange to ensure we do the minimal
1591 # amount of call to obsolete.foreground.
1592 foreground = obsolete.foreground(repo, [p1.node()])
1591 # amount of call to obsutil.foreground.
1592 foreground = obsutil.foreground(repo, [p1.node()])
1593 1593 # note: the <node> variable contains a random identifier
1594 1594 if repo[node].node() in foreground:
1595 1595 pass # allow updating to successors
@@ -869,32 +869,6 b' def successormarkers(ctx):'
869 869 for data in ctx.repo().obsstore.successors.get(ctx.node(), ()):
870 870 yield marker(ctx.repo(), data)
871 871
872 def foreground(repo, nodes):
873 """return all nodes in the "foreground" of other node
874
875 The foreground of a revision is anything reachable using parent -> children
876 or precursor -> successor relation. It is very similar to "descendant" but
877 augmented with obsolescence information.
878
879 Beware that possible obsolescence cycle may result if complex situation.
880 """
881 repo = repo.unfiltered()
882 foreground = set(repo.set('%ln::', nodes))
883 if repo.obsstore:
884 # We only need this complicated logic if there is obsolescence
885 # XXX will probably deserve an optimised revset.
886 nm = repo.changelog.nodemap
887 plen = -1
888 # compute the whole set of successors or descendants
889 while len(foreground) != plen:
890 plen = len(foreground)
891 succs = set(c.node() for c in foreground)
892 mutable = [c.node() for c in foreground if c.mutable()]
893 succs.update(obsutil.allsuccessors(repo.obsstore, mutable))
894 known = (n for n in succs if n in nm)
895 foreground = set(repo.set('%ln::', known))
896 return set(c.node() for c in foreground)
897
898 872 # keep compatibility for the 4.3 cycle
899 873 def allprecursors(obsstore, nodes, ignoreflags=0):
900 874 movemsg = 'obsolete.allprecursors moved to obsutil.allprecursors'
@@ -911,6 +885,11 b' def exclusivemarkers(repo, nodes):'
911 885 repo.ui.deprecwarn(movemsg, '4.3')
912 886 return obsutil.exclusivemarkers(repo, nodes)
913 887
888 def foreground(repo, nodes):
889 movemsg = 'obsolete.foreground moved to obsutil.foreground'
890 repo.ui.deprecwarn(movemsg, '4.3')
891 return obsutil.foreground(repo, nodes)
892
914 893 def successorssets(repo, initialnode, cache=None):
915 894 movemsg = 'obsolete.successorssets moved to obsutil.successorssets'
916 895 repo.ui.deprecwarn(movemsg, '4.3')
@@ -203,6 +203,32 b' def exclusivemarkers(repo, nodes):'
203 203
204 204 return exclmarkers
205 205
206 def foreground(repo, nodes):
207 """return all nodes in the "foreground" of other node
208
209 The foreground of a revision is anything reachable using parent -> children
210 or precursor -> successor relation. It is very similar to "descendant" but
211 augmented with obsolescence information.
212
213 Beware that possible obsolescence cycle may result if complex situation.
214 """
215 repo = repo.unfiltered()
216 foreground = set(repo.set('%ln::', nodes))
217 if repo.obsstore:
218 # We only need this complicated logic if there is obsolescence
219 # XXX will probably deserve an optimised revset.
220 nm = repo.changelog.nodemap
221 plen = -1
222 # compute the whole set of successors or descendants
223 while len(foreground) != plen:
224 plen = len(foreground)
225 succs = set(c.node() for c in foreground)
226 mutable = [c.node() for c in foreground if c.mutable()]
227 succs.update(allsuccessors(repo.obsstore, mutable))
228 known = (n for n in succs if n in nm)
229 foreground = set(repo.set('%ln::', known))
230 return set(c.node() for c in foreground)
231
206 232 def successorssets(repo, initialnode, cache=None):
207 233 """Return set of all latest successors of initial nodes
208 234
General Comments 0
You need to be logged in to leave comments. Login now