1
# Copyright (C) 2009 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
17
"""Tests for locking/unlocking a repository with external references."""
23
from bzrlib.tests.per_repository_reference import (
24
TestCaseWithExternalReferenceRepository,
28
class TestUnlock(TestCaseWithExternalReferenceRepository):
30
def create_stacked_branch(self):
31
builder = self.make_branch_builder('source',
32
format=self.bzrdir_format)
33
builder.start_series()
34
repo = builder.get_branch().repository
35
if not repo._format.supports_external_lookups:
36
raise tests.TestNotApplicable('format does not support stacking')
37
builder.build_snapshot('A-id', None, [
38
('add', ('', 'root-id', 'directory', None)),
39
('add', ('file', 'file-id', 'file', 'contents\n'))])
40
builder.build_snapshot('B-id', ['A-id'], [
41
('modify', ('file-id', 'new-content\n'))])
42
builder.build_snapshot('C-id', ['B-id'], [
43
('modify', ('file-id', 'yet more content\n'))])
44
builder.finish_series()
45
source_b = builder.get_branch()
47
self.addCleanup(source_b.unlock)
48
base = self.make_branch('base')
49
base.pull(source_b, stop_revision='B-id')
50
stacked = self.make_branch('stacked')
51
stacked.set_stacked_on_url('../base')
52
stacked.pull(source_b, stop_revision='C-id')
56
def test_unlock_unlocks_fallback(self):
57
base = self.make_branch('base')
58
stacked = self.make_branch('stacked')
59
repo = stacked.repository
60
stacked.set_stacked_on_url('../base')
61
self.assertEqual(1, len(repo._fallback_repositories))
62
fallback_repo = repo._fallback_repositories[0]
63
self.assertFalse(repo.is_locked())
64
self.assertFalse(fallback_repo.is_locked())
66
self.assertTrue(repo.is_locked())
67
self.assertTrue(fallback_repo.is_locked())
69
self.assertFalse(repo.is_locked())
70
self.assertFalse(fallback_repo.is_locked())
72
self.assertTrue(repo.is_locked())
73
self.assertTrue(fallback_repo.is_locked())
75
self.assertFalse(repo.is_locked())
76
self.assertFalse(fallback_repo.is_locked())