/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 bzrlib/log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-12-18 10:09:49 UTC
  • mfrom: (4871.5.4 admin-guide-submit)
  • Revision ID: pqm@pqm.ubuntu.com-20091218100949-2c1ityvnbqjtdf3g
(nmb) Add backup section to admin-guide

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2009 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,
86
85
    format_date,
87
86
    format_date_with_offset_in_original_timezone,
88
87
    get_terminal_encoding,
 
88
    re_compile_checked,
89
89
    terminal_width,
90
90
    )
91
 
from bzrlib.symbol_versioning import (
92
 
    deprecated_function,
93
 
    deprecated_in,
94
 
    )
95
91
 
96
92
 
97
93
def find_touching_revisions(branch, file_id):
109
105
    last_path = None
110
106
    revno = 1
111
107
    for revision_id in branch.revision_history():
112
 
        this_inv = branch.repository.get_inventory(revision_id)
 
108
        this_inv = branch.repository.get_revision_inventory(revision_id)
113
109
        if file_id in this_inv:
114
110
            this_ie = this_inv[file_id]
115
111
            this_path = this_inv.id2path(file_id)
220
216
    'direction': 'reverse',
221
217
    'levels': 1,
222
218
    'generate_tags': True,
223
 
    'exclude_common_ancestry': False,
224
219
    '_match_using_deltas': True,
225
220
    }
226
221
 
227
222
 
228
223
def make_log_request_dict(direction='reverse', specific_fileids=None,
229
 
                          start_revision=None, end_revision=None, limit=None,
230
 
                          message_search=None, levels=1, generate_tags=True,
231
 
                          delta_type=None,
232
 
                          diff_type=None, _match_using_deltas=True,
233
 
                          exclude_common_ancestry=False,
234
 
                          ):
 
224
    start_revision=None, end_revision=None, limit=None,
 
225
    message_search=None, levels=1, generate_tags=True, delta_type=None,
 
226
    diff_type=None, _match_using_deltas=True):
235
227
    """Convenience function for making a logging request dictionary.
236
228
 
237
229
    Using this function may make code slightly safer by ensuring
275
267
      algorithm used for matching specific_fileids. This parameter
276
268
      may be removed in the future so bzrlib client code should NOT
277
269
      use it.
278
 
 
279
 
    :param exclude_common_ancestry: Whether -rX..Y should be interpreted as a
280
 
      range operator or as a graph difference.
281
270
    """
282
271
    return {
283
272
        'direction': direction,
290
279
        'generate_tags': generate_tags,
291
280
        'delta_type': delta_type,
292
281
        'diff_type': diff_type,
293
 
        'exclude_common_ancestry': exclude_common_ancestry,
294
282
        # Add 'private' attributes for features that may be deprecated
295
283
        '_match_using_deltas': _match_using_deltas,
296
284
    }
316
304
 
317
305
 
318
306
class Logger(object):
319
 
    """An object that generates, formats and displays a log."""
 
307
    """An object the generates, formats and displays a log."""
320
308
 
321
309
    def __init__(self, branch, rqst):
