Merge lp:~gagern/bzr/bug149270_RevisionSpec_branch_readonly into lp:bzr

Proposed by Martin von Gagern
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5325
Proposed branch: lp:~gagern/bzr/bug149270_RevisionSpec_branch_readonly
Merge into: lp:bzr
Diff against target: 56 lines (+27/-2)
2 files modified
bzrlib/revisionspec.py (+14/-2)
bzrlib/tests/blackbox/test_log.py (+13/-0)
To merge this branch: bzr merge lp:~gagern/bzr/bug149270_RevisionSpec_branch_readonly
Reviewer Review Type Date Requested Status
John A Meinel Approve
Martin Pool Approve
Review via email: mp+28486@code.launchpad.net

Commit message

Deal with branch: revision specs in readonly transactions

Description of the change

In the case of a read-only transaction, as set up by commands like log or status, using a branch: revision specification used to raise ReadOnlyError. This should fix things at least for those two commands. As far as I can tell, diff still works as well.

There might be other commands that aren't prepared to deal with revision specifications naming their own branch, and will therefore fail. Bug reports should be filed for these, including steps for reproduction, suitable for new blackbox tests. So far I have found no such command.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

That's good. It looks almost too simple, but if this does fix those bugs and doesn't break any fetch tests then I think we're good. Well done. Needs NEWS to merge.

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

I did some manual testing to confirm, but things seem to work as expected.

I've put a version of this into my own branch to add the NEWS entry and submitted to pqm via email.
  lp:///~jameinel/bzr/other/gagern-bug149270_RevisionSpec_branch_readonly

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/revisionspec.py'
--- bzrlib/revisionspec.py 2010-02-17 17:11:16 +0000
+++ bzrlib/revisionspec.py 2010-06-25 08:19:26 +0000
@@ -813,8 +813,14 @@
813 revision_b = other_branch.last_revision()813 revision_b = other_branch.last_revision()
814 if revision_b in (None, revision.NULL_REVISION):814 if revision_b in (None, revision.NULL_REVISION):
815 raise errors.NoCommits(other_branch)815 raise errors.NoCommits(other_branch)
816 # pull in the remote revisions so we can diff816 if branch is None:
817 branch.fetch(other_branch, revision_b)817 branch = other_branch
818 else:
819 try:
820 # pull in the remote revisions so we can diff
821 branch.fetch(other_branch, revision_b)
822 except errors.ReadOnlyError:
823 branch = other_branch
818 try:824 try:
819 revno = branch.revision_id_to_revno(revision_b)825 revno = branch.revision_id_to_revno(revision_b)
820 except errors.NoSuchRevision:826 except errors.NoSuchRevision:
@@ -840,6 +846,12 @@
840 raise errors.NoCommits(other_branch)846 raise errors.NoCommits(other_branch)
841 return other_branch.repository.revision_tree(last_revision)847 return other_branch.repository.revision_tree(last_revision)
842848
849 def needs_branch(self):
850 return False
851
852 def get_branch(self):
853 return self.spec
854
843855
844856
845class RevisionSpec_submit(RevisionSpec_ancestor):857class RevisionSpec_submit(RevisionSpec_ancestor):
846858
=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- bzrlib/tests/blackbox/test_log.py 2010-06-08 08:24:39 +0000
+++ bzrlib/tests/blackbox/test_log.py 2010-06-25 08:19:26 +0000
@@ -158,6 +158,19 @@
158 self.make_linear_branch()158 self.make_linear_branch()
159 self.assertLogRevnos(['-c1'], ['1'])159 self.assertLogRevnos(['-c1'], ['1'])
160160
161 def test_branch_revspec(self):
162 foo = self.make_branch_and_tree('foo')
163 bar = self.make_branch_and_tree('bar')
164 self.build_tree(['foo/foo.txt', 'bar/bar.txt'])
165 foo.add('foo.txt')
166 bar.add('bar.txt')
167 foo.commit(message='foo')
168 bar.commit(message='bar')
169 self.run_bzr('log -r branch:../bar', working_dir='foo')
170 self.assertEqual([bar.branch.get_rev_id(1)],
171 [r.rev.revision_id
172 for r in self.get_captured_revisions()])
173
161174
162class TestLogExcludeCommonAncestry(TestLogWithLogCatcher):175class TestLogExcludeCommonAncestry(TestLogWithLogCatcher):
163176