~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-24 03:51:17 UTC
  • mfrom: (6162.1.3 857335-tags-revs-slow)
  • Revision ID: pqm@pqm.ubuntu.com-20110924035117-zwr1s675gzzftm8m
(vila) Stop reloading all ancestry for each tag when searching tags in a
 revision range (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2620
2620
            match_dict['author'] = match_author
2621
2621
        if match_bugs:
2622
2622
            match_dict['bugs'] = match_bugs
2623
 
            
 
2623
 
2624
2624
        # Build the LogRequest and execute it
2625
2625
        if len(file_ids) == 0:
2626
2626
            file_ids = None
5752
5752
 
5753
5753
        self.add_cleanup(branch.lock_read().unlock)
5754
5754
        if revision:
5755
 
            graph = branch.repository.get_graph()
5756
 
            rev1, rev2 = _get_revision_range(revision, branch, self.name())
5757
 
            revid1, revid2 = rev1.rev_id, rev2.rev_id
5758
 
            # only show revisions between revid1 and revid2 (inclusive)
5759
 
            tags = [(tag, revid) for tag, revid in tags if
5760
 
                graph.is_between(revid, revid1, revid2)]
 
5755
            # Restrict to the specified range
 
5756
            tags = self._tags_for_range(branch, revision)
5761
5757
        if sort is None:
5762
5758
            sort = tag_sort_methods.get()
5763
5759
        sort(branch, tags)
5768
5764
                    revno = branch.revision_id_to_dotted_revno(revid)
5769
5765
                    if isinstance(revno, tuple):
5770
5766
                        revno = '.'.join(map(str, revno))
5771
 
                except (errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno):
 
5767
                except (errors.NoSuchRevision,
 
5768
                        errors.GhostRevisionsHaveNoRevno):
5772
5769
                    # Bad tag data/merges can lead to tagged revisions
5773
5770
                    # which are not in this branch. Fail gracefully ...
5774
5771
                    revno = '?'
5777
5774
        for tag, revspec in tags:
5778
5775
            self.outf.write('%-20s %s\n' % (tag, revspec))
5779
5776
 
 
5777
    def _tags_for_range(self, branch, revision):
 
5778
        range_valid = True
 
5779
        rev1, rev2 = _get_revision_range(revision, branch, self.name())
 
5780
        revid1, revid2 = rev1.rev_id, rev2.rev_id
 
5781
        # _get_revision_range will always set revid2 if it's not specified.
 
5782
        # If revid1 is None, it means we want to start from the branch
 
5783
        # origin which is always a valid ancestor. If revid1 == revid2, the
 
5784
        # ancestry check is useless.
 
5785
        if revid1 and revid1 != revid2:
 
5786
            # FIXME: We really want to use the same graph than
 
5787
            # branch.iter_merge_sorted_revisions below, but this is not
 
5788
            # easily available -- vila 2011-09-23
 
5789
            if branch.repository.get_graph().is_ancestor(revid2, revid1):
 
5790
                # We don't want to output anything in this case...
 
5791
                return []
 
5792
        # only show revisions between revid1 and revid2 (inclusive)
 
5793
        tagged_revids = branch.tags.get_reverse_tag_dict()
 
5794
        found = []
 
5795
        for r in branch.iter_merge_sorted_revisions(
 
5796
            start_revision_id=revid2, stop_revision_id=revid1,
 
5797
            stop_rule='include'):
 
5798
            revid_tags = tagged_revids.get(r[0], None)
 
5799
            if revid_tags:
 
5800
                found.extend([(tag, r[0]) for tag in revid_tags])
 
5801
        return found
 
5802
 
5780
5803
 
5781
5804
class cmd_reconfigure(Command):
5782
5805
    __doc__ = """Reconfigure the type of a bzr directory.