/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4988.10.5 by John Arbash Meinel
Merge bzr.dev 5021 to resolve NEWS
1
# Copyright (C) 2006-2010 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1687.1.7 by Robert Collins
Teach Repository about break_lock.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1687.1.7 by Robert Collins
Teach Repository about break_lock.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1687.1.7 by Robert Collins
Teach Repository about break_lock.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1687.1.7 by Robert Collins
Teach Repository about break_lock.
16
17
"""Tests for repository break-lock."""
18
4985.1.5 by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity
19
from bzrlib import (
20
    errors,
21
    ui,
22
    )
5010.2.23 by Vincent Ladeuil
Fix imports in per_repository/test_break_lock.py.
23
from bzrlib.tests import per_repository
24
25
26
class TestBreakLock(per_repository.TestCaseWithRepository):
1687.1.7 by Robert Collins
Teach Repository about break_lock.
27
28
    def setUp(self):
29
        super(TestBreakLock, self).setUp()
30
        self.unused_repo = self.make_repository('.')
31
        self.repo = self.unused_repo.bzrdir.open_repository()
4985.1.5 by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity
32
        ui.ui_factory = ui.CannedInputUIFactory([True])
1687.1.7 by Robert Collins
Teach Repository about break_lock.
33
34
    def test_unlocked(self):
35
        # break lock when nothing is locked should just return
36
        try:
37
            self.repo.break_lock()
38
        except NotImplementedError:
39
            pass
40
41
    def test_locked(self):
42
        # break_lock when locked should
43
        self.repo.lock_write()
2592.3.188 by Robert Collins
Allow pack repositories to have multiple writers active at one time, for greater concurrency.
44
        self.assertEqual(self.repo.get_physical_lock_status(),
45
            self.unused_repo.get_physical_lock_status())
46
        if not self.unused_repo.get_physical_lock_status():
47
            # 'lock_write' has not taken a physical mutex out.
1687.1.7 by Robert Collins
Teach Repository about break_lock.
48
            self.repo.unlock()
49
            return
2592.3.188 by Robert Collins
Allow pack repositories to have multiple writers active at one time, for greater concurrency.
50
        self.unused_repo.break_lock()
1687.1.7 by Robert Collins
Teach Repository about break_lock.
51
        self.assertRaises(errors.LockBroken, self.repo.unlock)