Merge lp:~spiv/bzr/annotate-objectnotlocked-496590 into lp:bzr/2.0

Proposed by Andrew Bennetts
Status: Merged
Approved by: Martin Pool
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~spiv/bzr/annotate-objectnotlocked-496590
Merge into: lp:bzr/2.0
Diff against target: 102 lines (+40/-19)
3 files modified
NEWS (+3/-0)
bzrlib/builtins.py (+19/-15)
bzrlib/tests/blackbox/test_annotate.py (+18/-4)
To merge this branch: bzr merge lp:~spiv/bzr/annotate-objectnotlocked-496590
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+16945@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrew Bennetts (spiv) wrote :

This is a minimal fix for bug 496590 targetted to 2.0.x. <https://code.edge.launchpad.net/~spiv/bzr/command-cleanup/+merge/16943> has a much more comprehensive fix for pretty much all bugs of this sort in builtins.py, but it's obviously a bit too large to be sensible for 2.0.x.

Revision history for this message
Martin Pool (mbp) wrote :

Generally speaking it would be nice to also merge tests to 2.0, for all the usual reasons. But if that would be too hard, or depends on other changes, it's ok like this.

Thanks,

review: Approve
Revision history for this message
Andrew Bennetts (spiv) wrote :

Hmm, yes. I suppose I can turn the shell script at <http://launchpadlibrarian.net/37540559/repro.sh> (see comment 3 of bug 496590) into a simple test easily enough, so I'll do that.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-01-07 08:57:14 +0000
3+++ NEWS 2010-01-07 12:37:18 +0000
4@@ -20,6 +20,9 @@
5 Bug Fixes
6 *********
7
8+* ``bzr annotate`` on another branch with ``-r branch:...`` no longer
9+ fails with an ``ObjectNotLocked`` error. (Andrew Bennetts, #496590)
10+
11 * ``bzr export dir`` now requests all file content as a record stream,
12 rather than requsting the file content one file-at-a-time. This can make
13 exporting over the network significantly faster (54min => 9min in one
14
15=== modified file 'bzrlib/builtins.py'
16--- bzrlib/builtins.py 2009-10-29 05:49:32 +0000
17+++ bzrlib/builtins.py 2010-01-07 12:37:18 +0000
18@@ -4409,21 +4409,25 @@
19 branch.lock_read()
20 try:
21 tree = _get_one_revision_tree('annotate', revision, branch=branch)
22- if wt is not None:
23- file_id = wt.path2id(relpath)
24- else:
25- file_id = tree.path2id(relpath)
26- if file_id is None:
27- raise errors.NotVersionedError(filename)
28- file_version = tree.inventory[file_id].revision
29- if wt is not None and revision is None:
30- # If there is a tree and we're not annotating historical
31- # versions, annotate the working tree's content.
32- annotate_file_tree(wt, file_id, self.outf, long, all,
33- show_ids=show_ids)
34- else:
35- annotate_file(branch, file_version, file_id, long, all, self.outf,
36- show_ids=show_ids)
37+ tree.lock_read()
38+ try:
39+ if wt is not None:
40+ file_id = wt.path2id(relpath)
41+ else:
42+ file_id = tree.path2id(relpath)
43+ if file_id is None:
44+ raise errors.NotVersionedError(filename)
45+ file_version = tree.inventory[file_id].revision
46+ if wt is not None and revision is None:
47+ # If there is a tree and we're not annotating historical
48+ # versions, annotate the working tree's content.
49+ annotate_file_tree(wt, file_id, self.outf, long, all,
50+ show_ids=show_ids)
51+ else:
52+ annotate_file(branch, file_version, file_id, long, all,
53+ self.outf, show_ids=show_ids)
54+ finally:
55+ tree.unlock()
56 finally:
57 if wt is not None:
58 wt.unlock()
59
60=== modified file 'bzrlib/tests/blackbox/test_annotate.py'
61--- bzrlib/tests/blackbox/test_annotate.py 2009-03-23 14:59:43 +0000
62+++ bzrlib/tests/blackbox/test_annotate.py 2010-01-07 12:37:18 +0000
63@@ -29,6 +29,7 @@
64 from bzrlib.branch import Branch
65 from bzrlib.config import extract_email_address
66 from bzrlib.tests import TestCaseWithTransport
67+from bzrlib.urlutils import joinpath
68
69
70 class TestAnnotate(TestCaseWithTransport):
71@@ -153,14 +154,27 @@
72 class TestSimpleAnnotate(TestCaseWithTransport):
73 """Annotate tests with no complex setup."""
74
75- def _setup_edited_file(self):
76+ def _setup_edited_file(self, relpath='.'):
77 """Create a tree with a locally edited file."""
78- tree = self.make_branch_and_tree('.')
79- self.build_tree_contents([('file', 'foo\ngam\n')])
80+ tree = self.make_branch_and_tree(relpath)
81+ file_relpath = joinpath(relpath, 'file')
82+ self.build_tree_contents([(file_relpath, 'foo\ngam\n')])
83 tree.add('file')
84 tree.commit('add file', committer="test@host", rev_id="rev1")
85- self.build_tree_contents([('file', 'foo\nbar\ngam\n')])
86+ self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
87 tree.branch.get_config().set_user_option('email', 'current@host2')
88+ return tree
89+
90+ def test_annotate_cmd_revspec_branch(self):
91+ tree = self._setup_edited_file('trunk')
92+ tree.branch.create_checkout(self.get_url('work'), lightweight=True)
93+ os.chdir('work')
94+ out, err = self.run_bzr('annotate file -r branch:../trunk')
95+ self.assertEqual('', err)
96+ self.assertEqual(
97+ '1 test@ho | foo\n'
98+ ' | gam\n',
99+ out)
100
101 def test_annotate_edited_file(self):
102 tree = self._setup_edited_file()

Subscribers

People subscribed via source and target branches