/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-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
    diff,
67
67
    foreign,
68
68
    revision as _mod_revision,
69
 
    tsort,
70
69
    )
71
70
from breezy.i18n import gettext, ngettext
72
71
""")
213
212
 
214
213
    # Build the request and execute it
215
214
    rqst = make_log_request_dict(direction=direction, specific_fileids=file_ids,
216
 
        start_revision=start_revision, end_revision=end_revision,
217
 
        limit=limit, message_search=search,
218
 
        delta_type=delta_type, diff_type=diff_type)
 
215
                                 start_revision=start_revision, end_revision=end_revision,
 
216
                                 limit=limit, message_search=search,
 
217
                                 delta_type=delta_type, diff_type=diff_type)
219
218
    Logger(branch, rqst).show(lf)
220
219
 
221
220
 
304
303
            else:
305
304
                match['message'] = [message_search]
306
305
        else:
307
 
            match= {'message': [message_search]}
 
306
            match = {'message': [message_search]}
308
307
    return {
309
308
        'direction': direction,
310
309
        'specific_fileids': specific_fileids,
420
419
                lf.log_revision(lr)
421
420
        except errors.GhostRevisionUnusableHere:
422
421
            raise errors.BzrCommandError(
423
 
                    gettext('Further revision history missing.'))
 
422
                gettext('Further revision history missing.'))
424
423
        lf.show_advice()
425
424
 
426
425
    def _generator_factory(self, branch, rqst):
462
461
        for revs in revision_iterator:
463
462
            for (rev_id, revno, merge_depth), rev, delta in revs:
464
463
                # 0 levels means show everything; merge_depth counts from 0
465
 
                if levels != 0 and merge_depth is not None and merge_depth >= levels:
 
464
                if (levels != 0 and merge_depth is not None and
 
465
                        merge_depth >= levels):
466
466
                    continue
467
467
                if omit_merges and len(rev.parent_ids) > 1:
468
468
                    continue
476
476
                    signature = format_signature_validity(rev_id, self.branch)
477
477
                else:
478
478
                    signature = None
479
 
                yield LogRevision(rev, revno, merge_depth, delta,
 
479
                yield LogRevision(
 
480
                    rev, revno, merge_depth, delta,
480
481
                    self.rev_tag_dict.get(rev_id), diff, signature)
481
482
                if limit:
482
483
                    log_count += 1
499
500
        s = BytesIO()
500
501
        path_encoding = get_diff_header_encoding()
501
502
        diff.show_diff_trees(tree_1, tree_2, s, specific_files, old_label='',
502
 
            new_label='', path_encoding=path_encoding)
 
503
                             new_label='', path_encoding=path_encoding)
503
504
        return s.getvalue()
504
505
 
505
506
    def _create_log_revision_iterator(self):
519
520
            # not a directory
520
521
            file_count = len(self.rqst.get('specific_fileids'))
521
522
            if file_count != 1:
522
 
                raise BzrError("illegal LogRequest: must match-using-deltas "
 
523
                raise errors.BzrError(
 
524
                    "illegal LogRequest: must match-using-deltas "
523
525
                    "when logging %d files" % file_count)
524
526
            return self._log_revision_iterator_using_per_file_graph()
525
527
 
528
530
        rqst = self.rqst
529
531
        generate_merge_revisions = rqst.get('levels') != 1
530
532
        delayed_graph_generation = not rqst.get('specific_fileids') and (
531
 
                rqst.get('limit') or self.start_rev_id or self.end_rev_id)
 
533
            rqst.get('limit') or self.start_rev_id or self.end_rev_id)
532
534
        view_revisions = _calc_view_revisions(
533
535
            self.branch, self.start_rev_id, self.end_rev_id,
534
536
            rqst.get('direction'),
538
540
 
539
541
        # Apply the other filters
540
542
        return make_log_rev_iterator(self.branch, view_revisions,
541
 
            rqst.get('delta_type'), rqst.get('match'),
542
 
            file_ids=rqst.get('specific_fileids'),
543
 
            direction=rqst.get('direction'))
 
543
                                     rqst.get('delta_type'), rqst.get('match'),
 
544
                                     file_ids=rqst.get('specific_fileids'),
 
545
                                     direction=rqst.get('direction'))
544
546
 
545
547
    def _log_revision_iterator_using_per_file_graph(self):
546
548
        # Get the base revisions, filtering by the revision range.
554
556
        if not isinstance(view_revisions, list):
555
557
            view_revisions = list(view_revisions)
556
558
        view_revisions = _filter_revisions_touching_file_id(self.branch,
557
 
            rqst.get('specific_fileids')[0], view_revisions,
558
 
            include_merges=rqst.get('levels') != 1)
 
559
                                                            rqst.get('specific_fileids')[
 
560
                                                                0], view_revisions,
 
561
                                                            include_merges=rqst.get('levels') != 1)
559
562
        return make_log_rev_iterator(self.branch, view_revisions,
560
 
            rqst.get('delta_type'), rqst.get('match'))
 
563
                                     rqst.get('delta_type'), rqst.get('match'))
561
564
 
562
565
 
563
566
def _calc_view_revisions(branch, start_rev_id, end_rev_id, direction,
583
586
        and (not generate_merge_revisions
584
587
             or not _has_merges(branch, end_rev_id))):
585
588
        # If a single revision is requested, check we can handle it
586
 
        return  _generate_one_revision(branch, end_rev_id, br_rev_id,
587
 
                                       branch.revno())
 
589
        return _generate_one_revision(branch, end_rev_id, br_rev_id,
 
590
                                      branch.revno())
588
591
    if not generate_merge_revisions:
589
592
        try:
590
593
            # If we only want to see linear revisions, we can iterate ...
595
598
            # ancestor of the end limit, check it before outputting anything
596
599
            if (direction == 'forward'
597
600
                or (start_rev_id and not _is_obvious_ancestor(
598
 
                        branch, start_rev_id, end_rev_id))):
599
 
                    iter_revs = list(iter_revs)
 
601
                    branch, start_rev_id, end_rev_id))):
 
602
                iter_revs = list(iter_revs)
600
603
            if direction == 'forward':
601
604
                iter_revs = reversed(iter_revs)
602
605
            return iter_revs
634
637
    initial_revisions = []
635
638
    if delayed_graph_generation:
636
639
        try:
637
 
            for rev_id, revno, depth in  _linear_view_revisions(
638
 
                branch, start_rev_id, end_rev_id, exclude_common_ancestry):
 
640
            for rev_id, revno, depth in _linear_view_revisions(
 
641
                    branch, start_rev_id, end_rev_id, exclude_common_ancestry):
639
642
                if _has_merges(branch, rev_id):
640
643
                    # The end_rev_id can be nested down somewhere. We need an
641
644
                    # explicit ancestry check. There is an ambiguity here as we
648
651
                    # -- vila 20100319
649
652
                    graph = branch.repository.get_graph()
650
653
                    if (start_rev_id is not None
651
 
                        and not graph.is_ancestor(start_rev_id, end_rev_id)):
 
654
                            and not graph.is_ancestor(start_rev_id, end_rev_id)):
652
655
                        raise _StartNotLinearAncestor()
653
656
                    # Since we collected the revisions so far, we need to
654
657
                    # adjust end_rev_id.
663
666
            # A merge was never detected so the lower revision limit can't
664
667
            # be nested down somewhere
665
668
            raise errors.BzrCommandError(gettext('Start revision not found in'
666
 
                ' history of end revision.'))
 
669
                                                 ' history of end revision.'))
667
670
 
668
671
    # We exit the loop above because we encounter a revision with merges, from
669
672
    # this revision, we need to switch to _graph_view_revisions.
674
677
    # make forward the exact opposite display, but showing the merge revisions
675
678
    # indented at the end seems slightly nicer in that case.
676
679
    view_revisions = itertools.chain(iter(initial_revisions),
677
 
        _graph_view_revisions(branch, start_rev_id, end_rev_id,
678
 
                              rebase_initial_depths=(direction == 'reverse'),
679
 
                              exclude_common_ancestry=exclude_common_ancestry))
 
680
                                     _graph_view_revisions(branch, start_rev_id, end_rev_id,
 
681
                                                           rebase_initial_depths=(
 
682
                                                               direction == 'reverse'),
 
683
                                                           exclude_common_ancestry=exclude_common_ancestry))
680
684
    return view_revisions
681
685
 
682
686
 
714
718
            # both on mainline
715
719
            return start_dotted[0] <= end_dotted[0]
716
720
        elif (len(start_dotted) == 3 and len(end_dotted) == 3 and
717
 
            start_dotted[0:1] == end_dotted[0:1]):
 
721
              start_dotted[0:1] == end_dotted[0:1]):
718
722
            # both on same development line
719
723
            return start_dotted[2] <= end_dotted[2]
720
724
        else:
749
753
        else:
750
754
            cur_revno = br_revno
751
755
        graph_iter = graph.iter_lefthand_ancestry(br_rev_id,
752
 
            (_mod_revision.NULL_REVISION,))
 
756
                                                  (_mod_revision.NULL_REVISION,))
753
757
        while True:
754
758
            try:
755
759
                revision_id = next(graph_iter)
769
773
            end_rev_id = br_rev_id
770
774
        found_start = start_rev_id is None
771
775
        graph_iter = graph.iter_lefthand_ancestry(end_rev_id,
772
 
            (_mod_revision.NULL_REVISION,))
 
776
                                                  (_mod_revision.NULL_REVISION,))
773
777
        while True:
774
778
            try:
775
779
                revision_id = next(graph_iter)
842
846
    if view_revisions and view_revisions[0][2] and view_revisions[-1][2]:
843
847
        min_depth = min([d for r, n, d in view_revisions])
844
848
        if min_depth != 0:
845
 
            view_revisions = [(r, n, d-min_depth) for r, n, d in view_revisions]
 
849
            view_revisions = [(r, n, d - min_depth)
 
850
                              for r, n, d in view_revisions]
846
851
    return view_revisions
847
852
 
848
853
 
849
854
def make_log_rev_iterator(branch, view_revisions, generate_delta, search,
850
 
        file_ids=None, direction='reverse'):
 
855
                          file_ids=None, direction='reverse'):
851
856
    """Create a revision iterator for log.
