5753
5753
self.add_cleanup(branch.lock_read().unlock)
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 ...
5777
5774
for tag, revspec in tags:
5778
5775
self.outf.write('%-20s %s\n' % (tag, revspec))
5777
def _tags_for_range(self, branch, revision):
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...
5792
# only show revisions between revid1 and revid2 (inclusive)
5793
tagged_revids = branch.tags.get_reverse_tag_dict()
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)
5800
found.extend([(tag, r[0]) for tag in revid_tags])
5781
5804
class cmd_reconfigure(Command):
5782
5805
__doc__ = """Reconfigure the type of a bzr directory.