~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_locking.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Test locks across all branch implemenations"""
18
18
 
32
32
 
33
33
    def get_instrumented_branch(self):
34
34
        """Get a Branch object which has been instrumented"""
35
 
        # TODO: jam 20060630 It may be that not all formats have a 
 
35
        # TODO: jam 20060630 It may be that not all formats have a
36
36
        # 'control_files' member. So we should fail gracefully if
37
 
        # not there. But assuming it has them lets us test the exact 
 
37
        # not there. But assuming it has them lets us test the exact
38
38
        # lock/unlock order.
39
39
        self.locks = []
40
40
        b = LockWrapper(self.locks, self.get_branch(), 'b')
54
54
        if self.combined_control:
55
55
            # instrument the repository control files too to ensure its worked
56
56
            # with correctly. When they are not shared, we trust the repository
57
 
            # API and only instrument the repository itself. 
 
57
            # API and only instrument the repository itself.
58
58
            b.repository.control_files = \
59
59
                LockWrapper(self.locks, b.repository.control_files, 'rc')
60
60
        return b
146
146
                self.assertFalse(b.is_locked())
147
147
            self.assertTrue(b.repository.is_locked())
148
148
 
149
 
            # We unlock the branch control files, even if 
 
149
            # We unlock the branch control files, even if
150
150
            # we fail to unlock the repository
151
151
            if self.combined_control:
152
152
                self.assertEqual([('b', 'lw', True),
188
188
            else:
189
189
                self.assertFalse(b.repository.is_locked())
190
190
 
191
 
            # We unlock the repository even if 
 
191
            # We unlock the repository even if
192
192
            # we fail to unlock the control files
193
193
            if self.combined_control:
194
194
                self.assertEqual([('b', 'lw', True),
223
223
        self.assertFalse(b.repository.is_locked())
224
224
 
225
225
        self.assertEqual([('b', 'lr', True),
226
 
                          ('r', 'lr', False), 
 
226
                          ('r', 'lr', False),
227
227
                         ], self.locks)
228
228
 
229
229
    def test_06_lock_write_fail_repo(self):
236
236
        self.assertFalse(b.repository.is_locked())
237
237
 
238
238
        self.assertEqual([('b', 'lw', True),
239
 
                          ('r', 'lw', False), 
 
239
                          ('r', 'lw', False),
240
240
                         ], self.locks)
241
241
 
242
242
    def test_07_lock_read_fail_control(self):