852
857
 
853
858
    :param branch: The branch being logged.
877
882
        # It would be nicer if log adapters were first class objects
878
883
        # with custom parameters. This will do for now. IGC 20090127
879
884
        if adapter == _make_delta_filter:
880
 
            log_rev_iterator = adapter(branch, generate_delta,
881
 
                search, log_rev_iterator, file_ids, direction)
 
885
            log_rev_iterator = adapter(
 
886
                branch, generate_delta, search, log_rev_iterator, file_ids,
 
887
                direction)
882
888
        else:
883
 
            log_rev_iterator = adapter(branch, generate_delta,
884
 
                search, log_rev_iterator)
 
889
            log_rev_iterator = adapter(
 
890
                branch, generate_delta, search, log_rev_iterator)
885
891
    return log_rev_iterator
886
892
 
887
893
 
912
918
        if new_revs:
913
919
            yield new_revs
914
920
 
 
921
 
915
922
def _match_filter(searchRE, rev):
916
923
    strings = {
917
 
               'message': (rev.message,),
918
 
               'committer': (rev.committer,),
919
 
               'author': (rev.get_apparent_authors()),
920
 
               'bugs': list(rev.iter_bugs())
921
 
               }
 
924
        'message': (rev.message,),
 
925
        'committer': (rev.committer,),
 
926
        'author': (rev.get_apparent_authors()),
 
927
        'bugs': list(rev.iter_bugs())
 
928
        }
922
929
    strings[''] = [item for inner_list in strings.values()
923
930
                   for item in inner_list]
924
931
    for (k, v) in searchRE:
926
933
            return False
927
934
    return True
928
935
 
 
936
 
929
937
def _match_any_filter(strings, res):
930
938
    return any(re.search(s) for re in res for s in strings)
931
939
 
 
940
 
932
941
def _make_delta_filter(branch, generate_delta, search, log_rev_iterator,
933
 
    fileids=None, direction='reverse'):
 
942
                       fileids=None, direction='reverse'):
934
943
    """Add revision deltas to a log iterator if needed.
935
944
 
936
945
    :param branch: The branch being logged.
948
957
    if not generate_delta and not fileids:
949
958
        return log_rev_iterator
950
959
    return _generate_deltas(branch.repository, log_rev_iterator,
951
 
        generate_delta, fileids, direction)
 
960
                            generate_delta, fileids, direction)
952
961
 
953
962
 
954
963
def _generate_deltas(repository, log_rev_iterator, delta_type, fileids,
955
 
    direction):
 
964
                     direction):
956
965
    """Create deltas for each batch of revisions in log_rev_iterator.
