bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4543.2.2
by John Arbash Meinel
work out some tests that expose that bundles don't work w/ 2a formats. |
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 how merge directives interact with various repository formats.
|
|
18 |
||
19 |
Bundles contain the serialized form, so changes in serialization based on
|
|
20 |
repository effects the final bundle.
|
|
21 |
"""
|
|
22 |
||
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
23 |
from breezy import ( |
4543.2.2
by John Arbash Meinel
work out some tests that expose that bundles don't work w/ 2a formats. |
24 |
chk_map, |
25 |
merge_directive, |
|
6127.1.7
by Jelmer Vernooij
Move test_merge_directive to per_repository_vf. |
26 |
)
|
27 |
||
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
28 |
from breezy.tests.scenarios import load_tests_apply_scenarios |
29 |
from breezy.tests.per_repository_vf import ( |
|
6127.1.7
by Jelmer Vernooij
Move test_merge_directive to per_repository_vf. |
30 |
TestCaseWithRepository, |
31 |
all_repository_vf_format_scenarios, |
|
32 |
)
|
|
33 |
||
34 |
load_tests = load_tests_apply_scenarios |
|
4543.2.2
by John Arbash Meinel
work out some tests that expose that bundles don't work w/ 2a formats. |
35 |
|
36 |
||
37 |
class TestMergeDirective(TestCaseWithRepository): |
|
38 |
||
6127.1.7
by Jelmer Vernooij
Move test_merge_directive to per_repository_vf. |
39 |
scenarios = all_repository_vf_format_scenarios() |
40 |
||
4543.2.2
by John Arbash Meinel
work out some tests that expose that bundles don't work w/ 2a formats. |
41 |
def make_two_branches(self): |
42 |
builder = self.make_branch_builder('source') |
|
43 |
builder.start_series() |
|
44 |
builder.build_snapshot('A', None, [ |
|
45 |
('add', ('', 'root-id', 'directory', None)), |
|
46 |
('add', ('f', 'f-id', 'file', 'initial content\n')), |
|
47 |
])
|
|
48 |
builder.build_snapshot('B', 'A', [ |
|
49 |
('modify', ('f-id', 'new content\n')), |
|
50 |
])
|
|
51 |
builder.finish_series() |
|
52 |
b1 = builder.get_branch() |
|
53 |
b2 = b1.bzrdir.sprout('target', revision_id='A').open_branch() |
|
54 |
return b1, b2 |
|
55 |
||
56 |
def create_merge_directive(self, source_branch, submit_url): |
|
57 |
return merge_directive.MergeDirective2.from_objects( |
|
58 |
source_branch.repository, |
|
59 |
source_branch.last_revision(), |
|
60 |
time=1247775710, timezone=0, |
|
61 |
target_branch=submit_url) |
|
62 |
||
63 |
def test_create_merge_directive(self): |
|
64 |
source_branch, target_branch = self.make_two_branches() |
|
65 |
directive = self.create_merge_directive(source_branch, |
|
66 |
target_branch.base) |
|
67 |
self.assertIsInstance(directive, merge_directive.MergeDirective2) |
|
68 |
||
69 |
||
70 |
def test_create_and_install_directive(self): |
|
71 |
source_branch, target_branch = self.make_two_branches() |
|
72 |
directive = self.create_merge_directive(source_branch, |
|
73 |
target_branch.base) |
|
74 |
chk_map.clear_cache() |
|
75 |
directive.install_revisions(target_branch.repository) |
|
76 |
rt = target_branch.repository.revision_tree('B') |
|
77 |
rt.lock_read() |
|
78 |
self.assertEqualDiff('new content\n', rt.get_file_text('f-id')) |
|
79 |
rt.unlock() |