/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: Neil Santos
  • Date: 2010-03-04 02:43:41 UTC
  • mto: (5080.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5081.
  • Revision ID: neil_santos@users.sourceforge.net-20100304024341-ra7njxj4lzjb46rl
Removed separate lstat() and reverted LocalTransport and SFTPTransport's stat() methods to using lstat() internally.
Reworked how SFTPTransport's symlink() handles success and signals failure.
Removed lstat() declaration on the Transport base class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
220
220
    'direction': 'reverse',
221
221
    'levels': 1,
222
222
    'generate_tags': True,
223
 
    'exclude_common_ancestry': False,
224
223
    '_match_using_deltas': True,
225
224
    }
226
225
 
227
226
 
228
227
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
 
                          ):
 
228
    start_revision=None, end_revision=None, limit=None,
 
229
    message_search=None, levels=1, generate_tags=True, delta_type=None,
 
230
    diff_type=None, _match_using_deltas=True):
235
231
    """Convenience function for making a logging request dictionary.
236
232
 
237
233
    Using this function may make code slightly safer by ensuring
275
271
      algorithm used for matching specific_fileids. This parameter
276
272
      may be removed in the future so bzrlib client code should NOT
277
273
      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
274
    """
282
275
    return {
283
276
        'direction': direction,
290
283
        'generate_tags': generate_tags,
291
284
        'delta_type': delta_type,
292
285
        'diff_type': diff_type,
293
 
        'exclude_common_ancestry': exclude_common_ancestry,
294
286
        # Add 'private' attributes for features that may be deprecated
295
287
        '_match_using_deltas': _match_using_deltas,
296
288
    }
463
455
        generate_merge_revisions = rqst.get('levels') != 1
464
456
        delayed_graph_generation = not rqst.get('specific_fileids') and (
465
457
                rqst.get('limit') or self.start_rev_id or self.end_rev_id)
466
 
        view_revisions = _calc_view_revisions(
467
 
            self.branch, self.start_rev_id, self.end_rev_id,
468
 
            rqst.get('direction'),
469
 
            generate_merge_revisions=generate_merge_revisions,
470
 
            delayed_graph_generation=delayed_graph_generation,
471
 
            exclude_common_ancestry=rqst.get('exclude_common_ancestry'))
 
458
        view_revisions = _calc_view_revisions(self.branch, self.start_rev_id,
 
459
            self.end_rev_id, rqst.get('direction'), generate_merge_revisions,
 
460
            delayed_graph_generation=delayed_graph_generation)
472
461
 
473
462
        # Apply the other filters
474
463
        return make_log_rev_iterator(self.branch, view_revisions,
481
470
        # Note that we always generate the merge revisions because
482
471
        # filter_revisions_touching_file_id() requires them ...
483
472
        rqst = self.rqst
484
 
        view_revisions = _calc_view_revisions(
485
 
            self.branch, self.start_rev_id, self.end_rev_id,
486
 
            rqst.get('direction'), generate_merge_revisions=True,
487
 
            exclude_common_ancestry=rqst.get('exclude_common_ancestry'))
 
473
        view_revisions = _calc_view_revisions(self.branch, self.start_rev_id,
 
474
            self.end_rev_id, rqst.get('direction'), True)
488
475
        if not isinstance(view_revisions, list):
489
476
            view_revisions = list(view_revisions)
490
477
        view_revisions = _filter_revisions_touching_file_id(self.branch,
495
482
 
496
483
 
497
484
def _calc_view_revisions(branch, start_rev_id, end_rev_id, direction,
498
 
                         generate_merge_revisions,
499
 
                         delayed_graph_generation=False,
500
 
                         exclude_common_ancestry=False,
501
 
                         ):
 
485
    generate_merge_revisions, delayed_graph_generation=False):
502
486
    """Calculate the revisions to view.
503
487
 
504
488
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples OR
505
489
             a list of the same tuples.
506
490
    """
507
 
    if (exclude_common_ancestry and start_rev_id == end_rev_id):
508
 
        raise errors.BzrCommandError(
509
 
            '--exclude-common-ancestry requires two different revisions')
510
 
    if direction not in ('reverse', 'forward'):
511
 
        raise ValueError('invalid direction %r' % direction)
512
491
    br_revno, br_rev_id = branch.last_revision_info()
513
492
    if br_revno == 0:
514
493
        return []
515
494
 
516
 
    if (end_rev_id and start_rev_id == end_rev_id
517
 
        and (not generate_merge_revisions
518
 
             or not _has_merges(branch, end_rev_id))):
519
 
        # If a single revision is requested, check we can handle it
520
 
        iter_revs = _generate_one_revision(branch, end_rev_id, br_rev_id,
521
 
                                           br_revno)
522
 
    elif not generate_merge_revisions:
523
 
        # If we only want to see linear revisions, we can iterate ...
524
 
        iter_revs = _generate_flat_revisions(branch, start_rev_id, end_rev_id,
525
 
                                             direction)
526
 
        if direction == 'forward':
527
 
            iter_revs = reversed(iter_revs)
 
495
    # If a single revision is requested, check we can handle it
 
496
    generate_single_revision = (end_rev_id and start_rev_id == end_rev_id and
 
497
        (not generate_merge_revisions or not _has_merges(branch, end_rev_id)))
 
498
    if generate_single_revision:
 
499
        return _generate_one_revision(branch, end_rev_id, br_rev_id, br_revno)
 
500
 
 
501
    # If we only want to see linear revisions, we can iterate ...
 
502
    if not generate_merge_revisions:
 
503
        return _generate_flat_revisions(branch, start_rev_id, end_rev_id,
 
504
            direction)
528
505
    else:
529
 
        iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
530
 
                                            direction, delayed_graph_generation,
531
 
                                            exclude_common_ancestry)
