/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
3920.2.30 by Jelmer Vernooij
Review from John.
1
# Copyright (C) 2005, 2007, 2008, 2009 Canonical Ltd
3920.2.7 by Jelmer Vernooij
Add comments about dummy vcs.
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
3920.2.28 by Jelmer Vernooij
Fix FSF address.
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3920.2.7 by Jelmer Vernooij
Add comments about dummy vcs.
16
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
17
3920.2.7 by Jelmer Vernooij
Add comments about dummy vcs.
18
"""Black-box tests for bzr dpush."""
19
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
20
3920.2.30 by Jelmer Vernooij
Review from John.
21
import os
22
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
23
from bzrlib.branch import (
24
    Branch,
4347.2.1 by Jelmer Vernooij
Move dpush onto an InterBranch object.
25
    InterBranch,
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
26
    )
27
from bzrlib.bzrdir import (
28
    BzrDirFormat,
29
    )
30
from bzrlib.foreign import (
31
    ForeignBranch,
32
    ForeignRepository,
33
    )
34
from bzrlib.repository import (
35
    Repository,
36
    )
37
from bzrlib.tests.blackbox import (
38
    ExternalBase,
39
    )
40
from bzrlib.tests.test_foreign import (
41
    DummyForeignVcsDirFormat,
4347.2.1 by Jelmer Vernooij
Move dpush onto an InterBranch object.
42
    InterToDummyVcsBranch,
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
43
    )
3920.2.15 by Jelmer Vernooij
Add a DummyForeignVcsDir class.
44
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
45
46
class TestDpush(ExternalBase):
47
48
    def setUp(self):
3920.2.15 by Jelmer Vernooij
Add a DummyForeignVcsDir class.
49
        BzrDirFormat.register_control_format(DummyForeignVcsDirFormat)
4347.2.1 by Jelmer Vernooij
Move dpush onto an InterBranch object.
50
        InterBranch.register_optimiser(InterToDummyVcsBranch)
3920.2.30 by Jelmer Vernooij
Review from John.
51
        self.addCleanup(self.unregister_format)
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
52
        super(TestDpush, self).setUp()
53
3920.2.30 by Jelmer Vernooij
Review from John.
54
    def unregister_format(self):
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
55
        try:
3920.2.15 by Jelmer Vernooij
Add a DummyForeignVcsDir class.
56
            BzrDirFormat.unregister_control_format(DummyForeignVcsDirFormat)
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
57
        except ValueError:
58
            pass
4347.2.2 by Jelmer Vernooij
Rename dpush to lossy_push.
59
        InterBranch.unregister_optimiser(InterToDummyVcsBranch)
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
60
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
61
    def make_dummy_builder(self, relpath):
62
        builder = self.make_branch_builder(relpath, 
63
                format=DummyForeignVcsDirFormat())
64
        builder.build_snapshot('revid', None, 
65
            [('add', ('', 'TREE_ROOT', 'directory', None)),
66
             ('add', ('foo', 'fooid', 'file', 'bar'))])
67
        return builder
68
3920.2.18 by Jelmer Vernooij
make sure dpush between native branches fails.
69
    def test_dpush_native(self):
3920.2.30 by Jelmer Vernooij
Review from John.
70
        target_tree = self.make_branch_and_tree("dp")
71
        source_tree = self.make_branch_and_tree("dc")
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
72
        output, error = self.run_bzr("dpush -d dc dp", retcode=3)
73
        self.assertEquals("", output)
3920.2.18 by Jelmer Vernooij
make sure dpush between native branches fails.
74
        self.assertContainsRe(error, 'not a foreign branch, use regular push')
75
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
76
    def test_dpush(self):
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
77
        branch = self.make_dummy_builder('d').get_branch()
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
78
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
79
        dc = branch.bzrdir.sprout('dc', force_new_repo=True)
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
80
        self.build_tree(("dc/foo", "blaaaa"))
3920.2.32 by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested.
81
        dc.open_workingtree().commit('msg')
82
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
83
        self.check_output("", "dpush -d dc d")
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
84
        self.check_output("", "status dc")
85
86
    def test_dpush_new(self):
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
87
        branch = self.make_dummy_builder('d').get_branch()
88
89
        dc = branch.bzrdir.sprout('dc', force_new_repo=True)
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
90
        self.build_tree_contents([("dc/foofile", "blaaaa")])
3920.2.32 by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested.
91
        dc_tree = dc.open_workingtree()
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
92
        dc_tree.add("foofile")
93
        dc_tree.commit("msg")
3920.2.32 by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested.
94
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
95
        self.check_output("", "dpush -d dc d")
3920.2.20 by Jelmer Vernooij
Fix dpush tests.
96
        self.check_output("2\n", "revno dc")
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
97
        self.check_output("", "status dc")
98
99
    def test_dpush_wt_diff(self):
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
100
        branch = self.make_dummy_builder('d').get_branch()
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
101
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
102
        dc = branch.bzrdir.sprout('dc', force_new_repo=True)
3920.2.20 by Jelmer Vernooij
Fix dpush tests.
103
        self.build_tree_contents([("dc/foofile", "blaaaa")])
3920.2.32 by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested.
104
        dc_tree = dc.open_workingtree()
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
105
        dc_tree.add("foofile")
106
        newrevid = dc_tree.commit('msg')
3920.2.32 by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested.
107
3920.2.20 by Jelmer Vernooij
Fix dpush tests.
108
        self.build_tree_contents([("dc/foofile", "blaaaal")])
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
109
        self.check_output("", "dpush -d dc d")
3920.2.20 by Jelmer Vernooij
Fix dpush tests.
110
        self.assertFileEqual("blaaaal", "dc/foofile")
3920.2.10 by Jelmer Vernooij
More work trying to implement a dummy version control system.
111
        self.check_output('modified:\n  foofile\n', "status dc")
3920.2.20 by Jelmer Vernooij
Fix dpush tests.
112
113
    def test_diverged(self):
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
114
        builder = self.make_dummy_builder('d')
115
116
        branch = builder.get_branch()
117
118
        dc = branch.bzrdir.sprout('dc', force_new_repo=True)
3920.2.32 by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested.
119
        dc_tree = dc.open_workingtree()
3920.2.20 by Jelmer Vernooij
Fix dpush tests.
120
121
        self.build_tree_contents([("dc/foo", "bar")])
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
122
        dc_tree.commit('msg1')
3920.2.20 by Jelmer Vernooij
Fix dpush tests.
123
3920.2.33 by Jelmer Vernooij
Use branch_builder to create revisions in testsuite.
124
        builder.build_snapshot('revid2', None,
125
          [('modify', ('fooid', 'blie'))])
3920.2.20 by Jelmer Vernooij
Fix dpush tests.
126
3920.2.36 by Jelmer Vernooij
Fix tests after CommitBuilder changes.
127
        output, error = self.run_bzr("dpush -d dc d", retcode=3)
128
        self.assertEquals(output, "")
3920.2.20 by Jelmer Vernooij
Fix dpush tests.
129
        self.assertContainsRe(error, "have diverged")