322
310
        """Create a Logger.
432
420
        else:
433
421
            specific_files = None
434
422
        s = StringIO()
435
 
        path_encoding = osutils.get_diff_header_encoding()
436
423
        diff.show_diff_trees(tree_1, tree_2, s, specific_files, old_label='',
437
 
            new_label='', path_encoding=path_encoding)
 
424
            new_label='')
438
425
        return s.getvalue()
439
426
 
440
427
    def _create_log_revision_iterator(self):
464
451
        generate_merge_revisions = rqst.get('levels') != 1
465
452
        delayed_graph_generation = not rqst.get('specific_fileids') and (
466
453
                rqst.get('limit') or self.start_rev_id or self.end_rev_id)
467
 
        view_revisions = _calc_view_revisions(
468
 
            self.branch, self.start_rev_id, self.end_rev_id,
469
 
            rqst.get('direction'),
470
 
            generate_merge_revisions=generate_merge_revisions,
471
 
            delayed_graph_generation=delayed_graph_generation,
472
 
            exclude_common_ancestry=rqst.get('exclude_common_ancestry'))
 
454
        view_revisions = _calc_view_revisions(self.branch, self.start_rev_id,
 
455
            self.end_rev_id, rqst.get('direction'), generate_merge_revisions,
 
456
            delayed_graph_generation=delayed_graph_generation)
473
457
 
474
458
        # Apply the other filters
475
459
        return make_log_rev_iterator(self.branch, view_revisions,
482
466
        # Note that we always generate the merge revisions because
483
467
        # filter_revisions_touching_file_id() requires them ...
484
468
        rqst = self.rqst
485
 
        view_revisions = _calc_view_revisions(
486
 
            self.branch, self.start_rev_id, self.end_rev_id,
487
 
            rqst.get('direction'), generate_merge_revisions=True,
488
 
            exclude_common_ancestry=rqst.get('exclude_common_ancestry'))
 
469
        view_revisions = _calc_view_revisions(self.branch, self.start_rev_id,
 
470
            self.end_rev_id, rqst.get('direction'), True)
489
471
        if not isinstance(view_revisions, list):
490
472
            view_revisions = list(view_revisions)
491
473
        view_revisions = _filter_revisions_touching_file_id(self.branch,
496
478
 
497
479
 
498
480
def _calc_view_revisions(branch, start_rev_id, end_rev_id, direction,
499
 
                         generate_merge_revisions,
500
 
                         delayed_graph_generation=False,
501
 
                         exclude_common_ancestry=False,
502
 
                         ):
 
481
    generate_merge_revisions, delayed_graph_generation=False):
503
482
    """Calculate the revisions to view.
504
483
 
505
484
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples OR
506
485
             a list of the same tuples.
