/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/revision.py

  • Committer: Robert Collins
  • Date: 2007-08-22 00:00:26 UTC
  • mfrom: (2739 +trunk)
  • mto: (2592.3.96 repository)
  • mto: This revision was merged to the branch mainline in revision 2742.
  • Revision ID: robertc@robertcollins.net-20070822000026-kvufiqhlreokb1en
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
 
492
446
def ensure_null(revision_id):
493
447
    """Ensure only NULL_REVISION is used to represent the null revisionn"""
494
448
    if revision_id is None:
 
449
        symbol_versioning.warn('NULL_REVISION should be used for the null'
 
450
            ' revision instead of None, as of bzr 0.91.',
 
451
            DeprecationWarning, stacklevel=2)
495
452
        return NULL_REVISION
496
453
    else:
497
454
        return revision_id
500
457
def is_null(revision_id):
501
458
    if revision_id is None:
502
459
        symbol_versioning.warn('NULL_REVISION should be used for the null'
503
 
            ' revision instead of None, as of bzr 0.19.',
 
460
            ' revision instead of None, as of bzr 0.90.',
504
461
            DeprecationWarning, stacklevel=2)
505
462
    return revision_id in (None, NULL_REVISION)