~jelmer/brz/fix-c-extensions

« back to all changes in this revision

Viewing changes to breezy/log.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
409
409
 
410
410
        # Find and print the interesting revisions
411
411
        generator = self._generator_factory(self.branch, rqst)
412
 
        for lr in generator.iter_log_revisions():
413
 
            lf.log_revision(lr)
 
412
        try:
 
413
            for lr in generator.iter_log_revisions():
 
414
                lf.log_revision(lr)
 
415
        except errors.GhostRevisionUnusableHere:
 
416
            raise errors.BzrCommandError(
 
417
                    gettext('Further revision history missing.'))
414
418
        lf.show_advice()
415
419
 
416
420
    def _generator_factory(self, branch, rqst):
456
460
                    continue
457
461
                if omit_merges and len(rev.parent_ids) > 1:
458
462
                    continue
 
463
                if rev is None:
 
464
                    raise errors.GhostRevisionUnusableHere(rev_id)
459
465
                if diff_type is None:
460
466
                    diff = None
461
467
                else:
723
729
    :param exclude_common_ancestry: Whether the start_rev_id should be part of
724
730
        the iterated revisions.
725
731
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples.
 
732
        dotted_revno will be None for ghosts
726
733
    :raises _StartNotLinearAncestor: if a start_rev_id is specified but
727
734
        is not found walking the left-hand history
728
735
    """
731
738
    graph = repo.get_graph()
732
739
    if start_rev_id is None and end_rev_id is None:
733
740
        cur_revno = br_revno
734
 
        for revision_id in graph.iter_lefthand_ancestry(br_rev_id,
735
 
            (_mod_revision.NULL_REVISION,)):
736
 
            yield revision_id, str(cur_revno), 0
737
 
            cur_revno -= 1
 
741
        graph_iter = graph.iter_lefthand_ancestry(br_rev_id,
 
742
            (_mod_revision.NULL_REVISION,))
 
743
        while True:
 
744
            try:
 
745
                revision_id = next(graph_iter)
 
746
            except errors.RevisionNotPresent as e:
 
747
                # Oops, a ghost.
 
748
                yield e.revision_id, None, None
 
749
                break
 
750
            else:
 
751
                yield revision_id, str(cur_revno), 0
 
752
                cur_revno -= 1
738
753
    else:
739
754
        if end_rev_id is None:
740
755
            end_rev_id = br_rev_id
741
756
        found_start = start_rev_id is None
742
 
        for revision_id in graph.iter_lefthand_ancestry(end_rev_id,
743
 
                (_mod_revision.NULL_REVISION,)):
744
 
            revno_str = _compute_revno_str(branch, revision_id)
745
 
            if not found_start and revision_id == start_rev_id:
746
 
                if not exclude_common_ancestry:
 
757
        graph_iter = graph.iter_lefthand_ancestry(end_rev_id,
 
758
            (_mod_revision.NULL_REVISION,))
 
759
        while True:
 
760
            try:
 
761
                revision_id = next(graph_iter)
 
762
            except StopIteration:
 
763
                break
 
764
            except errors.RevisionNotPresent as e:
 
765
                # Oops, a ghost.
 
766
                yield e.revision_id, None, None
 
767
                break
 
768
            else:
 
769
                revno_str = _compute_revno_str(branch, revision_id)
 
770
                if not found_start and revision_id == start_rev_id:
 
771
                    if not exclude_common_ancestry:
 
772
                        yield revision_id, revno_str, 0
 
773
                    found_start = True
 
774
                    break
 
775
                else:
747
776
                    yield revision_id, revno_str, 0
748
 
                found_start = True
749
 
                break
750
 
            else:
751
 
                yield revision_id, revno_str, 0
752
 
        else:
753
 
            if not found_start:
754
 
                raise _StartNotLinearAncestor()
 
777
        if not found_start:
 
778
            raise _StartNotLinearAncestor()
755
779
 
756
780
 
757
781
def _graph_view_revisions(branch, start_rev_id, end_rev_id,
861
885
    :return: An iterator over lists of ((rev_id, revno, merge_depth), rev,
862
886
        delta).
863
887
    """
864
 
    if match is None:
 
888
    if not match:
865
889
        return log_rev_iterator
866
890
    searchRE = [(k, [re.compile(x, re.IGNORECASE) for x in v])
867
891
                for k, v in match.items()]
998
1022
    for revs in log_rev_iterator:
999
1023
        # r = revision_id, n = revno, d = merge depth
1000
1024
        revision_ids = [view[0] for view, _, _ in revs]
1001
 
        revisions = repository.get_revisions(revision_ids)
1002
 
        revs = [(rev[0], revision, rev[2]) for rev, revision in
1003
 
            zip(revs, revisions)]
1004
 
        yield revs
 
1025
        revisions = dict(repository.iter_revisions(revision_ids))
 
1026
        yield [(rev[0], revisions[rev[0][0]], rev[2]) for rev in revs]
1005
1027
 
1006
1028
 
1007
1029
def _make_batch_filter(branch, generate_delta, search, log_rev_iterator):