equal
deleted
inserted
replaced
259 |
259 |
260 If roots is unspecified, nullid is assumed as the only root. |
260 If roots is unspecified, nullid is assumed as the only root. |
261 If heads is unspecified, it is taken to be the output of the |
261 If heads is unspecified, it is taken to be the output of the |
262 heads method (i.e. a list of all nodes in the repository that |
262 heads method (i.e. a list of all nodes in the repository that |
263 have no children).""" |
263 have no children).""" |
|
264 nonodes = ([], [], []) |
264 if roots is not None: |
265 if roots is not None: |
265 roots = list(roots) |
266 roots = list(roots) |
|
267 if not roots: |
|
268 return nonodes |
266 lowestrev = min([self.rev(n) for n in roots]) |
269 lowestrev = min([self.rev(n) for n in roots]) |
267 else: |
270 else: |
268 roots = [nullid] # Everybody's a descendent of nullid |
271 roots = [nullid] # Everybody's a descendent of nullid |
269 lowestrev = -1 |
272 lowestrev = -1 |
270 if (lowestrev == -1) and (heads is None): |
273 if (lowestrev == -1) and (heads is None): |
278 # Set ancestors to None to signal that every node is an ancestor. |
281 # Set ancestors to None to signal that every node is an ancestor. |
279 ancestors = None |
282 ancestors = None |
280 # Set heads to an empty dictionary for later discovery of heads |
283 # Set heads to an empty dictionary for later discovery of heads |
281 heads = {} |
284 heads = {} |
282 else: |
285 else: |
|
286 heads = list(heads) |
|
287 if not heads: |
|
288 return nonodes |
283 ancestors = {} |
289 ancestors = {} |
284 # Start at the top and keep marking parents until we're done. |
290 # Start at the top and keep marking parents until we're done. |
285 nodestotag = list(heads) |
291 nodestotag = heads[:] |
286 # Turn heads into a dictionary so we can remove 'fake' heads. |
292 # Turn heads into a dictionary so we can remove 'fake' heads. |
287 # Also, later we will be using it to filter out the heads we can't |
293 # Also, later we will be using it to filter out the heads we can't |
288 # find from roots. |
294 # find from roots. |
289 heads = dict.fromkeys(heads, 0) |
295 heads = dict.fromkeys(heads, 0) |
290 # Remember where the top was so we can use it as a limit later. |
296 # Remember where the top was so we can use it as a limit later. |
309 elif n in heads: # We've seen it before, is it a fake head? |
315 elif n in heads: # We've seen it before, is it a fake head? |
310 # So it is, real heads should not be the ancestors of |
316 # So it is, real heads should not be the ancestors of |
311 # any other heads. |
317 # any other heads. |
312 heads.pop(n) |
318 heads.pop(n) |
313 if not ancestors: |
319 if not ancestors: |
314 return ([], [], []) |
320 return nonodes |
315 # Now that we have our set of ancestors, we want to remove any |
321 # Now that we have our set of ancestors, we want to remove any |
316 # roots that are not ancestors. |
322 # roots that are not ancestors. |
317 |
323 |
318 # If one of the roots was nullid, everything is included anyway. |
324 # If one of the roots was nullid, everything is included anyway. |
319 if lowestrev > -1: |
325 if lowestrev > -1: |
325 # Recompute the lowest revision |
331 # Recompute the lowest revision |
326 if roots: |
332 if roots: |
327 lowestrev = min([self.rev(n) for n in roots]) |
333 lowestrev = min([self.rev(n) for n in roots]) |
328 else: |
334 else: |
329 # No more roots? Return empty list |
335 # No more roots? Return empty list |
330 return ([], [], []) |
336 return nonodes |
331 else: |
337 else: |
332 # We are descending from nullid, and don't need to care about |
338 # We are descending from nullid, and don't need to care about |
333 # any other roots. |
339 # any other roots. |
334 lowestrev = -1 |
340 lowestrev = -1 |
335 roots = [nullid] |
341 roots = [nullid] |