~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

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