245 |
245 |
246 # Cleanup opportunity: this is *identical* to the revlog.py version |
246 # Cleanup opportunity: this is *identical* to the revlog.py version |
247 def descendants(self, revs): |
247 def descendants(self, revs): |
248 return dagop.descendantrevs(revs, self.revs, self.parentrevs) |
248 return dagop.descendantrevs(revs, self.revs, self.parentrevs) |
249 |
249 |
|
250 def incrementalmissingrevs(self, common=None): |
|
251 """Return an object that can be used to incrementally compute the |
|
252 revision numbers of the ancestors of arbitrary sets that are not |
|
253 ancestors of common. This is an ancestor.incrementalmissingancestors |
|
254 object. |
|
255 |
|
256 'common' is a list of revision numbers. If common is not supplied, uses |
|
257 nullrev. |
|
258 """ |
|
259 if common is None: |
|
260 common = [nodemod.nullrev] |
|
261 |
|
262 return ancestor.incrementalmissingancestors(self.parentrevs, common) |
|
263 |
|
264 def findmissing(self, common=None, heads=None): |
|
265 """Return the ancestors of heads that are not ancestors of common. |
|
266 |
|
267 More specifically, return a list of nodes N such that every N |
|
268 satisfies the following constraints: |
|
269 |
|
270 1. N is an ancestor of some node in 'heads' |
|
271 2. N is not an ancestor of any node in 'common' |
|
272 |
|
273 The list is sorted by revision number, meaning it is |
|
274 topologically sorted. |
|
275 |
|
276 'heads' and 'common' are both lists of node IDs. If heads is |
|
277 not supplied, uses all of the revlog's heads. If common is not |
|
278 supplied, uses nullid.""" |
|
279 if common is None: |
|
280 common = [nodemod.nullid] |
|
281 if heads is None: |
|
282 heads = self.heads() |
|
283 |
|
284 common = [self.rev(n) for n in common] |
|
285 heads = [self.rev(n) for n in heads] |
|
286 |
|
287 inc = self.incrementalmissingrevs(common=common) |
|
288 return [self.node(r) for r in inc.missingancestors(heads)] |
|
289 |
|
290 def children(self, node): |
|
291 """find the children of a given node""" |
|
292 c = [] |
|
293 p = self.rev(node) |
|
294 for r in self.revs(start=p + 1): |
|
295 prevs = [pr for pr in self.parentrevs(r) if pr != nodemod.nullrev] |
|
296 if prevs: |
|
297 for pr in prevs: |
|
298 if pr == p: |
|
299 c.append(self.node(r)) |
|
300 elif p == nodemod.nullrev: |
|
301 c.append(self.node(r)) |
|
302 return c |
|
303 |
250 def reachableroots(self, minroot, heads, roots, includepath=False): |
304 def reachableroots(self, minroot, heads, roots, includepath=False): |
251 return dagop._reachablerootspure( |
305 return dagop._reachablerootspure( |
252 self.parentrevs, minroot, roots, heads, includepath |
306 self.parentrevs, minroot, roots, heads, includepath |
253 ) |
307 ) |
254 |
308 |