532
 
        if direction == 'forward':
533
 
            iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
534
 
    return iter_revs
 
506
        return _generate_all_revisions(branch, start_rev_id, end_rev_id,
 
507
            direction, delayed_graph_generation)
535
508
 
536
509
 
537
510
def _generate_one_revision(branch, rev_id, br_rev_id, br_revno):
555
528
        except _StartNotLinearAncestor:
556
529
            raise errors.BzrCommandError('Start revision not found in'
557
530
                ' left-hand history of end revision.')
 
531
    if direction == 'forward':
 
532
        result = reversed(result)
558
533
    return result
559
534
 
560
535
 
561
536
def _generate_all_revisions(branch, start_rev_id, end_rev_id, direction,
562
 
                            delayed_graph_generation,
563
 
                            exclude_common_ancestry=False):
 
537
                            delayed_graph_generation):
564
538
    # On large trees, generating the merge graph can take 30-60 seconds
565
539
    # so we delay doing it until a merge is detected, incrementally
566
540
    # returning initial (non-merge) revisions while we can.
579
553
                    # may not raise _StartNotLinearAncestor for a revision that
580
554
                    # is an ancestor but not a *linear* one. But since we have
581
555
                    # loaded the graph to do the check (or calculate a dotted
582
 
                    # revno), we may as well accept to show the log...  We need
583
 
                    # the check only if start_rev_id is not None as all
584
 
                    # revisions have _mod_revision.NULL_REVISION as an ancestor
585
 
                    # -- vila 20100319
 
556
                    # revno), we may as well accept to show the log... 
 
557
                    # -- vila 100201
586
558
                    graph = branch.repository.get_graph()
587
 
                    if (start_rev_id is not None
588
 
                        and not graph.is_ancestor(start_rev_id, end_rev_id)):
 
559
                    if not graph.is_ancestor(start_rev_id, end_rev_id):
589
560
                        raise _StartNotLinearAncestor()
590
 
                    # Since we collected the revisions so far, we need to
591
 
                    # adjust end_rev_id.
592
561
                    end_rev_id = rev_id
593
562
                    break
594
563
                else:
595
564
                    initial_revisions.append((rev_id, revno, depth))
596
565
            else:
597
566
                # No merged revisions found
598
 
                return initial_revisions
 
567
                if direction == 'reverse':
 
568
                    return initial_revisions
 
569
                elif direction == 'forward':
 
570
                    return reversed(initial_revisions)
 
571
                else:
 
572
                    raise ValueError('invalid direction %r' % direction)
599
573
        except _StartNotLinearAncestor:
600
574
            # A merge was never detected so the lower revision limit can't
601
575
            # be nested down somewhere
602
576
            raise errors.BzrCommandError('Start revision not found in'
603
577
                ' history of end revision.')
604
578
 
605
 
    # We exit the loop above because we encounter a revision with merges, from
606
 
    # this revision, we need to switch to _graph_view_revisions.
607
 
 
608
579
    # A log including nested merges is required. If the direction is reverse,
609
580
    # we rebase the initial merge depths so that the development line is
610
581
    # shown naturally, i.e. just like it is for linear logging. We can easily
612
583
    # indented at the end seems slightly nicer in that case.
613
584
    view_revisions = chain(iter(initial_revisions),
614
585
        _graph_view_revisions(branch, start_rev_id, end_rev_id,
615
 
                              rebase_initial_depths=(direction == 'reverse'),
616
 
                              exclude_common_ancestry=exclude_common_ancestry))
