~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2011-11-18 05:13:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6277.
  • Revision ID: mbp@canonical.com-20111118051319-9cj53bg5e06zl7rw
Remove more lzma related code

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
 
 
18
 
17
19
"""Code to show logs of changes.
18
20
 
19
21
Various flavors of log can be produced:
47
49
all the changes since the previous revision that touched hello.c.
48
50
"""
49
51
 
50
 
from __future__ import absolute_import
51
 
 
52
52
import codecs
53
53
from cStringIO import StringIO
54
54
from itertools import (
341
341
    from bzrlib import gpg
342
342
 
343
343
    gpg_strategy = gpg.GPGStrategy(None)
344
 
    result = repo.verify_revision_signature(rev_id, gpg_strategy)
 
344
    result = repo.verify_revision(rev_id, gpg_strategy)
345
345
    if result[0] == gpg.SIGNATURE_VALID:
346
346
        return "valid signature from {0}".format(result[1])
347
347
    if result[0] == gpg.SIGNATURE_KEY_MISSING:
580
580
        and (not generate_merge_revisions
581
581
             or not _has_merges(branch, end_rev_id))):
582
582
        # If a single revision is requested, check we can handle it
583
 
        return  _generate_one_revision(branch, end_rev_id, br_rev_id,
584
 
                                       br_revno)
585
 
    if not generate_merge_revisions:
586
 
        try:
587
 
            # If we only want to see linear revisions, we can iterate ...
588
 
            iter_revs = _linear_view_revisions(
589
 
                branch, start_rev_id, end_rev_id,
590
 
                exclude_common_ancestry=exclude_common_ancestry)
591
 
            # If a start limit was given and it's not obviously an
592
 
            # ancestor of the end limit, check it before outputting anything
593
 
            if (direction == 'forward'
594
 
                or (start_rev_id and not _is_obvious_ancestor(
595
 
                        branch, start_rev_id, end_rev_id))):
596
 
                    iter_revs = list(iter_revs)
597
 
            if direction == 'forward':
598
 
                iter_revs = reversed(iter_revs)
599
 
            return iter_revs
600
 
        except _StartNotLinearAncestor:
601
 
            # Switch to the slower implementation that may be able to find a
602
 
            # non-obvious ancestor out of the left-hand history.
603
 
            pass
604
 
    iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
605
 
                                        direction, delayed_graph_generation,
606
 
                                        exclude_common_ancestry)
607
 
    if direction == 'forward':
608
 
        iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
 
583
        iter_revs = _generate_one_revision(branch, end_rev_id, br_rev_id,
 
584
                                           br_revno)
 
585
    elif not generate_merge_revisions:
 
586
        # If we only want to see linear revisions, we can iterate ...
 
587
        iter_revs = _generate_flat_revisions(branch, start_rev_id, end_rev_id,
 
588
                                             direction, exclude_common_ancestry)
 
589
        if direction == 'forward':
 
590
            iter_revs = reversed(iter_revs)
 
591
    else:
 
592
        iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
 
593
                                            direction, delayed_graph_generation,
 
594
                                            exclude_common_ancestry)
 
595
        if direction == 'forward':
 
596
            iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
609
597
    return iter_revs
610
598
 
611
599
 
618
606
        return [(rev_id, revno_str, 0)]
619
607
 
620
608
 
 
609
def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction,
 
610
                             exclude_common_ancestry=False):
 
611
    result = _linear_view_revisions(
 
612
        branch, start_rev_id, end_rev_id,
 
613
        exclude_common_ancestry=exclude_common_ancestry)
 
614
    # If a start limit was given and it's not obviously an
 
615
    # ancestor of the end limit, check it before outputting anything
 
616
    if direction == 'forward' or (start_rev_id
 
617
        and not _is_obvious_ancestor(branch, start_rev_id, end_rev_id)):
 
618
        try:
 
619
            result = list(result)
 
620
        except _StartNotLinearAncestor:
 
621
            raise errors.BzrCommandError(gettext('Start revision not found in'
 
622
                ' left-hand history of end revision.'))
 
623
    return result
 
624
 
 
625
 
621
626
def _generate_all_revisions(branch, start_rev_id, end_rev_id, direction,
622
627
                            delayed_graph_generation,
623
628
                            exclude_common_ancestry=False):
1802
1807
 
1803
1808
 
1804
1809
log_formatter_registry.register('short', ShortLogFormatter,
1805
 
                                'Moderately short log format.')
 
1810
                                'Moderately short log format')
1806
1811
log_formatter_registry.register('long', LongLogFormatter,
1807
 
                                'Detailed log format.')
 
1812
                                'Detailed log format')
1808
1813
log_formatter_registry.register('line', LineLogFormatter,
1809
 
                                'Log format with one line per revision.')
 
1814
                                'Log format with one line per revision')
1810
1815
log_formatter_registry.register('gnu-changelog', GnuChangelogLogFormatter,
1811
 
                                'Format used by GNU ChangeLog files.')
 
1816
                                'Format used by GNU ChangeLog files')
1812
1817
 
1813
1818
 
1814
1819
def register_formatter(name, formatter):
2023
2028
      kind is one of values 'directory', 'file', 'symlink', 'tree-reference'.
2024
2029
      branch will be read-locked.
2025
2030
    """
2026
 
    from bzrlib.builtins import _get_revision_range
 
2031
    from builtins import _get_revision_range
2027
2032
    tree, b, path = controldir.ControlDir.open_containing_tree_or_branch(
2028
2033
        file_list[0])
2029
2034
    add_cleanup(b.lock_read().unlock)