/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/log.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-05-15 00:35:21 UTC
  • mfrom: (6965.1.3 horizon)
  • Revision ID: breezy.the.bot@gmail.com-20180515003521-u1v3c75m5jxi5ts9
Support running 'bzr log' in a shallow git branch.

Revision numbers are not displayed in this case, since they are not known.

Merged from https://code.launchpad.net/~jelmer/brz/horizon-log/+merge/345552

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
    else:
199
199
        diff_type = None
200
200
 
 
201
    if isinstance(start_revision, int):
 
202
        try:
 
203
            start_revision = revisionspec.RevisionInfo(branch, start_revision)
 
204
        except errors.NoSuchRevision:
 
205
            raise errors.InvalidRevisionNumber(start_revision)
 
206
 
 
207
    if isinstance(end_revision, int):
 
208
        try:
 
209
            end_revision = revisionspec.RevisionInfo(branch, end_revision)
 
210
        except errors.NoSuchRevision:
 
211
            raise errors.InvalidRevisionNumber(end_revision)
 
212
 
 
213
    if end_revision is not None and end_revision.revno == 0:
 
214
        raise errors.InvalidRevisionNumber(end_revision.revno)
 
215
 
201
216
    # Build the request and execute it
202
217
    rqst = make_log_request_dict(direction=direction, specific_fileids=file_ids,
203
218
        start_revision=start_revision, end_revision=end_revision,
565
580
            '--exclude-common-ancestry requires two different revisions'))
566
581
    if direction not in ('reverse', 'forward'):
567
582
        raise ValueError(gettext('invalid direction %r') % direction)
568
 
    br_revno, br_rev_id = branch.last_revision_info()
569
 
    if br_revno == 0:
 
583
    br_rev_id = branch.last_revision()
 
584
    if br_rev_id == _mod_revision.NULL_REVISION:
570
585
        return []
571
586
 
572
587
    if (end_rev_id and start_rev_id == end_rev_id
574
589
             or not _has_merges(branch, end_rev_id))):
575
590
        # If a single revision is requested, check we can handle it
576
591
        return  _generate_one_revision(branch, end_rev_id, br_rev_id,
577
 
                                       br_revno)
 
592
                                       branch.revno())
578
593
    if not generate_merge_revisions:
579
594
        try:
580
595
            # If we only want to see linear revisions, we can iterate ...
728
743
    :raises _StartNotLinearAncestor: if a start_rev_id is specified but
729
744
        is not found walking the left-hand history
730
745
    """
731
 
    br_revno, br_rev_id = branch.last_revision_info()
732
746
    repo = branch.repository
733
747
    graph = repo.get_graph()
734
748
    if start_rev_id is None and end_rev_id is None:
735
 
        cur_revno = br_revno
 
749
        try:
 
750
            br_revno, br_rev_id = branch.last_revision_info()
 
751
        except errors.GhostRevisionsHaveNoRevno:
 
752
            br_rev_id = branch.last_revision()
 
753
            cur_revno = None
 
754
        else:
 
755
            cur_revno = br_revno
736
756
        graph_iter = graph.iter_lefthand_ancestry(br_rev_id,
737
757
            (_mod_revision.NULL_REVISION,))
738
758
        while True:
743
763
                yield e.revision_id, None, None
744
764
                break
745
765
            else:
746
 
                yield revision_id, str(cur_revno), 0
747
 
                cur_revno -= 1
 
766
                yield revision_id, str(cur_revno) if cur_revno is not None else None, 0
 
767
                if cur_revno is not None:
 
768
                    cur_revno -= 1
748
769
    else:
 
770
        br_rev_id = branch.last_revision()
749
771
        if end_rev_id is None:
750
772
            end_rev_id = br_rev_id
751
773
        found_start = start_rev_id is None
1049
1071
    :param  branch: The branch containing the revisions.
1050
1072
 
1051
1073
    :param  start_revision: The first revision to be logged.
1052
 
            For backwards compatibility this may be a mainline integer revno,
1053
1074
            but for merge revision support a RevisionInfo is expected.
1054
1075
 
1055
1076
    :param  end_revision: The last revision to be logged.
1058
1079
 
1059
1080
    :return: (start_rev_id, end_rev_id) tuple.
1060
1081
    """
1061
 
    branch_revno, branch_rev_id = branch.last_revision_info()
1062
1082
    start_rev_id = None
1063
 
    if start_revision is None:
 
1083
    start_revno = None
 
1084
    if start_revision is not None:
 
1085
        if not isinstance(start_revision, revisionspec.RevisionInfo):
 
1086
            raise TypeError(start_revision)
 
1087
        start_rev_id = start_revision.rev_id
 
1088
        start_revno = start_revision.revno
 
1089
    if start_revno is None:
1064
1090
        start_revno = 1
1065
 
    else:
1066
 
        if isinstance(start_revision, revisionspec.RevisionInfo):
1067
 
            start_rev_id = start_revision.rev_id
1068
 
            start_revno = start_revision.revno or 1
1069
 
        else:
1070
 
            branch.check_real_revno(start_revision)
1071
 
            start_revno = start_revision
1072
 
            start_rev_id = branch.get_rev_id(start_revno)
1073
1091
 
1074
1092
    end_rev_id = None
1075
 
    if end_revision is None:
1076
 
        end_revno = branch_revno
1077
 
    else:
1078
 
        if isinstance(end_revision, revisionspec.RevisionInfo):
1079
 
            end_rev_id = end_revision.rev_id
1080
 
            end_revno = end_revision.revno or branch_revno
1081
 
        else:
1082
 
            branch.check_real_revno(end_revision)
1083
 
            end_revno = end_revision
1084
 
            end_rev_id = branch.get_rev_id(end_revno)
 
1093
    end_revno = None
 
1094
    if end_revision is not None:
 
1095
        if not isinstance(end_revision, revisionspec.RevisionInfo):
 
1096
            raise TypeError(start_revision)
 
1097
        end_rev_id = end_revision.rev_id
 
1098
        end_revno = end_revision.revno
 
1099
    if end_revno is None:
 
1100
        try:
 
1101
            end_revno = branch.revno()
 
1102
        except errors.GhostRevisionsHaveNoRevno:
 
1103
            end_revno = None
1085
1104
 
1086
 
    if branch_revno != 0:
 
1105
    if branch.last_revision() != _mod_revision.NULL_REVISION:
1087
1106
        if (start_rev_id == _mod_revision.NULL_REVISION
1088
1107
            or end_rev_id == _mod_revision.NULL_REVISION):
1089
1108
            raise errors.BzrCommandError(gettext('Logging revision 0 is invalid.'))
1090
 
        if start_revno > end_revno:
 
1109
        if end_revno is not None and start_revno > end_revno:
1091
1110
            raise errors.BzrCommandError(gettext("Start revision must be "
1092
1111
                                         "older than the end revision."))
1093
1112
    return (start_rev_id, end_rev_id)
1996
2015
        output.write('Added Revisions:\n')
1997
2016
        start_revno = new_revno - len(new_history) + 1
1998
2017
        show_log(branch, lf, None, verbose=False, direction='forward',
1999
 
                 start_revision=start_revno,)
 
2018
                 start_revision=start_revno)
2000
2019
 
2001
2020
 
2002
2021
def show_flat_log(repository, history, last_revno, lf):