507
486
    """
508
 
    if (exclude_common_ancestry and start_rev_id == end_rev_id):
509
 
        raise errors.BzrCommandError(
510
 
            '--exclude-common-ancestry requires two different revisions')
511
 
    if direction not in ('reverse', 'forward'):
512
 
        raise ValueError('invalid direction %r' % direction)
513
487
    br_revno, br_rev_id = branch.last_revision_info()
514
488
    if br_revno == 0:
515
489
        return []
516
490
 
517
 
    if (end_rev_id and start_rev_id == end_rev_id
518
 
        and (not generate_merge_revisions
519
 
             or not _has_merges(branch, end_rev_id))):
520
 
        # If a single revision is requested, check we can handle it
521
 
        iter_revs = _generate_one_revision(branch, end_rev_id, br_rev_id,
522
 
                                           br_revno)
523
 
    elif not generate_merge_revisions:
524
 
        # If we only want to see linear revisions, we can iterate ...
525
 
        iter_revs = _generate_flat_revisions(branch, start_rev_id, end_rev_id,
526
 
                                             direction, exclude_common_ancestry)
527
 
        if direction == 'forward':
528
 
            iter_revs = reversed(iter_revs)
 
491
    # If a single revision is requested, check we can handle it
 
492
    generate_single_revision = (end_rev_id and start_rev_id == end_rev_id and
 
493
        (not generate_merge_revisions or not _has_merges(branch, end_rev_id)))
 
494
    if generate_single_revision:
 
495
        return _generate_one_revision(branch, end_rev_id, br_rev_id, br_revno)
 
496
 
 
497
    # If we only want to see linear revisions, we can iterate ...
 
498
    if not generate_merge_revisions:
 
499
        return _generate_flat_revisions(branch, start_rev_id, end_rev_id,
 
500
            direction)
529
501
    else:
530
 
        iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
531
 
                                            direction, delayed_graph_generation,
532
 
                                            exclude_common_ancestry)
533
 
        if direction == 'forward':
534
 
            iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
535
 
    return iter_revs
 
502
        return _generate_all_revisions(branch, start_rev_id, end_rev_id,
 
503
            direction, delayed_graph_generation)
536
504
 
537
505
 
538
506
def _generate_one_revision(branch, rev_id, br_rev_id, br_revno):
545
513
        return [(rev_id, revno_str, 0)]
546
514
 
547
515
 
548
 
def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction,
549
 
                             exclude_common_ancestry=False):
550
 
    result = _linear_view_revisions(
551
 
        branch, start_rev_id, end_rev_id,
552
 
        exclude_common_ancestry=exclude_common_ancestry)
 
516
def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction):
 
517
    result = _linear_view_revisions(branch, start_rev_id, end_rev_id)
553
518
    # If a start limit was given and it's not obviously an
554
519
    # ancestor of the end limit, check it before outputting anything
555
520
    if direction == 'forward' or (start_rev_id
559
524
        except _StartNotLinearAncestor:
560
525
            raise errors.BzrCommandError('Start revision not found in'
561
526
                ' left-hand history of end revision.')
 
527
    if direction == 'forward':
 
528
        result = reversed(result)
562
529
    return result
563
530
 
564
531
 
565
532
def _generate_all_revisions(branch, start_rev_id, end_rev_id, direction,
566
 
                            delayed_graph_generation,
567
 
                            exclude_common_ancestry=False):
 
533
    delayed_graph_generation):
568
534
    # On large trees, generating the merge graph can take 30-60 seconds
569
535
    # so we delay doing it until a merge is detected, incrementally
570
536
    # returning initial (non-merge) revisions while we can.
571
 
 
572
 
    # The above is only true for old formats (<= 0.92), for newer formats, a
573
 
    # couple of seconds only should be needed to load the whole graph and the
574
 
    # other graph operations needed are even faster than that -- vila 100201
575
537
    initial_revisions = []
576
538
    if delayed_graph_generation:
577
539
        try:
578
 
            for rev_id, revno, depth in  _linear_view_revisions(
579
 
                branch, start_rev_id, end_rev_id, exclude_common_ancestry):
 
540
            for rev_id, revno, depth in \
 
541
                _linear_view_revisions(branch, start_rev_id, end_rev_id):
580
542
                if _has_merges(branch, rev_id):
581
 
                    # The end_rev_id can be nested down somewhere. We need an
582
 
                    # explicit ancestry check. There is an ambiguity here as we
583
 
                    # may not raise _StartNotLinearAncestor for a revision that
584
 
                    # is an ancestor but not a *linear* one. But since we have
585
 
                    # loaded the graph to do the check (or calculate a dotted
586
 
                    # revno), we may as well accept to show the log...  We need
587
 
                    # the check only if start_rev_id is not None as all
588
 
                    # revisions have _mod_revision.NULL_REVISION as an ancestor
589
 
                    # -- vila 20100319
590
 
                    graph = branch.repository.get_graph()
591
 
                    if (start_rev_id is not None
592
 
                        and not graph.is_ancestor(start_rev_id, end_rev_id)):
593
 
                        raise _StartNotLinearAncestor()
594
 
                    # Since we collected the revisions so far, we need to
595
 
                    # adjust end_rev_id.
596
543
                    end_rev_id = rev_id
597
544
                    break
598
545
                else:
599
546
                    initial_revisions.append((rev_id, revno, depth))
600
547
            else:
601
548
                # No merged revisions found
602
 
                return initial_revisions
 
549
                if direction == 'reverse':
 
550
                    return initial_revisions
 
551
                elif direction == 'forward':
 
552
                    return reversed(initial_revisions)
 
553
                else:
 
554
                    raise ValueError('invalid direction %r' % direction)
603
555
        except _StartNotLinearAncestor:
604
556
            # A merge was never detected so the lower revision limit can't
605
557
            # be nested down somewhere
606
558
            raise errors.BzrCommandError('Start revision not found in'
607
559
                ' history of end revision.')
608
560
 
609
 
    # We exit the loop above because we encounter a revision with merges, from
610
 
    # this revision, we need to switch to _graph_view_revisions.
611
 
 
612
561
    # A log including nested merges is required. If the direction is reverse,
613
562
    # we rebase the initial merge depths so that the development line is
614
563
    # shown naturally, i.e. just like it is for linear logging. We can easily
616
565
    # indented at the end seems slightly nicer in that case.
617
566
    view_revisions = chain(iter(initial_revisions),
618
567
        _graph_view_revisions(branch, start_rev_id, end_rev_id,
619
 
                              rebase_initial_depths=(direction == 'reverse'),
620
 
                              exclude_common_ancestry=exclude_common_ancestry))
621
 
    return view_revisions
 
568
        rebase_initial_depths=direction == 'reverse'))
 
569
    if direction == 'reverse':
 
570
        return view_revisions
 
571
    elif direction == 'forward':
 
572
        # Forward means oldest first, adjusting for depth.
 
573
        view_revisions = reverse_by_depth(list(view_revisions))
 
574
        return _rebase_merge_depth(view_revisions)
 
575
    else:
 
576
        raise ValueError('invalid direction %r' % direction)
622
577
 
623
578
 
624
579
def _has_merges(branch, rev_id):
642
597
        else:
643
598
            # not obvious
644
599
            return False
645
 
    # if either start or end is not specified then we use either the first or
646
 
    # the last revision and *they* are obvious ancestors.
647
600
    return True
648
601
 
649
602
 
650
 
def _linear_view_revisions(branch, start_rev_id, end_rev_id,
651
 
                           exclude_common_ancestry=False):
 
603
def _linear_view_revisions(branch, start_rev_id, end_rev_id):
652
604
    """Calculate a sequence of revisions to view, newest to oldest.
