/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/graph.py

  • Committer: John Arbash Meinel
  • Date: 2007-12-05 18:47:51 UTC
  • mfrom: (3079 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3080.
  • Revision ID: john@arbash-meinel.com-20071205184751-58fi7xoj8ddox6ch
[merge] bzr.dev 3079

Show diffs side-by-side

added added

removed removed

Lines of Context:
242
242
            order if they need it.
243
243
        """
244
244
        candidate_heads = set(keys)
 
245
        if revision.NULL_REVISION in candidate_heads:
 
246
            # NULL_REVISION is only a head if it is the only entry
 
247
            candidate_heads.remove(revision.NULL_REVISION)
 
248
            if not candidate_heads:
 
249
                return set([revision.NULL_REVISION])
245
250
        if len(candidate_heads) < 2:
246
251
            return candidate_heads
247
252
        searchers = dict((c, self._make_breadth_first_searcher([c]))
310
315
            common_walker.start_searching(new_common)
311
316
        return candidate_heads
312
317
 
313
 
    def find_unique_lca(self, left_revision, right_revision):
 
318
    def find_unique_lca(self, left_revision, right_revision,
 
319
                        count_steps=False):
314
320
        """Find a unique LCA.
315
321
 
316
322
        Find lowest common ancestors.  If there is no unique  common
321
327
 
322
328
        Note that None is not an acceptable substitute for NULL_REVISION.
323
329
        in the input for this method.
 
330
 
 
331
        :param count_steps: If True, the return value will be a tuple of
 
332
            (unique_lca, steps) where steps is the number of times that
 
333
            find_lca was run.  If False, only unique_lca is returned.
324
334
        """
325
335
        revisions = [left_revision, right_revision]
 
336
        steps = 0
326
337
        while True:
 
338
            steps += 1
327
339
            lca = self.find_lca(*revisions)
328
340
            if len(lca) == 1:
329
 
                return lca.pop()
 
341
                result = lca.pop()
 
342
                if count_steps:
 
343
                    return result, steps
 
344
                else:
 
345
                    return result
330
346
            if len(lca) == 0:
331
347
                raise errors.NoCommonAncestor(left_revision, right_revision)
332
348
            revisions = lca
348
364
        smallest number of parent looksup to determine the ancestral
349
365
        relationship between N revisions.
350
366
        """
351
 
        if revision.is_null(candidate_ancestor):
352
 
            return True
353
 
        if revision.is_null(candidate_descendant):
354
 
            # if candidate_descendant is NULL_REVISION, then only
355
 
            # candidate_ancestor == NULL_REVISION is an ancestor, but we've
356
 
            # already handled that case.
357
 
            return False
358
367
        return set([candidate_descendant]) == self.heads(
359
368
            [candidate_ancestor, candidate_descendant])
360
369