~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 04:25:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5472.
  • Revision ID: andrew.bennetts@canonical.com-20101008042510-sg9vdhmnggilzxsk
Fix stray TAB in source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
70
70
    diff,
71
71
    errors,
72
72
    foreign,
 
73
    osutils,
73
74
    repository as _mod_repository,
74
75
    revision as _mod_revision,
75
76
    revisionspec,
 
77
    trace,
76
78
    tsort,
77
79
    )
78
80
""")
83
85
from bzrlib.osutils import (
84
86
    format_date,
85
87
    format_date_with_offset_in_original_timezone,
86
 
    get_diff_header_encoding,
87
88
    get_terminal_encoding,
88
89
    terminal_width,
89
90
    )
297
298
 
298
299
def _apply_log_request_defaults(rqst):
299
300
    """Apply default values to a request dictionary."""
300
 
    result = _DEFAULT_REQUEST_PARAMS.copy()
 
301
    result = _DEFAULT_REQUEST_PARAMS
301
302
    if rqst:
302
303
        result.update(rqst)
303
304
    return result
431
432
        else:
432
433
            specific_files = None
433
434
        s = StringIO()
434
 
        path_encoding = get_diff_header_encoding()
 
435
        path_encoding = osutils.get_diff_header_encoding()
435
436
        diff.show_diff_trees(tree_1, tree_2, s, specific_files, old_label='',
436
437
            new_label='', path_encoding=path_encoding)
437
438
        return s.getvalue()
539
540
        # It's the tip
540
541
        return [(br_rev_id, br_revno, 0)]
541
542
    else:
542
 
        revno_str = _compute_revno_str(branch, rev_id)
 
543
        revno = branch.revision_id_to_dotted_revno(rev_id)
 
544
        revno_str = '.'.join(str(n) for n in revno)
543
545
        return [(rev_id, revno_str, 0)]
544
546
 
545
547
 
625
627
    return len(parents) > 1
626
628
 
627
629
 
628
 
def _compute_revno_str(branch, rev_id):
629
 
    """Compute the revno string from a rev_id.
630
 
 
631
 
    :return: The revno string, or None if the revision is not in the supplied
632
 
        branch.
633
 
    """
634
 
    try:
635
 
        revno = branch.revision_id_to_dotted_revno(rev_id)
636
 
    except errors.NoSuchRevision:
637
 
        # The revision must be outside of this branch
638
 
        return None
639
 
    else:
640
 
        return '.'.join(str(n) for n in revno)
641
 
 
642
 
 
643
630
def _is_obvious_ancestor(branch, start_rev_id, end_rev_id):
644
631
    """Is start_rev_id an obvious ancestor of end_rev_id?"""
645
632
    if start_rev_id and end_rev_id:
646
 
        try:
647
 
            start_dotted = branch.revision_id_to_dotted_revno(start_rev_id)
648
 
            end_dotted = branch.revision_id_to_dotted_revno(end_rev_id)
649
 
        except errors.NoSuchRevision:
650
 
            # one or both is not in the branch; not obvious
651
 
            return False
 
633
        start_dotted = branch.revision_id_to_dotted_revno(start_rev_id)
 
634
        end_dotted = branch.revision_id_to_dotted_revno(end_rev_id)
652
635
        if len(start_dotted) == 1 and len(end_dotted) == 1:
653
636
            # both on mainline
654
637
            return start_dotted[0] <= end_dotted[0]
688
671
            end_rev_id = br_rev_id
689
672
        found_start = start_rev_id is None
690
673
        for revision_id in repo.iter_reverse_revision_history(end_rev_id):
691
 
            revno_str = _compute_revno_str(branch, revision_id)
 
674
            revno = branch.revision_id_to_dotted_revno(revision_id)
 
675
            revno_str = '.'.join(str(n) for n in revno)
692
676
            if not found_start and revision_id == start_rev_id:
693
677
                if not exclude_common_ancestry:
694
678
                    yield revision_id, revno_str, 0
1316
1300
    def __init__(self, rev=None, revno=None, merge_depth=0, delta=None,
1317
1301
                 tags=None, diff=None):
1318
1302
        self.rev = rev
1319
 
        if revno is None:
1320
 
            self.revno = None
1321
 
        else:
1322
 
            self.revno = str(revno)
 
1303
        self.revno = str(revno)
1323
1304
        self.merge_depth = merge_depth
1324
1305
        self.delta = delta
1325
1306
        self.tags = tags
1576
1557
                self.merge_marker(revision)))
1577
1558
        if revision.tags:
1578
1559
            lines.append('tags: %s' % (', '.join(revision.tags)))
1579
 
        if self.show_ids or revision.revno is None:
 
1560
        if self.show_ids:
1580
1561
            lines.append('revision-id: %s' % (revision.rev.revision_id,))
1581
 
        if self.show_ids:
1582
1562
            for parent_id in revision.rev.parent_ids:
1583
1563
                lines.append('parent: %s' % (parent_id,))
1584
1564
        lines.extend(self.custom_properties(revision.rev))
1647
1627
        indent = '    ' * depth
1648
1628
        revno_width = self.revno_width_by_depth.get(depth)
1649
1629
        if revno_width is None:
1650
 
            if revision.revno is None or revision.revno.find('.') == -1:
 
1630
            if revision.revno.find('.') == -1:
1651
1631
                # mainline revno, e.g. 12345
1652
1632
                revno_width = 5
1653
1633
            else:
1661
1641
        if revision.tags:
1662
1642
            tags = ' {%s}' % (', '.join(revision.tags))
1663
1643
        to_file.write(indent + "%*s %s\t%s%s%s\n" % (revno_width,
1664
 
                revision.revno or "", self.short_author(revision.rev),
 
1644
                revision.revno, self.short_author(revision.rev),
1665
1645
                format_date(revision.rev.timestamp,
1666
1646
                            revision.rev.timezone or 0,
1667
1647
                            self.show_timezone, date_fmt="%Y-%m-%d",
1668
1648
                            show_offset=False),
1669
1649
                tags, self.merge_marker(revision)))
1670
1650
        self.show_properties(revision.rev, indent+offset)
1671
 
        if self.show_ids or revision.revno is None:
 
1651
        if self.show_ids:
1672
1652
            to_file.write(indent + offset + 'revision-id:%s\n'
1673
1653
                          % (revision.rev.revision_id,))
1674
1654
        if not revision.rev.message: