~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_repository_reference/test_unlock.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Canonical Ltd
2
 
#
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.
7
 
#
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.
12
 
#
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
16
 
 
17
 
"""Tests for locking/unlocking a repository with external references."""
18
 
 
19
 
from bzrlib import (
20
 
    branch,
21
 
    errors,
22
 
    )
23
 
from bzrlib.tests.per_repository_reference import (
24
 
    TestCaseWithExternalReferenceRepository,
25
 
    )
26
 
 
27
 
 
28
 
class TestUnlock(TestCaseWithExternalReferenceRepository):
29
 
 
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()
46
 
        source_b.lock_read()
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')
53
 
 
54
 
        return base, stacked
55
 
 
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())
65
 
        repo.lock_read()
66
 
        self.assertTrue(repo.is_locked())
67
 
        self.assertTrue(fallback_repo.is_locked())
68
 
        repo.unlock()
69
 
        self.assertFalse(repo.is_locked())
70
 
        self.assertFalse(fallback_repo.is_locked())
71
 
        repo.lock_write()
72
 
        self.assertTrue(repo.is_locked())
73
 
        self.assertTrue(fallback_repo.is_locked())
74
 
        repo.unlock()
75
 
        self.assertFalse(repo.is_locked())
76
 
        self.assertFalse(fallback_repo.is_locked())