Merge lp:~ian-clatworthy/bzr/faster-tags2 into lp:~bzr/bzr/trunk-old

Proposed by Ian Clatworthy
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ian-clatworthy/bzr/faster-tags2
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 75 lines
To merge this branch: bzr merge lp:~ian-clatworthy/bzr/faster-tags2
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+6901@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

This fixes the locking problem Matthew Fuller highlighted on the mailing list.

Rather than put the branch lock around just the revno lookup, I think it's more correct to lock just once, having the same lock across the optional rev-id lookup, sorting and revno generation steps.

Revision history for this message
Martin Pool (mbp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/builtins.py'
2--- bzrlib/builtins.py 2009-05-29 03:26:25 +0000
3+++ bzrlib/builtins.py 2009-05-30 06:35:13 +0000
4@@ -5027,42 +5027,42 @@
5 if not tags:
6 return
7
8- if revision:
9- branch.lock_read()
10- try:
11+ branch.lock_read()
12+ try:
13+ if revision:
14 graph = branch.repository.get_graph()
15 rev1, rev2 = _get_revision_range(revision, branch, self.name())
16 revid1, revid2 = rev1.rev_id, rev2.rev_id
17 # only show revisions between revid1 and revid2 (inclusive)
18 tags = [(tag, revid) for tag, revid in tags if
19 graph.is_between(revid, revid1, revid2)]
20- finally:
21- branch.unlock()
22- if sort == 'alpha':
23- tags.sort()
24- elif sort == 'time':
25- timestamps = {}
26- for tag, revid in tags:
27- try:
28- revobj = branch.repository.get_revision(revid)
29- except errors.NoSuchRevision:
30- timestamp = sys.maxint # place them at the end
31- else:
32- timestamp = revobj.timestamp
33- timestamps[revid] = timestamp
34- tags.sort(key=lambda x: timestamps[x[1]])
35- if not show_ids:
36- # [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
37- for index, (tag, revid) in enumerate(tags):
38- try:
39- revno = branch.revision_id_to_dotted_revno(revid)
40- if isinstance(revno, tuple):
41- revno = '.'.join(map(str, revno))
42- except errors.NoSuchRevision:
43- # Bad tag data/merges can lead to tagged revisions
44- # which are not in this branch. Fail gracefully ...
45- revno = '?'
46- tags[index] = (tag, revno)
47+ if sort == 'alpha':
48+ tags.sort()
49+ elif sort == 'time':
50+ timestamps = {}
51+ for tag, revid in tags:
52+ try:
53+ revobj = branch.repository.get_revision(revid)
54+ except errors.NoSuchRevision:
55+ timestamp = sys.maxint # place them at the end
56+ else:
57+ timestamp = revobj.timestamp
58+ timestamps[revid] = timestamp
59+ tags.sort(key=lambda x: timestamps[x[1]])
60+ if not show_ids:
61+ # [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
62+ for index, (tag, revid) in enumerate(tags):
63+ try:
64+ revno = branch.revision_id_to_dotted_revno(revid)
65+ if isinstance(revno, tuple):
66+ revno = '.'.join(map(str, revno))
67+ except errors.NoSuchRevision:
68+ # Bad tag data/merges can lead to tagged revisions
69+ # which are not in this branch. Fail gracefully ...
70+ revno = '?'
71+ tags[index] = (tag, revno)
72+ finally:
73+ branch.unlock()
74 for tag, revspec in tags:
75 self.outf.write('%-20s %s\n' % (tag, revspec))
76