957
966
 
958
967
    If we're only generating deltas for the sake of filtering against
1101
1110
 
1102
1111
    if branch.last_revision() != _mod_revision.NULL_REVISION:
1103
1112
        if (start_rev_id == _mod_revision.NULL_REVISION
1104
 
            or end_rev_id == _mod_revision.NULL_REVISION):
1105
 
            raise errors.BzrCommandError(gettext('Logging revision 0 is invalid.'))
 
1113
                or end_rev_id == _mod_revision.NULL_REVISION):
 
1114
            raise errors.BzrCommandError(
 
1115
                gettext('Logging revision 0 is invalid.'))
1106
1116
        if end_revno is not None and start_revno > end_revno:
1107
 
            raise errors.BzrCommandError(gettext("Start revision must be "
1108
 
                                         "older than the end revision."))
 
1117
            raise errors.BzrCommandError(
 
1118
                gettext("Start revision must be older than the end revision."))
1109
1119
    return (start_rev_id, end_rev_id)
1110
1120
 
1111
1121
 
1159
1169
            end_revno = end_revision
1160
1170
 
1161
1171
    if ((start_rev_id == _mod_revision.NULL_REVISION)
1162
 
        or (end_rev_id == _mod_revision.NULL_REVISION)):
 
1172
            or (end_rev_id == _mod_revision.NULL_REVISION)):
1163
1173
        raise errors.BzrCommandError(gettext('Logging revision 0 is invalid.'))
1164
1174
    if start_revno > end_revno:
1165
1175
        raise errors.BzrCommandError(gettext("Start revision must be older "
1166
 
                                     "than the end revision."))
 
1176
                                             "than the end revision."))
1167
1177
 
1168
1178
    if end_revno < start_revno:
1169
1179
        return None, None, None, None
1193
1203
 
1194
1204
 
1195
1205
def _filter_revisions_touching_file_id(branch, file_id, view_revisions,
1196
 
    include_merges=True):
 
1206
                                       include_merges=True):
1197
1207
    r"""Return the list of revision ids which touch a given file id.
1198
1208
 
1199
1209
    The function filters view_revisions and returns a subset.
1280
1290
    """Reverse revisions by depth.
1281
1291
 
1282
1292
    Revisions with a different depth are sorted as a group with the previous
1283
 
    revision of that depth.  There may be no topological justification for this,
 
1293
    revision of that depth.  There may be no topological justification for this
1284
1294
    but it looks much nicer.
1285
1295
    """
1286
1296
    # Add a fake revision at start so that we can always attach sub revisions
1393
1403
        """
1394
1404
        self.to_file = to_file