653
605
 
654
606
    :param start_rev_id: the lower revision-id
655
607
    :param end_rev_id: the upper revision-id
656
 
    :param exclude_common_ancestry: Whether the start_rev_id should be part of
657
 
        the iterated revisions.
658
608
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples.
659
609
    :raises _StartNotLinearAncestor: if a start_rev_id is specified but
660
 
        is not found walking the left-hand history
 
610
      is not found walking the left-hand history
661
611
    """
662
612
    br_revno, br_rev_id = branch.last_revision_info()
663
613
    repo = branch.repository
674
624
            revno = branch.revision_id_to_dotted_revno(revision_id)
675
625
            revno_str = '.'.join(str(n) for n in revno)
676
626
            if not found_start and revision_id == start_rev_id:
677
 
                if not exclude_common_ancestry:
678
 
                    yield revision_id, revno_str, 0
 
627
                yield revision_id, revno_str, 0
679
628
                found_start = True
680
629
                break
681
630
            else:
686
635
 
687
636
 
688
637
def _graph_view_revisions(branch, start_rev_id, end_rev_id,
689
 
                          rebase_initial_depths=True,
690
 
                          exclude_common_ancestry=False):
 
638
    rebase_initial_depths=True):
691
639
    """Calculate revisions to view including merges, newest to oldest.
692
640
 
693
641
    :param branch: the branch
697
645
      revision is found?
698
646
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples.
699
647
    """
700
 
    if exclude_common_ancestry:
701
 
        stop_rule = 'with-merges-without-common-ancestry'
702
 
    else:
703
 
        stop_rule = 'with-merges'
704
648
    view_revisions = branch.iter_merge_sorted_revisions(
705
649
        start_revision_id=end_rev_id, stop_revision_id=start_rev_id,
706
 
        stop_rule=stop_rule)
 
650
        stop_rule="with-merges")
707
651
    if not rebase_initial_depths:
708
652
        for (rev_id, merge_depth, revno, end_of_merge
709
653
             ) in view_revisions:
720
664
                depth_adjustment = merge_depth
721
665
            if depth_adjustment:
722
666
                if merge_depth < depth_adjustment:
723
 
                    # From now on we reduce the depth adjustement, this can be
724
 
                    # surprising for users. The alternative requires two passes
725
 
                    # which breaks the fast display of the first revision
726
 
                    # though.
727
667
                    depth_adjustment = merge_depth
728
668
                merge_depth -= depth_adjustment
729
669
            yield rev_id, '.'.join(map(str, revno)), merge_depth
730
670
 
731
671
 
732
 
@deprecated_function(deprecated_in((2, 2, 0)))
733
672
def calculate_view_revisions(branch, start_revision, end_revision, direction,
734
673
        specific_fileid, generate_merge_revisions):
735
674
    """Calculate the revisions to view.
737
676
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples OR
738
677
             a list of the same tuples.
