~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/lock_helpers.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Helper functions/classes for testing locking"""
18
18
 
19
19
from bzrlib import errors
20
 
from bzrlib.decorators import only_raises
21
20
 
22
21
 
23
22
class TestPreventLocking(errors.LockError):
45
44
        self.__dict__['_allow_read'] = True
46
45
        self.__dict__['_allow_unlock'] = True
47
46
 
48
 
    def __eq__(self, other):
49
 
        # Branch objects look for controlfiles == repo.controlfiles.
50
 
        if type(other) is LockWrapper:
51
 
            return self._other == other._other
52
 
        return False
53
 
 
54
47
    def __getattr__(self, attr):
55
48
        return getattr(self._other, attr)
56
49
 
63
56
            return self._other.lock_read()
64
57
        raise TestPreventLocking('lock_read disabled')
65
58
 
66
 
    def lock_write(self, token=None):
 
59
    def lock_write(self):
67
60
        self._sequence.append((self._other_id, 'lw', self._allow_write))
68
61
        if self._allow_write:
69
62
            return self._other.lock_write()
70
63
        raise TestPreventLocking('lock_write disabled')
71
64
 
72
 
    @only_raises(errors.LockNotHeld, errors.LockBroken)
73
65
    def unlock(self):
74
66
        self._sequence.append((self._other_id, 'ul', self._allow_unlock))
75
67
        if self._allow_unlock: