~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Aaron Bentley
  • Date: 2007-08-20 13:07:12 UTC
  • mfrom: (2732 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2733.
  • Revision ID: abentley@panoramicfeedback.com-20070820130712-buopmg528zcgwyxc
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
from bzrlib.osutils import contains_whitespace
32
32
from bzrlib.progress import DummyProgress
33
33
from bzrlib.symbol_versioning import (deprecated_function,
34
 
        zero_eight,
35
34
        )
36
35
 
37
36
NULL_REVISION="null:"
430
429
            source.unlock()
431
430
 
432
431
 
433
 
@deprecated_function(zero_eight)
434
 
def get_intervening_revisions(ancestor_id, rev_id, rev_source,
435
 
                              revision_history=None):
436
 
    """Find the longest line of descent from maybe_ancestor to revision.
437
 
    Revision history is followed where possible.
438
 
 
439
 
    If ancestor_id == rev_id, list will be empty.
440
 
    Otherwise, rev_id will be the last entry.  ancestor_id will never appear.
441
 
    If ancestor_id is not an ancestor, NotAncestor will be thrown
442
 
    """
443
 
    root, ancestors, descendants = revision_graph(rev_id, rev_source)
444
 
    if len(descendants) == 0:
445
 
        raise errors.NoSuchRevision(rev_source, rev_id)
446
 
    if ancestor_id not in descendants:
447
 
        rev_source.get_revision(ancestor_id)
448
 
        raise errors.NotAncestor(rev_id, ancestor_id)
449
 
    root_descendants = all_descendants(descendants, ancestor_id)
450
 
    root_descendants.add(ancestor_id)
451
 
    if rev_id not in root_descendants:
452
 
        raise errors.NotAncestor(rev_id, ancestor_id)
453
 
    distances = node_distances(descendants, ancestors, ancestor_id,
454
 
                               root_descendants=root_descendants)
455
 
 
456
 
    def best_ancestor(rev_id):
457
 
        best = None
458
 
        for anc_id in ancestors[rev_id]:
459
 
            try:
460
 
                distance = distances[anc_id]
461
 
            except KeyError:
462
 
                continue
463
 
            if revision_history is not None and anc_id in revision_history:
464
 
                return anc_id
465
 
            elif best is None or distance > best[1]:
466
 
                best = (anc_id, distance)
467
 
        return best[0]
468
 
 
469
 
    next = rev_id
470
 
    path = []
471
 
    while next != ancestor_id:
472
 
        path.append(next)
473
 
        next = best_ancestor(next)
474
 
    path.reverse()
475
 
    return path
476
 
 
477
 
 
478
432
def is_reserved_id(revision_id):
479
433
    """Determine whether a revision id is reserved
480
434