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

  • Committer: Andrew Bennetts
  • Date: 2008-02-18 08:30:38 UTC
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20080218083038-tts55zsx5xrz3l2e
Lots of assorted hackery to reduce the number of imports for common operations.  Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
    warn,
60
60
    )
61
61
 
 
62
from bzrlib.lazy_import import lazy_import
 
63
lazy_import(globals(), """
 
64
from bzrlib import (
 
65
    errors,
 
66
    revision,
 
67
    revisionspec,
 
68
    tsort,
 
69
    )
 
70
""")
 
71
 
62
72
from bzrlib import (
63
73
    config,
64
74
    lazy_regex,
65
75
    registry,
66
76
    symbol_versioning,
67
77
    )
68
 
from bzrlib.errors import (
69
 
    BzrCommandError,
70
 
    )
71
78
from bzrlib.osutils import (
72
79
    format_date,
73
80
    get_terminal_encoding,
74
81
    terminal_width,
75
82
    )
76
 
from bzrlib.revision import (
77
 
    NULL_REVISION,
78
 
    )
79
 
from bzrlib.revisionspec import (
80
 
    RevisionInfo,
81
 
    )
82
83
from bzrlib.symbol_versioning import (
83
84
    deprecated_method,
84
85
    zero_seventeen,
85
86
    )
86
87
from bzrlib.trace import mutter
87
 
from bzrlib.tsort import (
88
 
    merge_sort,
89
 
    topo_sort,
90
 
    )
91
88
 
92
89
 
93
90
def find_touching_revisions(branch, file_id):
249
246
        generate_single_revision = ((start_rev_id == end_rev_id)
250
247
            and getattr(lf, 'supports_single_merge_revision', False))
251
248
        if not generate_single_revision:
252
 
            raise BzrCommandError('Selected log formatter only supports '
 
249
            raise errors.BzrCommandError('Selected log formatter only supports '
253
250
                'mainline revisions.')
254
251
        generate_merge_revisions = generate_single_revision
255
252
    view_revs_iter = get_view_revisions(mainline_revs, rev_nos, branch,
363
360
    if start_revision is None:
364
361
        start_revno = 1
365
362
    else:
366
 
        if isinstance(start_revision,RevisionInfo):
 
363
        if isinstance(start_revision, revisionspec.RevisionInfo):
367
364
            start_rev_id = start_revision.rev_id
368
365
            start_revno = start_revision.revno or 1
369
366
        else:
374
371
    if end_revision is None:
375
372
        end_revno = len(which_revs)
376
373
    else:
377
 
        if isinstance(end_revision,RevisionInfo):
 
374
        if isinstance(end_revision, revisionspec.RevisionInfo):
378
375
            end_rev_id = end_revision.rev_id
379
376
            end_revno = end_revision.revno or len(which_revs)
380
377
        else:
381
378
            branch.check_real_revno(end_revision)
382
379
            end_revno = end_revision
383
380
 
384
 
    if ((start_rev_id == NULL_REVISION)
385
 
        or (end_rev_id == NULL_REVISION)):
386
 
        raise BzrCommandError('Logging revision 0 is invalid.')
 
381
    if ((start_rev_id == revision.NULL_REVISION)
 
382
        or (end_rev_id == revision.NULL_REVISION)):
 
383
        raise errors.BzrCommandError('Logging revision 0 is invalid.')
387
384
    if start_revno > end_revno:
388
 
        raise BzrCommandError("Start revision must be older than "
389
 
                              "the end revision.")
 
385
        raise errors.BzrCommandError("Start revision must be older than "
 
386
                                     "the end revision.")
390
387
 
391
388
    # list indexes are 0-based; revisions are 1-based
392
389
    cut_revs = which_revs[(start_revno-1):(end_revno)]
475
472
    # build the ancestry of each revision in the graph
476
473
    # - only listing the ancestors that change the specific file.
477
474
    rev_graph = branch.repository.get_revision_graph(mainline_revisions[-1])
478
 
    sorted_rev_list = topo_sort(rev_graph)
 
475
    sorted_rev_list = tsort.topo_sort(rev_graph)
479
476
    ancestry = {}
480
477
    for rev in sorted_rev_list:
481
478
        parents = rev_graph[rev]
520
517
        for revision_id in revision_ids:
521
518
            yield revision_id, str(rev_nos[revision_id]), 0
522
519
        return
523
 
    merge_sorted_revisions = merge_sort(
 
520
    merge_sorted_revisions = tsort.merge_sort(
524
521
        branch.repository.get_revision_graph(mainline_revs[-1]),
525
522
        mainline_revs[-1],
526
523
        mainline_revs,
827
824
    try:
828
825
        return log_formatter_registry.make_formatter(name, *args, **kwargs)
829
826
    except KeyError:
830
 
        raise BzrCommandError("unknown log formatter: %r" % name)
 
827
        raise errors.BzrCommandError("unknown log formatter: %r" % name)
831
828
 
832
829
 
833
830
def show_one_log(revno, rev, delta, verbose, to_file, show_timezone):