/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/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-30 15:01:10 UTC
  • mfrom: (4392.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090530150110-c87w11jf6sqevh16
(igc) fix locking in tags command

Show diffs side-by-side

added added

removed removed

Lines of Context:
5027
5027
        if not tags:
5028
5028
            return
5029
5029
 
5030
 
        if revision:
5031
 
            branch.lock_read()
5032
 
            try:
 
5030
        branch.lock_read()
 
5031
        try:
 
5032
            if revision:
5033
5033
                graph = branch.repository.get_graph()
5034
5034
                rev1, rev2 = _get_revision_range(revision, branch, self.name())
5035
5035
                revid1, revid2 = rev1.rev_id, rev2.rev_id
5036
5036
                # only show revisions between revid1 and revid2 (inclusive)
5037
5037
                tags = [(tag, revid) for tag, revid in tags if
5038
5038
                    graph.is_between(revid, revid1, revid2)]
5039
 
            finally:
5040
 
                branch.unlock()
5041
 
        if sort == 'alpha':
5042
 
            tags.sort()
5043
 
        elif sort == 'time':
5044
 
            timestamps = {}
5045
 
            for tag, revid in tags:
5046
 
                try:
5047
 
                    revobj = branch.repository.get_revision(revid)
5048
 
                except errors.NoSuchRevision:
5049
 
                    timestamp = sys.maxint # place them at the end
5050
 
                else:
5051
 
                    timestamp = revobj.timestamp
5052
 
                timestamps[revid] = timestamp
5053
 
            tags.sort(key=lambda x: timestamps[x[1]])
5054
 
        if not show_ids:
5055
 
            # [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
5056
 
            for index, (tag, revid) in enumerate(tags):
5057
 
                try:
5058
 
                    revno = branch.revision_id_to_dotted_revno(revid)
5059
 
                    if isinstance(revno, tuple):
5060
 
                        revno = '.'.join(map(str, revno))
5061
 
                except errors.NoSuchRevision:
5062
 
                    # Bad tag data/merges can lead to tagged revisions
5063
 
                    # which are not in this branch. Fail gracefully ...
5064
 
                    revno = '?'
5065
 
                tags[index] = (tag, revno)
 
5039
            if sort == 'alpha':
 
5040
                tags.sort()
 
5041
            elif sort == 'time':
 
5042
                timestamps = {}
 
5043
                for tag, revid in tags:
 
5044
                    try:
 
5045
                        revobj = branch.repository.get_revision(revid)
 
5046
                    except errors.NoSuchRevision:
 
5047
                        timestamp = sys.maxint # place them at the end
 
5048
                    else:
 
5049
                        timestamp = revobj.timestamp
 
5050
                    timestamps[revid] = timestamp
 
5051
                tags.sort(key=lambda x: timestamps[x[1]])
 
5052
            if not show_ids:
 
5053
                # [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
 
5054
                for index, (tag, revid) in enumerate(tags):
 
5055
                    try:
 
5056
                        revno = branch.revision_id_to_dotted_revno(revid)
 
5057
                        if isinstance(revno, tuple):
 
5058
                            revno = '.'.join(map(str, revno))
 
5059
                    except errors.NoSuchRevision:
 
5060
                        # Bad tag data/merges can lead to tagged revisions
 
5061
                        # which are not in this branch. Fail gracefully ...
 
5062
                        revno = '?'
 
5063
                    tags[index] = (tag, revno)
 
5064
        finally:
 
5065
            branch.unlock()
5066
5066
        for tag, revspec in tags:
5067
5067
            self.outf.write('%-20s %s\n' % (tag, revspec))
5068
5068