~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: 2010-04-28 09:40:23 UTC
  • mfrom: (5155.1.5 320119-exclude-ancestry)
  • Revision ID: pqm@pqm.ubuntu.com-20100428094023-7504mlou1qk28r9n
(vila) Add --exclude-common-ancestry log option (Vincent Ladeuil)

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,
223
224
    '_match_using_deltas': True,
224
225
    }
225
226
 
226
227
 
227
228
def make_log_request_dict(direction='reverse', specific_fileids=None,
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):
 
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
                          ):
231
235
    """Convenience function for making a logging request dictionary.
232
236
 
233
237
    Using this function may make code slightly safer by ensuring
271
275
      algorithm used for matching specific_fileids. This parameter
272
276
      may be removed in the future so bzrlib client code should NOT
273
277
      use it.
 
278
 
 
279
    :param exclude_common_ancestry: Whether -rX..Y should be interpreted as a
 
280
      range operator or as a graph difference.
274
281
    """
275
282
    return {
276
283
        'direction': direction,
283
290
        'generate_tags': generate_tags,
284
291
        'delta_type': delta_type,
285
292
        'diff_type': diff_type,
 
293
        'exclude_common_ancestry': exclude_common_ancestry,
286
294
        # Add 'private' attributes for features that may be deprecated
287
295
        '_match_using_deltas': _match_using_deltas,
288
296
    }
459
467
            self.branch, self.start_rev_id, self.end_rev_id,
460
468
            rqst.get('direction'),
461
469
            generate_merge_revisions=generate_merge_revisions,
462
 
            delayed_graph_generation=delayed_graph_generation)
 
470
            delayed_graph_generation=delayed_graph_generation,
 
471
            exclude_common_ancestry=rqst.get('exclude_common_ancestry'))
463
472
 
464
473
        # Apply the other filters
465
474
        return make_log_rev_iterator(self.branch, view_revisions,
474
483
        rqst = self.rqst
475
484
        view_revisions = _calc_view_revisions(
476
485
            self.branch, self.start_rev_id, self.end_rev_id,
477
 
            rqst.get('direction'), generate_merge_revisions=True)
 
486
            rqst.get('direction'), generate_merge_revisions=True,
 
487
            exclude_common_ancestry=rqst.get('exclude_common_ancestry'))
478
488
        if not isinstance(view_revisions, list):
479
489
            view_revisions = list(view_revisions)
480
490
        view_revisions = _filter_revisions_touching_file_id(self.branch,
485
495
 
486
496
 
487
497
def _calc_view_revisions(branch, start_rev_id, end_rev_id, direction,
488
 
    generate_merge_revisions, delayed_graph_generation=False):
 
498
                         generate_merge_revisions,
 
499
                         delayed_graph_generation=False,
 
500
                         exclude_common_ancestry=False,
 
501
                         ):
489
502
    """Calculate the revisions to view.
490
503
 
491
504
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples OR
492
505
             a list of the same tuples.
493
506
    """
 
507
    if (exclude_common_ancestry and start_rev_id == end_rev_id):
 
508
        raise errors.BzrCommandError(
 
509
            '--exclude-common-ancestry requires two different revisions')
494
510
    if direction not in ('reverse', 'forward'):
495
511
        raise ValueError('invalid direction %r' % direction)
496
512
    br_revno, br_rev_id = branch.last_revision_info()
511
527
            iter_revs = reversed(iter_revs)
512
528
    else:
513
529
        iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
514
 
                                            direction, delayed_graph_generation)
 
530
                                            direction, delayed_graph_generation,
 
531
                                            exclude_common_ancestry)
515
532
        if direction == 'forward':
516
533
            iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
517
534
    return iter_revs
542
559
 
543
560
 
544
561
def _generate_all_revisions(branch, start_rev_id, end_rev_id, direction,
545
 
                            delayed_graph_generation):
 
562
                            delayed_graph_generation,
 
563
                            exclude_common_ancestry=False):
546
564
    # On large trees, generating the merge graph can take 30-60 seconds
547
565
    # so we delay doing it until a merge is detected, incrementally
548
566
    # returning initial (non-merge) revisions while we can.
594
612
    # indented at the end seems slightly nicer in that case.
595
613
    view_revisions = chain(iter(initial_revisions),
596
614
        _graph_view_revisions(branch, start_rev_id, end_rev_id,
597
 
                              rebase_initial_depths=(direction == 'reverse')))
 
615
                              rebase_initial_depths=(direction == 'reverse'),
 
616
                              exclude_common_ancestry=exclude_common_ancestry))
598
617
    return view_revisions
599
618
 
600
619
 
659
678
 
660
679
 
661
680
def _graph_view_revisions(branch, start_rev_id, end_rev_id,
662
 
                          rebase_initial_depths=True):
 
681
                          rebase_initial_depths=True,
 
682
                          exclude_common_ancestry=False):
663
683
    """Calculate revisions to view including merges, newest to oldest.
664
684
 
665
685
    :param branch: the branch
669
689
      revision is found?
670
690
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples.
671
691
    """
 
692
    if exclude_common_ancestry:
 
693
        stop_rule = 'with-merges-without-common-ancestry'
 
694
    else:
 
695
        stop_rule = 'with-merges'
672
696
    view_revisions = branch.iter_merge_sorted_revisions(
673
697
        start_revision_id=end_rev_id, stop_revision_id=start_rev_id,
674
 
        stop_rule="with-merges")
 
698
        stop_rule=stop_rule)
675
699
    if not rebase_initial_depths:
676
700
        for (rev_id, merge_depth, revno, end_of_merge
677
701
             ) in view_revisions: