1
# Copyright (C) 2010 Canonical Ltd
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.
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.
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
from bzrlib.tests import (
30
class TestRevert(TestCaseInTempDir):
33
super(TestRevert, self).setUp()
35
def test_revert_tree_write_lock_and_branch_read_lock(self):
37
# install lock hooks to find out about cmd_revert's locking actions
40
lock.Lock.hooks.install_named_hook('lock_acquired',
41
locks_acquired.append, None)
42
lock.Lock.hooks.install_named_hook('lock_released',
43
locks_released.append, None)
45
# execute the revert command (There is nothing to actually revert,
46
# but locks are acquired either way.)
47
revert = builtins.cmd_revert()
50
# make sure that only one lock is acquired and released.
51
self.assertLength(1, locks_acquired)
52
self.assertLength(1, locks_released)
54
# make sure that the nonces are the same, since otherwise
55
# this would not be the same lock.
56
self.assertEqual(locks_acquired[0].details, locks_released[0].details)
58
# make sure that the locks are checkout locks.
59
self.assertEndsWith(locks_acquired[0].lock_url, "/checkout/lock")
60
self.assertEndsWith(locks_released[0].lock_url, "/checkout/lock")