739
678
    """
 
679
    # This method is no longer called by the main code path.
 
680
    # It is retained for API compatibility and may be deprecated
 
681
    # soon. IGC 20090116
740
682
    start_rev_id, end_rev_id = _get_revision_limits(branch, start_revision,
741
683
        end_revision)
742
684
    view_revisions = list(_calc_view_revisions(branch, start_rev_id, end_rev_id,
810
752
    """
811
753
    if search is None:
812
754
        return log_rev_iterator
813
 
    searchRE = re.compile(search, re.IGNORECASE)
 
755
    searchRE = re_compile_checked(search, re.IGNORECASE,
 
756
            'log message filter')
814
757
    return _filter_message_re(searchRE, log_rev_iterator)
815
758
 
816
759
 
1091
1034
    return mainline_revs, rev_nos, start_rev_id, end_rev_id
1092
1035
 
1093
1036
 
1094
 
@deprecated_function(deprecated_in((2, 2, 0)))
1095
1037
def _filter_revision_range(view_revisions, start_rev_id, end_rev_id):
1096
1038
    """Filter view_revisions based on revision ranges.
1097
1039
 
1106
1048
 
1107
1049
    :return: The filtered view_revisions.
1108
1050
    """
 
1051
    # This method is no longer called by the main code path.
 
1052
    # It may be removed soon. IGC 20090127
1109
1053
    if start_rev_id or end_rev_id:
1110
1054
        revision_ids = [r for r, n, d in view_revisions]
1111
1055
        if start_rev_id:
1217
1161
    return result
1218
1162
 
1219
1163
 
1220
 
@deprecated_function(deprecated_in((2, 2, 0)))
1221
1164
def get_view_revisions(mainline_revs, rev_nos, branch, direction,
1222
1165
                       include_merges=True):
1223
1166
    """Produce an iterator of revisions to show
1224
1167
    :return: an iterator of (revision_id, revno, merge_depth)
1225
1168
    (if there is no revno for a revision, None is supplied)
1226
1169
    """
 
1170
    # This method is no longer called by the main code path.
 
1171
    # It is retained for API compatibility and may be deprecated
 
1172
    # soon. IGC 20090127
1227
1173
    if not include_merges:
1228
1174
        revision_ids = mainline_revs[1:]
1229
1175
        if direction == 'reverse':
1347
1293
    preferred_levels = 0
1348
1294
 
1349
1295
    def __init__(self, to_file, show_ids=False, show_timezone='original',
1350
 
                 delta_format=None, levels=None, show_advice=False,
1351
 
                 to_exact_file=None, author_list_handler=None):
 
1296
            delta_format=None, levels=None, show_advice=False,
 
1297
            to_exact_file=None):
1352
1298
        """Create a LogFormatter.
1353
1299
 
1354
1300
        :param to_file: the file to output to
1362
1308
          let the log formatter decide.
1363
1309
        :param show_advice: whether to show advice at the end of the
1364
1310
          log or not
1365
 
        :param author_list_handler: callable generating a list of
1366
 
          authors to display for a given revision
1367
1311
        """
1368
1312
        self.to_file = to_file
1369
1313
        # 'exact' stream used to show diff, it should print content 'as is'
1384
1328
        self.levels = levels
1385
1329
        self._show_advice = show_advice
1386
1330
        self._merge_count = 0
1387
 
        self._author_list_handler = author_list_handler
1388
1331
 
1389
1332
    def get_levels(self):
1390
1333
        """Get the number of levels to display or 0 for all."""
1422
1365
        return address
1423
1366
 
1424
1367
    def short_author(self, rev):
1425
 
        return self.authors(rev, 'first', short=True, sep=', ')
1426
 
 
1427
 
    def authors(self, rev, who, short=False, sep=None):