617
 
    return view_revisions
 
586
        rebase_initial_depths=direction == 'reverse'))
 
587
    if direction == 'reverse':
 
588
        return view_revisions
 
589
    elif direction == 'forward':
 
590
        # Forward means oldest first, adjusting for depth.
 
591
        view_revisions = reverse_by_depth(list(view_revisions))
 
592
        return _rebase_merge_depth(view_revisions)
 
593
    else:
 
594
        raise ValueError('invalid direction %r' % direction)
618
595
 
619
596
 
620
597
def _has_merges(branch, rev_id):
678
655
 
679
656
 
680
657
def _graph_view_revisions(branch, start_rev_id, end_rev_id,
681
 
                          rebase_initial_depths=True,
682
 
                          exclude_common_ancestry=False):
 
658
    rebase_initial_depths=True):
683
659
    """Calculate revisions to view including merges, newest to oldest.
684
660
 
685
661
    :param branch: the branch
689
665
      revision is found?
690
666
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples.
691
667
    """
692
 
    if exclude_common_ancestry:
693
 
        stop_rule = 'with-merges-without-common-ancestry'
694
 
    else:
695
 
        stop_rule = 'with-merges'
696
668
    view_revisions = branch.iter_merge_sorted_revisions(
697
669
        start_revision_id=end_rev_id, stop_revision_id=start_rev_id,
698
 
        stop_rule=stop_rule)
 
670
        stop_rule="with-merges")
699
671
    if not rebase_initial_depths:
700
672
        for (rev_id, merge_depth, revno, end_of_merge
701
673
             ) in view_revisions:
1452
1424
        """
1453
1425
        # Revision comes directly from a foreign repository
1454
1426
        if isinstance(rev, foreign.ForeignRevision):
1455
 
            return self._format_properties(
1456
 
                rev.mapping.vcs.show_foreign_revid(rev.foreign_revid))
 
1427
            return self._format_properties(rev.mapping.vcs.show_foreign_revid(rev.foreign_revid))
1457
1428
 
1458
1429
        # Imported foreign revision revision ids always contain :
1459
1430
        if not ":" in rev.revision_id:
1546
1517
        to_file = self.to_file
1547
1518
        to_file.write("%s%s\n" % (indent, ('\n' + indent).join(lines)))
1548
1519
        if revision.delta is not None:
1549
 
            # Use the standard status output to display changes
1550
 
            from bzrlib.delta import report_delta
1551
 
            report_delta(to_file, revision.delta, short_status=False, 
1552
 
                         show_ids=self.show_ids, indent=indent)
 
1520
            # We don't respect delta_format for compatibility
 
1521
            revision.delta.show(to_file, self.show_ids, indent=indent,
 
1522
                                short_status=False)
1553
1523
        if revision.diff is not None:
1554
1524
            to_file.write(indent + 'diff:\n')
1555
1525
            to_file.flush()
1618
1588
                to_file.write(indent + offset + '%s\n' % (l,))
1619
1589
 
1620
1590
        if revision.delta is not None:
1621
 
            # Use the standard status output to display changes
1622
 
            from bzrlib.delta import report_delta
1623
 
            report_delta(to_file, revision.delta, 
1624
 
                         short_status=self.delta_format==1, 
1625
 
                         show_ids=self.show_ids, indent=indent + offset)
 
1591
            revision.delta.show(to_file, self.show_ids, indent=indent + offset,
 
1592
                                short_status=self.delta_format==1)
1626
1593
        if revision.diff is not None:
1627
1594
            self.show_diff(self.to_exact_file, revision.diff, '      ')
1628
1595
        to_file.write('\n')
1703
1670
                               self.show_timezone,
1704
1671
                               date_fmt='%Y-%m-%d',
1705
1672
                               show_offset=False)
1706
 
        committer_str = revision.rev.get_apparent_authors()[0].replace (' <', '  <')
 
1673
        committer_str = revision.rev.committer.replace (' <', '  <')
1707
1674
        to_file.write('%s  %s\n\n' % (date_str,committer_str))
1708
1675
 
1709
1676
        if revision.delta is not None and revision.delta.has_changed():
2039
2006
        bug_rows = [line.split(' ', 1) for line in bug_lines]
2040
2007
        fixed_bug_urls = [row[0] for row in bug_rows if
2041
2008
                          len(row) > 1 and row[1] == 'fixed']
2042
 
 
 
2009
        
2043
2010
        if fixed_bug_urls:
2044
2011
            return {'fixes bug(s)': ' '.join(fixed_bug_urls)}
2045
2012
    return {}