/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 breezy/tests/blackbox/test_dpush.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

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