1428
 
        """Generate list of authors, taking --authors option into account.
1429
 
 
1430
 
        The caller has to specify the name of a author list handler,
1431
 
        as provided by the author list registry, using the ``who``
1432
 
        argument.  That name only sets a default, though: when the
1433
 
        user selected a different author list generation using the
1434
 
        ``--authors`` command line switch, as represented by the
1435
 
        ``author_list_handler`` constructor argument, that value takes
1436
 
        precedence.
1437
 
 
1438
 
        :param rev: The revision for which to generate the list of authors.
1439
 
        :param who: Name of the default handler.
1440
 
        :param short: Whether to shorten names to either name or address.
1441
 
        :param sep: What separator to use for automatic concatenation.
1442
 
        """
1443
 
        if self._author_list_handler is not None:
1444
 
            # The user did specify --authors, which overrides the default
1445
 
            author_list_handler = self._author_list_handler
1446
 
        else:
1447
 
            # The user didn't specify --authors, so we use the caller's default
1448
 
            author_list_handler = author_list_registry.get(who)
1449
 
        names = author_list_handler(rev)
1450
 
        if short:
1451
 
            for i in range(len(names)):
1452
 
                name, address = config.parse_username(names[i])
1453
 
                if name:
1454
 
                    names[i] = name
1455
 
                else:
1456
 
                    names[i] = address
1457
 
        if sep is not None:
1458
 
            names = sep.join(names)
1459
 
        return names
 
1368
        name, address = config.parse_username(rev.get_apparent_authors()[0])
 
1369
        if name:
 
1370
            return name
 
1371
        return address
1460
1372
 
1461
1373
    def merge_marker(self, revision):
1462
1374
        """Get the merge marker to include in the output or '' if none."""
1493
1405
        """
1494
1406
        # Revision comes directly from a foreign repository
1495
1407
        if isinstance(rev, foreign.ForeignRevision):
1496
 
            return self._format_properties(
1497
 
                rev.mapping.vcs.show_foreign_revid(rev.foreign_revid))
 
1408
            return rev.mapping.vcs.show_foreign_revid(rev.foreign_revid)
1498
1409
 
1499
1410
        # Imported foreign revision revision ids always contain :
1500
1411
        if not ":" in rev.revision_id:
1564
1475
        lines.extend(self.custom_properties(revision.rev))
1565
1476
 
1566
1477
        committer = revision.rev.committer
1567
 
        authors = self.authors(revision.rev, 'all')
 
1478
        authors = revision.rev.get_apparent_authors()
1568
1479
        if authors != [committer]:
1569
1480
            lines.append('author: %s' % (", ".join(authors),))
1570
1481
        lines.append('committer: %s' % (committer,))
1587
1498
        to_file = self.to_file
1588
1499
        to_file.write("%s%s\n" % (indent, ('\n' + indent).join(lines)))
1589
1500
        if revision.delta is not None:
1590
 
            # Use the standard status output to display changes
1591
 
            from bzrlib.delta import report_delta
1592
 
            report_delta(to_file, revision.delta, short_status=False, 
1593
 
                         show_ids=self.show_ids, indent=indent)
 
1501
            # We don't respect delta_format for compatibility
 
1502
            revision.delta.show(to_file, self.show_ids, indent=indent,
 
1503
                                short_status=False)
1594
1504
        if revision.diff is not None:
1595
1505
            to_file.write(indent + 'diff:\n')
1596
1506
            to_file.flush()
1659
1569
                to_file.write(indent + offset + '%s\n' % (l,))
1660
1570
 
1661
1571
        if revision.delta is not None:
1662
 
            # Use the standard status output to display changes
1663
 
            from bzrlib.delta import report_delta
1664
 
            report_delta(to_file, revision.delta, 
1665
 
                         short_status=self.delta_format==1, 
1666
 
                         show_ids=self.show_ids, indent=indent + offset)
 
1572
            revision.delta.show(to_file, self.show_ids, indent=indent + offset,
 
1573
                                short_status=self.delta_format==1)
1667
1574
        if revision.diff is not None:
1668
1575
            self.show_diff(self.to_exact_file, revision.diff, '      ')
1669
1576
        to_file.write('\n')
1744
1651
                               self.show_timezone,
1745
1652
                               date_fmt='%Y-%m-%d',
1746
1653
                               show_offset=False)
1747
 
        committer_str = self.authors(revision.rev, 'first', sep=', ')
1748
 
        committer_str = committer_str.replace(' <', '  <')
 
1654
        committer_str = revision.rev.committer.replace (' <', '  <')
1749
1655
        to_file.write('%s  %s\n\n' % (date_str,committer_str))
1750
1656
 
1751
1657
        if revision.delta is not None and revision.delta.has_changed():
1816
1722
        raise errors.BzrCommandError("unknown log formatter: %r" % name)
1817
1723
 
1818
1724
 
1819
 
def author_list_all(rev):
1820
 
    return rev.get_apparent_authors()[:]
1821
 
 
1822
 
 
1823
 
def author_list_first(rev):
1824
 
    lst = rev.get_apparent_authors()
1825
 
    try:
1826
 
        return [lst[0]]
1827
 
    except IndexError:
1828
 
        return []
1829
 
 
1830
 
 
1831
 
def author_list_committer(rev):
1832
 
    return [rev.committer]
1833
 
 
1834
 
 
1835
 
author_list_registry = registry.Registry()
1836
 
 
1837
 
author_list_registry.register('all', author_list_all,
1838
 
                              'All authors')
1839
 
 
1840
 
author_list_registry.register('first', author_list_first,
1841
 
                              'The first author')
1842
 
 
1843
 
author_list_registry.register('committer', author_list_committer,
1844
 
                              'The committer')
1845
 
 
1846
 
 
1847
1725
def show_one_log(revno, rev, delta, verbose, to_file, show_timezone):
1848
1726
    # deprecated; for compatibility
1849
1727
    lf = LongLogFormatter(to_file=to_file, show_timezone=show_timezone)
2000
1878
        lf.log_revision(lr)
2001
1879
 
2002
1880
 
2003
 
def _get_info_for_log_files(revisionspec_list, file_list, add_cleanup):
 
1881
def _get_info_for_log_files(revisionspec_list, file_list):
2004
1882
    """Find file-ids and kinds given a list of files and a revision range.
