~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-18 03:07:07 UTC
  • mfrom: (3535.5.1 lean_imports)
  • Revision ID: pqm@pqm.ubuntu.com-20080718030707-qimx9fv1d4xhlk1m
(jam) Some small import cleanups, to reduce unused dependencies.

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
 
62
65
from bzrlib import (
63
66
    config,
64
 
    lazy_regex,
 
67
    errors,
 
68
    repository as _mod_repository,
 
69
    revision as _mod_revision,
 
70
    revisionspec,
 
71
    trace,
 
72
    tsort,
 
73
    )
 
74
""")
 
75
 
 
76
from bzrlib import (
65
77
    registry,
66
78
    )
67
 
from bzrlib.errors import (
68
 
    BzrCommandError,
69
 
    )
70
79
from bzrlib.osutils import (
71
80
    format_date,
72
81
    get_terminal_encoding,
73
82
    terminal_width,
74
83
    )
75
 
from bzrlib.repository import _strip_NULL_ghosts
76
 
from bzrlib.revision import (
77
 
    NULL_REVISION,
78
 
    )
79
 
from bzrlib.revisionspec import (
80
 
    RevisionInfo,
81
 
    )
82
 
from bzrlib.trace import mutter
83
 
from bzrlib.tsort import (
84
 
    merge_sort,
85
 
    topo_sort,
86
 
    )
87
84
 
88
85
 
89
86
def find_touching_revisions(branch, file_id):
204
201
        warn("not a LogFormatter instance: %r" % lf)
205
202
 
206
203
    if specific_fileid:
207
 
        mutter('get log for file_id %r', specific_fileid)
 
204
        trace.mutter('get log for file_id %r', specific_fileid)
208
205
    generate_merge_revisions = getattr(lf, 'supports_merge_revisions', False)
209
206
    allow_single_merge_revision = getattr(lf,
210
207
        'supports_single_merge_revision', False)
265
262
        generate_single_revision = ((start_rev_id == end_rev_id)
266
263
            and allow_single_merge_revision)
267
264
        if not generate_single_revision:
268
 
            raise BzrCommandError('Selected log formatter only supports '
269
 
                'mainline revisions.')
 
265
            raise errors.BzrCommandError('Selected log formatter only supports'
 
266
                ' mainline revisions.')
270
267
        generate_merge_revisions = generate_single_revision
271
268
    view_revs_iter = get_view_revisions(mainline_revs, rev_nos, branch,
272
269
                          direction, include_merges=generate_merge_revisions)
349
346
    if start_revision is None:
350
347
        start_revno = 1
351
348
    else:
352
 
        if isinstance(start_revision, RevisionInfo):
 
349
        if isinstance(start_revision, revisionspec.RevisionInfo):
353
350
            start_rev_id = start_revision.rev_id
354
351
            start_revno = start_revision.revno or 1
355
352
        else:
360
357
    if end_revision is None:
361
358
        end_revno = branch_revno
362
359
    else:
363
 
        if isinstance(end_revision, RevisionInfo):
 
360
        if isinstance(end_revision, revisionspec.RevisionInfo):
364
361
            end_rev_id = end_revision.rev_id
365
362
            end_revno = end_revision.revno or branch_revno
366
363
        else:
367
364
            branch.check_real_revno(end_revision)
368
365
            end_revno = end_revision
369
366
 
370
 
    if ((start_rev_id == NULL_REVISION)
371
 
        or (end_rev_id == NULL_REVISION)):
372
 
        raise BzrCommandError('Logging revision 0 is invalid.')
 
367
    if ((start_rev_id == _mod_revision.NULL_REVISION)
 
368
        or (end_rev_id == _mod_revision.NULL_REVISION)):
 
369
        raise errors.BzrCommandError('Logging revision 0 is invalid.')
373
370
    if start_revno > end_revno:
374
 
        raise BzrCommandError("Start revision must be older than "
375
 
                              "the end revision.")
 
371
        raise errors.BzrCommandError("Start revision must be older than "
 
372
                                     "the end revision.")
376
373
 
377
374
    if end_revno < start_revno:
378
375
        return None, None, None, None
474
471
    # don't request it.
475
472
    parent_map = dict(((key, value) for key, value in
476
473
        graph.iter_ancestry(mainline_revisions[1:]) if value is not None))
477
 
    sorted_rev_list = topo_sort(parent_map.items())
 
474
    sorted_rev_list = tsort.topo_sort(parent_map.items())
478
475
    text_keys = [(file_id, rev_id) for rev_id in sorted_rev_list]
479
476
    modified_text_versions = branch.repository.texts.get_parent_map(text_keys)
480
477
    ancestry = {}
536
533
    parent_map = dict(((key, value) for key, value in
537
534
        graph.iter_ancestry(mainline_revs[1:]) if value is not None))
538
535
    # filter out ghosts; merge_sort errors on ghosts.
539
 
    rev_graph = _strip_NULL_ghosts(parent_map)
540
 
    merge_sorted_revisions = merge_sort(
 
536
    rev_graph = _mod_repository._strip_NULL_ghosts(parent_map)
 
537
    merge_sorted_revisions = tsort.merge_sort(
541
538
        rev_graph,
542
539
        mainline_revs[-1],
543
540
        mainline_revs,
832
829
    try:
833
830
        return log_formatter_registry.make_formatter(name, *args, **kwargs)
834
831
    except KeyError:
835
 
        raise BzrCommandError("unknown log formatter: %r" % name)
 
832
        raise errors.BzrCommandError("unknown log formatter: %r" % name)
836
833
 
837
834
 
838
835
def show_one_log(revno, rev, delta, verbose, to_file, show_timezone):