Rev 5242: (andrew) Fix AttributeError in RemoteBranch.lock_write after in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu May 20 06:43:47 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5242 [merge]
revision-id: pqm at pqm.ubuntu.com-20100520054344-xrqni611g1280mgb
parent: pqm at pqm.ubuntu.com-20100519151219-b1agjbkntjbirf92
parent: andrew.bennetts at canonical.com-20100520032004-2gzmkqwjkqb6f82p
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-05-20 06:43:44 +0100
message:
  (andrew) Fix AttributeError in RemoteBranch.lock_write after
  	lock_read. (#582781)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/per_branch/test_locking.py test_locking.py-20060707151933-tav3o2hpibwi53u4-4
=== modified file 'NEWS'
--- a/NEWS	2010-05-19 02:58:05 +0000
+++ b/NEWS	2010-05-20 03:20:04 +0000
@@ -108,6 +108,10 @@
 * Reduce peak memory by one copy of compressed text.
   (John Arbash Meinel, #566940)
 
+* ``RemoteBranch.lock_write`` raises ``ReadOnlyError`` if called during a
+  read lock, rather than causing an ``AttributeError``.
+  (Andrew Bennetts, Данило Шеган, #582781)
+
 * Selftest was failing with testtools 0.9.3, which caused an
   AssertionError raised from a cleanUp to be reported as a Failure, not an
   Error, breaking on of our test hygiene tests.

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2010-05-14 12:40:03 +0000
+++ b/bzrlib/remote.py	2010-05-20 03:20:04 +0000
@@ -2449,7 +2449,7 @@
             self._lock_mode = 'w'
             self._lock_count = 1
         elif self._lock_mode == 'r':
-            raise errors.ReadOnlyTransaction
+            raise errors.ReadOnlyError(self)
         else:
             if token is not None:
                 # A token was given to lock_write, and we're relocking, so

=== modified file 'bzrlib/tests/per_branch/test_locking.py'
--- a/bzrlib/tests/per_branch/test_locking.py	2010-05-06 23:41:35 +0000
+++ b/bzrlib/tests/per_branch/test_locking.py	2010-05-20 03:20:04 +0000
@@ -419,10 +419,6 @@
         new_branch.lock_write()
         new_branch.unlock()
 
-    def test_lock_write_returns_unlockable(self):
-        branch = self.make_branch('b')
-        self.assertThat(branch.lock_write, ReturnsUnlockable(branch))
-
     def test_leave_lock_in_place(self):
         branch = self.make_branch('b')
         # Lock the branch, then use leave_lock_in_place so that when we
@@ -534,6 +530,11 @@
         branch = self.make_branch('b')
         self.assertThat(branch.lock_write, ReturnsUnlockable(branch))
 
+    def test_lock_write_raises_in_lock_read(self):
+        branch = self.make_branch('b')
+        branch.lock_read()
+        err = self.assertRaises(errors.ReadOnlyError, branch.lock_write)
+
     def test_lock_and_unlock_leaves_repo_unlocked(self):
         branch = self.make_branch('b')
         branch.lock_write()




More information about the bazaar-commits mailing list