Rev 4721: (andrew) Fix ObjectNotLocked error when doing 'bzr annotate -r in file:///home/pqm/archives/thelove/bzr/2.0/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Jan 8 01:08:43 GMT 2010
At file:///home/pqm/archives/thelove/bzr/2.0/
------------------------------------------------------------
revno: 4721 [merge]
revision-id: pqm at pqm.ubuntu.com-20100108010840-tywncpw4p715pwu4
parent: pqm at pqm.ubuntu.com-20100107085714-bfuh2lmk855sjexc
parent: andrew.bennetts at canonical.com-20100107123237-057kqy9tfwvuhnwy
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.0
timestamp: Fri 2010-01-08 01:08:40 +0000
message:
(andrew) Fix ObjectNotLocked error when doing 'bzr annotate -r
branch:...' (#496590)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_annotate.py testannotate.py-20051013044000-457f44801bfa9d39
=== modified file 'NEWS'
--- a/NEWS 2010-01-07 08:57:14 +0000
+++ b/NEWS 2010-01-08 01:08:40 +0000
@@ -20,6 +20,9 @@
Bug Fixes
*********
+* ``bzr annotate`` on another branch with ``-r branch:...`` no longer
+ fails with an ``ObjectNotLocked`` error. (Andrew Bennetts, #496590)
+
* ``bzr export dir`` now requests all file content as a record stream,
rather than requsting the file content one file-at-a-time. This can make
exporting over the network significantly faster (54min => 9min in one
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-10-29 05:49:32 +0000
+++ b/bzrlib/builtins.py 2009-12-16 22:26:56 +0000
@@ -4409,21 +4409,25 @@
branch.lock_read()
try:
tree = _get_one_revision_tree('annotate', revision, branch=branch)
- if wt is not None:
- file_id = wt.path2id(relpath)
- else:
- file_id = tree.path2id(relpath)
- if file_id is None:
- raise errors.NotVersionedError(filename)
- file_version = tree.inventory[file_id].revision
- if wt is not None and revision is None:
- # If there is a tree and we're not annotating historical
- # versions, annotate the working tree's content.
- annotate_file_tree(wt, file_id, self.outf, long, all,
- show_ids=show_ids)
- else:
- annotate_file(branch, file_version, file_id, long, all, self.outf,
- show_ids=show_ids)
+ tree.lock_read()
+ try:
+ if wt is not None:
+ file_id = wt.path2id(relpath)
+ else:
+ file_id = tree.path2id(relpath)
+ if file_id is None:
+ raise errors.NotVersionedError(filename)
+ file_version = tree.inventory[file_id].revision
+ if wt is not None and revision is None:
+ # If there is a tree and we're not annotating historical
+ # versions, annotate the working tree's content.
+ annotate_file_tree(wt, file_id, self.outf, long, all,
+ show_ids=show_ids)
+ else:
+ annotate_file(branch, file_version, file_id, long, all,
+ self.outf, show_ids=show_ids)
+ finally:
+ tree.unlock()
finally:
if wt is not None:
wt.unlock()
=== modified file 'bzrlib/tests/blackbox/test_annotate.py'
--- a/bzrlib/tests/blackbox/test_annotate.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_annotate.py 2010-01-07 12:32:37 +0000
@@ -29,6 +29,7 @@
from bzrlib.branch import Branch
from bzrlib.config import extract_email_address
from bzrlib.tests import TestCaseWithTransport
+from bzrlib.urlutils import joinpath
class TestAnnotate(TestCaseWithTransport):
@@ -153,14 +154,27 @@
class TestSimpleAnnotate(TestCaseWithTransport):
"""Annotate tests with no complex setup."""
- def _setup_edited_file(self):
+ def _setup_edited_file(self, relpath='.'):
"""Create a tree with a locally edited file."""
- tree = self.make_branch_and_tree('.')
- self.build_tree_contents([('file', 'foo\ngam\n')])
+ tree = self.make_branch_and_tree(relpath)
+ file_relpath = joinpath(relpath, 'file')
+ self.build_tree_contents([(file_relpath, 'foo\ngam\n')])
tree.add('file')
tree.commit('add file', committer="test at host", rev_id="rev1")
- self.build_tree_contents([('file', 'foo\nbar\ngam\n')])
+ self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
tree.branch.get_config().set_user_option('email', 'current at host2')
+ return tree
+
+ def test_annotate_cmd_revspec_branch(self):
+ tree = self._setup_edited_file('trunk')
+ tree.branch.create_checkout(self.get_url('work'), lightweight=True)
+ os.chdir('work')
+ out, err = self.run_bzr('annotate file -r branch:../trunk')
+ self.assertEqual('', err)
+ self.assertEqual(
+ '1 test at ho | foo\n'
+ ' | gam\n',
+ out)
def test_annotate_edited_file(self):
tree = self._setup_edited_file()
More information about the bazaar-commits
mailing list