1395
1405
        # 'exact' stream used to show diff, it should print content 'as is'
1396
 
        # and should not try to decode/encode it to unicode to avoid bug #328007
 
1406
        # and should not try to decode/encode it to unicode to avoid bug
 
1407
        # #328007
1397
1408
        if to_exact_file is not None:
1398
1409
            self.to_exact_file = to_exact_file
1399
1410
        else:
1400
 
            # XXX: somewhat hacky; this assumes it's a codec writer; it's better
1401
 
            # for code that expects to get diffs to pass in the exact file
1402
 
            # stream
 
1411
            # XXX: somewhat hacky; this assumes it's a codec writer; it's
 
1412
            # better for code that expects to get diffs to pass in the exact
 
1413
            # file stream
1403
1414
            self.to_exact_file = getattr(to_file, 'stream', to_file)
1404
1415
        self.show_ids = show_ids
1405
1416
        self.show_timezone = show_timezone
1406
1417
        if delta_format is None:
1407
1418
            # Ensures backward compatibility
1408
 
            delta_format = 2 # long format
 
1419
            delta_format = 2  # long format
1409
1420
        self.delta_format = delta_format
1410
1421
        self.levels = levels
1411
1422
        self._show_advice = show_advice
1523
1534
                rev.mapping.vcs.show_foreign_revid(rev.foreign_revid))
1524
1535
 
1525
1536
        # Imported foreign revision revision ids always contain :
1526
 
        if not b":" in rev.revision_id:
 
1537
        if b":" not in rev.revision_id:
1527
1538
            return []
1528
1539
 
1529
1540
        # Revision was once imported from a foreign repository
1574
1585
 
1575
1586
    def _date_string_original_timezone(self, rev):
1576
1587
        return format_date_with_offset_in_original_timezone(rev.timestamp,
1577
 
            rev.timezone or 0)
 
1588
                                                            rev.timezone or 0)
1578
1589
 
1579
1590
    def log_revision(self, revision):
1580
1591
        """Log a revision, either merged or not."""
1582
1593
        lines = [_LONG_SEP]
1583
1594
        if revision.revno is not None:
1584
1595
            lines.append('revno: %s%s' % (revision.revno,
1585
 
                self.merge_marker(revision)))
 
1596
                                          self.merge_marker(revision)))
1586
1597
        if revision.tags:
1587
1598
            lines.append('tags: %s' % (', '.join(sorted(revision.tags))))
1588
1599
        if self.show_ids or revision.revno is None:
1589
 
            lines.append('revision-id: %s' % (revision.rev.revision_id.decode('utf-8'),))
 
1600
            lines.append('revision-id: %s' %
 
1601
                         (revision.rev.revision_id.decode('utf-8'),))
1590
1602
        if self.show_ids:
1591
1603
            for parent_id in revision.rev.parent_ids:
1592
1604
                lines.append('parent: %s' % (parent_id.decode('utf-8'),))
1673
1685
        if revision.tags:
1674
1686
            tags = ' {%s}' % (', '.join(sorted(revision.tags)))
1675
1687
        to_file.write(indent + "%*s %s\t%s%s%s\n" % (revno_width,
1676
 
                revision.revno or "", self.short_author(revision.rev),
1677
 
                format_date(revision.rev.timestamp,
1678
 
                            revision.rev.timezone or 0,
1679
 
                            self.show_timezone, date_fmt="%Y-%m-%d",
1680
 
                            show_offset=False),
1681
 
                tags, self.merge_marker(revision)))
1682
 
        self.show_properties(revision.rev, indent+offset)
 
1688
                                                     revision.revno or "", self.short_author(
 
1689
                                                         revision.rev),
 
1690
                                                     format_date(revision.rev.timestamp,
 
1691
                                                                 revision.rev.timezone or 0,
 
1692
                                                                 self.show_timezone, date_fmt="%Y-%m-%d",
 
1693
                                                                 show_offset=False),
 
