/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_repository/test_merge_directive.py

  • Committer: Martin Pool
  • Date: 2009-08-20 05:02:45 UTC
  • mfrom: (4615 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4632.
  • Revision ID: mbp@sourcefrog.net-20090820050245-o7cw6nxrzh1eah8h
News for apport feature

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 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
 
 
23
from bzrlib import (
 
24
    chk_map,
 
25
    errors,
 
26
    merge_directive,
 
27
    tests,
 
28
    )
 
29
 
 
30
from bzrlib.tests.per_repository import TestCaseWithRepository
 
31
 
 
32
 
 
33
class TestMergeDirective(TestCaseWithRepository):
 
34
 
 
35
    def make_two_branches(self):
 
36
        builder = self.make_branch_builder('source')
 
37
        builder.start_series()
 
38
        builder.build_snapshot('A', None, [
 
39
            ('add', ('', 'root-id', 'directory', None)),
 
40
            ('add', ('f', 'f-id', 'file', 'initial content\n')),
 
41
            ])
 
42
        builder.build_snapshot('B', 'A', [
 
43
            ('modify', ('f-id', 'new content\n')),
 
44
            ])
 
45
        builder.finish_series()
 
46
        b1 = builder.get_branch()
 
47
        b2 = b1.bzrdir.sprout('target', revision_id='A').open_branch()
 
48
        return b1, b2
 
49
 
 
50
    def create_merge_directive(self, source_branch, submit_url):
 
51
        return merge_directive.MergeDirective2.from_objects(
 
52
            source_branch.repository,
 
53
            source_branch.last_revision(),
 
54
            time=1247775710, timezone=0,
 
55
            target_branch=submit_url)
 
56
 
 
57
    def test_create_merge_directive(self):
 
58
        source_branch, target_branch = self.make_two_branches()
 
59
        directive = self.create_merge_directive(source_branch,
 
60
                                                target_branch.base)
 
61
        self.assertIsInstance(directive, merge_directive.MergeDirective2)
 
62
 
 
63
 
 
64
    def test_create_and_install_directive(self):
 
65
        source_branch, target_branch = self.make_two_branches()
 
66
        directive = self.create_merge_directive(source_branch,
 
67
                                                target_branch.base)
 
68
        chk_map.clear_cache()
 
69
        directive.install_revisions(target_branch.repository)
 
70
        rt = target_branch.repository.revision_tree('B')
 
71
        rt.lock_read()
 
72
        self.assertEqualDiff('new content\n', rt.get_file_text('f-id'))
 
73
        rt.unlock()