2005
1883
 
2006
1884
    We search for files at the end of the range. If not found there,
2010
1888
    :param file_list: the list of paths given on the command line;
2011
1889
      the first of these can be a branch location or a file path,
2012
1890
      the remainder must be file paths
2013
 
    :param add_cleanup: When the branch returned is read locked,
2014
 
      an unlock call will be queued to the cleanup.
2015
1891
    :return: (branch, info_list, start_rev_info, end_rev_info) where
2016
1892
      info_list is a list of (relative_path, file_id, kind) tuples where
2017
1893
      kind is one of values 'directory', 'file', 'symlink', 'tree-reference'.
2019
1895
    """
2020
1896
    from builtins import _get_revision_range, safe_relpath_files
2021
1897
    tree, b, path = bzrdir.BzrDir.open_containing_tree_or_branch(file_list[0])
2022
 
    add_cleanup(b.lock_read().unlock)
 
1898
    b.lock_read()
2023
1899
    # XXX: It's damn messy converting a list of paths to relative paths when
2024
1900
    # those paths might be deleted ones, they might be on a case-insensitive
2025
1901
    # filesystem and/or they might be in silly locations (like another branch).
2104
1980
 
2105
1981
properties_handler_registry = registry.Registry()
2106
1982
 
2107
 
# Use the properties handlers to print out bug information if available
2108
 
def _bugs_properties_handler(revision):
2109
 
    if revision.properties.has_key('bugs'):
2110
 
        bug_lines = revision.properties['bugs'].split('\n')
2111
 
        bug_rows = [line.split(' ', 1) for line in bug_lines]
2112
 
        fixed_bug_urls = [row[0] for row in bug_rows if
2113
 
                          len(row) > 1 and row[1] == 'fixed']
2114
 
 
2115
 
        if fixed_bug_urls:
2116
 
            return {'fixes bug(s)': ' '.join(fixed_bug_urls)}
2117
 
    return {}
2118
 
 
2119
 
properties_handler_registry.register('bugs_properties_handler',
2120
 
                                     _bugs_properties_handler)
2121
 
 
2122
1983
 
2123
1984
# adapters which revision ids to log are filtered. When log is called, the
2124
1985
# log_rev_iterator is adapted through each of these factory methods.