1694
                                                     tags, self.merge_marker(revision)))
 
1695
        self.show_properties(revision.rev, indent + offset)
1683
1696
        if self.show_ids or revision.revno is None:
1684
1697
            to_file.write(indent + offset + 'revision-id:%s\n'
1685
1698
                          % (revision.rev.revision_id.decode('utf-8'),))
1694
1707
            # Use the standard status output to display changes
1695
1708
            from breezy.delta import report_delta
1696
1709
            report_delta(to_file, revision.delta,
1697
 
                         short_status=self.delta_format==1,
 
1710
                         short_status=self.delta_format == 1,
1698
1711
                         show_ids=self.show_ids, indent=indent + offset)
1699
1712
        if revision.diff is not None:
1700
1713
            self.show_diff(self.to_exact_file, revision.diff, '      ')
1718
1731
    def truncate(self, str, max_len):
1719
1732
        if max_len is None or len(str) <= max_len:
1720
1733
            return str
1721
 
        return str[:max_len-3] + '...'
 
1734
        return str[:max_len - 3] + '...'
1722
1735
 
1723
1736
    def date_string(self, rev):
1724
1737
        return format_date(rev.timestamp, rev.timezone or 0,
1734
1747
    def log_revision(self, revision):
1735
1748
        indent = '  ' * revision.merge_depth
1736
1749
        self.to_file.write(self.log_string(revision.revno, revision.rev,
1737
 
            self._max_chars, revision.tags, indent))
 
1750
                                           self._max_chars, revision.tags, indent))
1738
1751
        self.to_file.write('\n')
1739
1752
 
1740
1753
    def log_string(self, revno, rev, max_chars, tags=None, prefix=''):
1753
1766
            # show revno only when is not None
1754
1767
            out.append("%s:" % revno)
1755
1768
        if max_chars is not None:
