~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: 2011-04-08 05:16:30 UTC
  • mfrom: (5728.5.10 log-not-in-branch)
  • Revision ID: pqm@pqm.ubuntu.com-20110408051630-wlk2z0cv73walyz0
(spiv) log no longer raises NoSuchRevision against revisions in the
 repository which are not in the current branch (#241998). Such revisions
 have no revno,
 so display the revision-id instead. It is now possible for a LogRevision to
 have a revno of None. (Matt Giuca) (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
539
539
        # It's the tip
540
540
        return [(br_rev_id, br_revno, 0)]
541
541
    else:
542
 
        revno = branch.revision_id_to_dotted_revno(rev_id)
543
 
        revno_str = '.'.join(str(n) for n in revno)
 
542
        revno_str = _compute_revno_str(branch, rev_id)
544
543
        return [(rev_id, revno_str, 0)]
545
544
 
546
545
 
626
625
    return len(parents) > 1
627
626
 
628
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
 
629
643
def _is_obvious_ancestor(branch, start_rev_id, end_rev_id):
630
644
    """Is start_rev_id an obvious ancestor of end_rev_id?"""
631
645
    if start_rev_id and end_rev_id:
632
 
        start_dotted = branch.revision_id_to_dotted_revno(start_rev_id)
633
 
        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
634
652
        if len(start_dotted) == 1 and len(end_dotted) == 1:
635
653
            # both on mainline
636
654
            return start_dotted[0] <= end_dotted[0]
670
688
            end_rev_id = br_rev_id
671
689
        found_start = start_rev_id is None
672
690
        for revision_id in repo.iter_reverse_revision_history(end_rev_id):
673
 
            revno = branch.revision_id_to_dotted_revno(revision_id)
674
 
            revno_str = '.'.join(str(n) for n in revno)
 
691
            revno_str = _compute_revno_str(branch, revision_id)
675
692
            if not found_start and revision_id == start_rev_id:
676
693
                if not exclude_common_ancestry:
677
694
                    yield revision_id, revno_str, 0
1299
1316
    def __init__(self, rev=None, revno=None, merge_depth=0, delta=None,
1300
1317
                 tags=None, diff=None):
1301
1318
        self.rev = rev
1302
 
        self.revno = str(revno)
 
1319
        if revno is None:
 
1320
            self.revno = None
 
1321
        else:
 
1322
            self.revno = str(revno)
1303
1323
        self.merge_depth = merge_depth
1304
1324
        self.delta = delta
1305
1325
        self.tags = tags
1556
1576
                self.merge_marker(revision)))
1557
1577
        if revision.tags:
1558
1578
            lines.append('tags: %s' % (', '.join(revision.tags)))
1559
 
        if self.show_ids:
 
1579
        if self.show_ids or revision.revno is None:
1560
1580
            lines.append('revision-id: %s' % (revision.rev.revision_id,))
 
1581
        if self.show_ids:
1561
1582
            for parent_id in revision.rev.parent_ids:
1562
1583
                lines.append('parent: %s' % (parent_id,))
1563
1584
        lines.extend(self.custom_properties(revision.rev))
1626
1647
        indent = '    ' * depth
1627
1648
        revno_width = self.revno_width_by_depth.get(depth)
1628
1649
        if revno_width is None:
1629
 
            if revision.revno.find('.') == -1:
 
1650
            if revision.revno is None or revision.revno.find('.') == -1:
1630
1651
                # mainline revno, e.g. 12345
1631
1652
                revno_width = 5
1632
1653
            else:
1640
1661
        if revision.tags:
1641
1662
            tags = ' {%s}' % (', '.join(revision.tags))
1642
1663
        to_file.write(indent + "%*s %s\t%s%s%s\n" % (revno_width,
1643
 
                revision.revno, self.short_author(revision.rev),
 
1664
                revision.revno or "", self.short_author(revision.rev),
1644
1665
                format_date(revision.rev.timestamp,
1645
1666
                            revision.rev.timezone or 0,
1646
1667
                            self.show_timezone, date_fmt="%Y-%m-%d",
1647
1668
                            show_offset=False),
1648
1669
                tags, self.merge_marker(revision)))
1649
1670
        self.show_properties(revision.rev, indent+offset)
1650
 
        if self.show_ids:
 
1671
        if self.show_ids or revision.revno is None:
1651
1672
            to_file.write(indent + offset + 'revision-id:%s\n'
1652
1673
                          % (revision.rev.revision_id,))
1653
1674
        if not revision.rev.message: