~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_dpush.py

  • Committer: Martin Pool
  • Date: 2005-06-28 05:33:40 UTC
  • Revision ID: mbp@sourcefrog.net-20050628053340-ea73b03fbcde9c46
- Remove XMLMixin class in favour of simple pack_xml, unpack_xml functions
  called as needed.  

- Avoid importing xml and ElementTree library unless needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010, 2011 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
 
 
18
 
"""Black-box tests for bzr dpush."""
19
 
 
20
 
 
21
 
from bzrlib import (
22
 
    tests,
23
 
    )
24
 
from bzrlib.tests import (
25
 
    script,
26
 
    test_foreign,
27
 
    )
28
 
from bzrlib.tests.blackbox import test_push
29
 
from bzrlib.tests.scenarios import (
30
 
    load_tests_apply_scenarios,
31
 
    )
32
 
 
33
 
 
34
 
load_tests = load_tests_apply_scenarios
35
 
 
36
 
 
37
 
class TestDpush(tests.TestCaseWithTransport):
38
 
 
39
 
    def setUp(self):
40
 
        super(TestDpush, self).setUp()
41
 
        test_foreign.register_dummy_foreign_for_test(self)
42
 
 
43
 
    def make_dummy_builder(self, relpath):
44
 
        builder = self.make_branch_builder(
45
 
            relpath, format=test_foreign.DummyForeignVcsDirFormat())
46
 
        builder.build_snapshot('revid', None,
47
 
            [('add', ('', 'TREE_ROOT', 'directory', None)),
48
 
             ('add', ('foo', 'fooid', 'file', 'bar'))])
49
 
        return builder
50
 
 
51
 
    def test_dpush_native(self):
52
 
        target_tree = self.make_branch_and_tree("dp")
53
 
        source_tree = self.make_branch_and_tree("dc")
54
 
        output, error = self.run_bzr("dpush -d dc dp", retcode=3)
55
 
        self.assertEquals("", output)
56
 
        self.assertContainsRe(error,
57
 
            'in the same VCS, lossy push not necessary. Please use regular '
58
 
            'push.')
59
 
 
60
 
    def test_dpush(self):
61
 
        branch = self.make_dummy_builder('d').get_branch()
62
 
 
63
 
        dc = branch.bzrdir.sprout('dc', force_new_repo=True)
64
 
        self.build_tree(("dc/foo", "blaaaa"))
65
 
        dc.open_workingtree().commit('msg')
66
 
 
67
 
        script.run_script(self, """
68
 
            $ bzr dpush -d dc d
69
 
            2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
70
 
            2>This may take some time. Upgrade the repositories to the same format for better performance.
71
 
            2>Pushed up to revision 2.
72
 
            $ bzr status dc
73
 
            """)
74
 
 
75
 
    def test_dpush_new(self):
76
 
        b = self.make_dummy_builder('d').get_branch()
77
 
 
78
 
        dc = b.bzrdir.sprout('dc', force_new_repo=True)
79
 
        self.build_tree_contents([("dc/foofile", "blaaaa")])
80
 
        dc_tree = dc.open_workingtree()
81
 
        dc_tree.add("foofile")
82
 
        dc_tree.commit("msg")
83
 
 
84
 
        script.run_script(self, '''
85
 
            $ bzr dpush -d dc d
86
 
            2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
87
 
            2>This may take some time. Upgrade the repositories to the same format for better performance.
88
 
            2>Pushed up to revision 2.
89
 
            $ bzr revno dc
90
 
            2
91
 
            $ bzr status dc
92
 
            ''')
93
 
 
94
 
    def test_dpush_wt_diff(self):
95
 
        b = self.make_dummy_builder('d').get_branch()
96
 
 
97
 
        dc = b.bzrdir.sprout('dc', force_new_repo=True)
98
 
        self.build_tree_contents([("dc/foofile", "blaaaa")])
99
 
        dc_tree = dc.open_workingtree()
100
 
        dc_tree.add("foofile")
101
 
        newrevid = dc_tree.commit('msg')
102
 
 
103
 
        self.build_tree_contents([("dc/foofile", "blaaaal")])
104
 
        script.run_script(self, '''
105
 
            $ bzr dpush -d dc d --no-strict
106
 
            2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
107
 
            2>This may take some time. Upgrade the repositories to the same format for better performance.
108
 
            2>Pushed up to revision 2.
109
 
            ''')
110
 
        self.assertFileEqual("blaaaal", "dc/foofile")
111
 
        # if the dummy vcs wasn't that dummy we could uncomment the line below
112
 
        # self.assertFileEqual("blaaaa", "d/foofile")
113
 
        script.run_script(self, '''
114
 
            $ bzr status dc
115
 
            modified:
116
 
              foofile
117
 
            ''')
118
 
 
119
 
    def test_diverged(self):
120
 
        builder = self.make_dummy_builder('d')
121
 
 
122
 
        b = builder.get_branch()
123
 
 
124
 
        dc = b.bzrdir.sprout('dc', force_new_repo=True)
125
 
        dc_tree = dc.open_workingtree()
126
 
 
127
 
        self.build_tree_contents([("dc/foo", "bar")])
128
 
        dc_tree.commit('msg1')
129
 
 
130
 
        builder.build_snapshot('revid2', None,
131
 
          [('modify', ('fooid', 'blie'))])
132
 
 
133
 
        output, error = self.run_bzr("dpush -d dc d", retcode=3)
134
 
        self.assertEquals(output, "")
135
 
        self.assertContainsRe(error, "have diverged")
136
 
 
137
 
 
138
 
class TestDpushStrictMixin(object):
139
 
 
140
 
    def setUp(self):
141
 
        test_foreign.register_dummy_foreign_for_test(self)
142
 
        # Create an empty branch where we will be able to push
143
 
        self.foreign = self.make_branch(
144
 
            'to', format=test_foreign.DummyForeignVcsDirFormat())
145
 
 
146
 
    def set_config_push_strict(self, value):
147
 
        # set config var (any of bazaar.conf, locations.conf, branch.conf
148
 
        # should do)
149
 
        conf = self.tree.branch.get_config_stack()
150
 
        conf.set('dpush_strict', value)
151
 
 
152
 
    _default_command = ['dpush', '../to']
153
 
 
154
 
 
155
 
class TestDpushStrictWithoutChanges(TestDpushStrictMixin,
156
 
                                    test_push.TestPushStrictWithoutChanges):
157
 
 
158
 
    def setUp(self):
159
 
        test_push.TestPushStrictWithoutChanges.setUp(self)
160
 
        TestDpushStrictMixin.setUp(self)
161
 
 
162
 
 
163
 
class TestDpushStrictWithChanges(TestDpushStrictMixin,
164
 
                                 test_push.TestPushStrictWithChanges):
165
 
 
166
 
    scenarios = test_push.strict_push_change_scenarios
167
 
 
168
 
    _changes_type = None # Set by load_tests
169
 
 
170
 
    def setUp(self):
171
 
        test_push.TestPushStrictWithChanges.setUp(self)
172
 
        TestDpushStrictMixin.setUp(self)
173
 
 
174
 
    def test_push_with_revision(self):
175
 
        raise tests.TestNotApplicable('dpush does not handle --revision')