1756
 
            out.append(self.truncate(self.short_author(rev), (max_chars+3)//4))
 
1769
            out.append(self.truncate(
 
1770
                self.short_author(rev), (max_chars + 3) // 4))
1757
1771
        else:
1758
1772
            out.append(self.short_author(rev))
1759
1773
        out.append(self.date_string(rev))
1850
1864
    try:
1851
1865
        return log_formatter_registry.make_formatter(name, *args, **kwargs)
1852
1866
    except KeyError:
1853
 
        raise errors.BzrCommandError(gettext("unknown log formatter: %r") % name)
 
1867
        raise errors.BzrCommandError(
 
1868
            gettext("unknown log formatter: %r") % name)
1854
1869
 
1855
1870
 
1856
1871
def author_list_all(rev):
1892
1907
    """
1893
1908
    if to_file is None:
1894
1909
        to_file = codecs.getwriter(get_terminal_encoding())(sys.stdout,
1895
 
            errors='replace')
 
1910
                                                            errors='replace')
1896
1911
    lf = log_formatter(log_format,
1897
1912
                       show_ids=False,
1898
1913
                       to_file=to_file,
1904
1919
    for i in range(max(len(new_rh), len(old_rh))):
1905
1920
        if (len(new_rh) <= i
1906
1921
            or len(old_rh) <= i
1907
 
            or new_rh[i] != old_rh[i]):
 
1922
                or new_rh[i] != old_rh[i]):
1908
1923
            base_idx = i
1909
1924
            break
1910
1925
 
1911
1926
    if base_idx is None:
1912
1927
        to_file.write('Nothing seems to have changed\n')
1913
1928
        return
1914
 
    ## TODO: It might be nice to do something like show_log
1915
 
    ##       and show the merged entries. But since this is the
1916
 
    ##       removed revisions, it shouldn't be as important
 
1929
    # TODO: It might be nice to do something like show_log
 
1930
    # and show the merged entries. But since this is the
 
1931
    # removed revisions, it shouldn't be as important
1917
1932
    if base_idx < len(old_rh):
1918
 
        to_file.write('*'*60)
 
1933
        to_file.write('*' * 60)
1919
1934
        to_file.write('\nRemoved Revisions:\n')
1920
1935
        for i in range(base_idx, len(old_rh)):
1921
1936
            rev = branch.repository.get_revision(old_rh[i])
1922
 
            lr = LogRevision(rev, i+1, 0, None)
 
1937
            lr = LogRevision(rev, i + 1, 0, None)
1923
1938
            lf.log_revision(lr)
1924
 
        to_file.write('*'*60)
 
1939
        to_file.write('*' * 60)
1925
1940
        to_file.write('\n\n')
1926
1941
    if base_idx < len(new_rh):
1927
1942
        to_file.write('Added Revisions:\n')
1930
1945
                 None,
1931
1946
                 verbose=False,
1932
1947
                 direction='forward',
1933
 
                 start_revision=base_idx+1,
 
1948
                 start_revision=base_idx + 1,
1934
1949
                 end_revision=len(new_rh),
1935
1950
                 search=None)
1936
1951
 
2004
2019
    log_format = log_formatter_registry.get_default(branch)
2005
2020
    lf = log_format(show_ids=False, to_file=output, show_timezone='original')
2006
2021
    if old_history != []:
2007
 
        output.write('*'*60)
 
2022
        output.write('*' * 60)
2008
2023
        output.write('\nRemoved Revisions:\n')
2009
2024
        show_flat_log(branch.repository, old_history, old_revno, lf)
2010
 
        output.write('*'*60)
 
2025
        output.write('*' * 60)
2011
2026
        output.write('\n\n')
2012
2027
    if new_history != []:
2013
2028
        output.write('Added Revisions:\n')
2024
2039
    :param last_revno: The revno of the last revision_id in the history.
2025
2040
    :param lf: The log formatter to use.
2026
2041
    """
2027
 
    start_revno = last_revno - len(history) + 1
2028
2042
    revisions = repository.get_revisions(history)
2029
2043
    for i, rev in enumerate(revisions):
2030
2044
        lr = LogRevision(rev, i + last_revno, 0, None)
2066
2080
        relpaths = [path] + file_list[1:]
2067
2081
    info_list = []
2068
2082
    start_rev_info, end_rev_info = _get_revision_range(revisionspec_list, b,
2069
 
        "log")
 
2083
                                                       "log")
2070
2084
    if relpaths in ([], [u'']):
2071
2085
        return b, [], start_rev_info, end_rev_info
2072
2086
    if start_rev_info is None and end_rev_info is None:
2137
2151
properties_handler_registry = registry.Registry()
2138
2152
 
2139
2153
# Use the properties handlers to print out bug information if available
 
2154
 
 
2155
 
2140
2156
def _bugs_properties_handler(revision):
2141
2157
    ret = {}
2142
2158
    if 'bugs' in revision.properties:
2147
2163
        related_bug_urls = [row[0] for row in bug_rows if
2148
2164
                            len(row) > 1 and row[1] == 'related']
2149
2165
        if fixed_bug_urls:
2150
 
            ret[ngettext('fixes bug', 'fixes bugs', len(fixed_bug_urls))] = (
2151
 
                ' '.join(fixed_bug_urls))
 
2166
            text = ngettext('fixes bug', 'fixes bugs', len(fixed_bug_urls))
 
2167
            ret[text] = ' '.join(fixed_bug_urls)
2152
2168
        if related_bug_urls:
2153
 
            ret[ngettext('related bug', 'related bugs', len(related_bug_urls))] = (
2154
 
                ' '.join(related_bug_urls))
 
2169
            text = ngettext('related bug', 'related bugs',
 
2170
                            len(related_bug_urls))
 
2171
            ret[text] = ' '.join(related_bug_urls)
2155
2172
    return ret
2156
2173
 
 
2174
 
2157
2175
properties_handler_registry.register('bugs_properties_handler',
2158
2176
                                     _bugs_properties_handler)
2159
2177