~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2007-06-26 20:32:49 UTC
  • mto: (2581.1.1 cleanup-runbzr)
  • mto: This revision was merged to the branch mainline in revision 2588.
  • Revision ID: v.ladeuil+lp@free.fr-20070626203249-sqm4afiai5dxofum
Deprecate the varargs syntax and fix the tests.

* bzrlib/tests/__init__.py:
(TestCase.run_bzr): Activate the deprecation warning.
(TestCase.run_bzr_error): Add error_regexes to kwargs or run_bzr
get confused.

* bzrlib/tests/blackbox/test_selftest.py:
(TestRunBzr.test_args): Activate.

* bzrlib/tests/blackbox/test_inventory.py:
(TestInventory.assertInventoryEqual): Build the command from args
if not None.

* bzrlib/tests/blackbox/test_ls.py:
(TestLS.ls_equals): Build the command from args if not None.

* bzrlib/tests/blackbox/test_remove_tree.py:
(TestRemoveTree.test_remove_tree_lightweight_checkout_explicit):
Nice catch, we were calling run_bzr instead of run_bzr_error. This
went unnoticed for some time...

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 
55
55
    def test_merge_directive(self):
56
56
        self.prepare_merge_directive()
57
 
        md_text = self.run_bzr('merge-directive', '../tree2')[0]
 
57
        md_text = self.run_bzr('merge-directive ../tree2')[0]
58
58
        self.assertContainsRe(md_text, "\\+e")
59
 
        md_text = self.run_bzr('merge-directive', '-r', '-2', '../tree2')[0]
 
59
        md_text = self.run_bzr('merge-directive -r -2 ../tree2')[0]
60
60
        self.assertNotContainsRe(md_text, "\\+e")
61
61
 
62
62
    def test_submit_branch(self):
63
63
        self.prepare_merge_directive()
64
64
        self.run_bzr_error(('No submit branch',), 'merge-directive', retcode=3)
65
 
        self.run_bzr('merge-directive', '../tree2')
 
65
        self.run_bzr('merge-directive ../tree2')
66
66
 
67
67
    def test_public_branch(self):
68
68
        self.prepare_merge_directive()
69
 
        self.run_bzr_error(('No public branch',), 'merge-directive', '--diff',
70
 
                           '../tree2', retcode=3)
71
 
        md_text = self.run_bzr('merge-directive', '../tree2')[0]
 
69
        self.run_bzr_error(('No public branch',),
 
70
                           'merge-directive --diff ../tree2', retcode=3)
 
71
        md_text = self.run_bzr('merge-directive ../tree2')[0]
72
72
        self.assertNotContainsRe(md_text, 'source_branch:')
73
 
        self.run_bzr('merge-directive', '--diff', '../tree2', '.')
74
 
        self.run_bzr('merge-directive', '--diff')[0]
 
73
        self.run_bzr('merge-directive --diff ../tree2 .')
 
74
        self.run_bzr('merge-directive --diff')[0]
75
75
        self.assertNotContainsRe(md_text, 'source_branch:')
76
76
 
77
77
    def test_patch_types(self):
78
78
        self.prepare_merge_directive()
79
 
        md_text = self.run_bzr('merge-directive', '../tree2')[0]
 
79
        md_text = self.run_bzr('merge-directive ../tree2')[0]
80
80
        self.assertContainsRe(md_text, "Bazaar revision bundle")
81
81
        self.assertContainsRe(md_text, "\\+e")
82
 
        md_text = self.run_bzr('merge-directive', '../tree2', '--diff', '.')[0]
 
82
        md_text = self.run_bzr('merge-directive ../tree2 --diff .')[0]
83
83
        self.assertNotContainsRe(md_text, "Bazaar revision bundle")
84
84
        self.assertContainsRe(md_text, "\\+e")
85
 
        md_text = self.run_bzr('merge-directive', '--plain')[0]
 
85
        md_text = self.run_bzr('merge-directive --plain')[0]
86
86
        self.assertNotContainsRe(md_text, "\\+e")
87
87
 
88
88
    def test_message(self):
89
89
        self.prepare_merge_directive()
90
 
        md_text = self.run_bzr('merge-directive', '../tree2')[0]
 
90
        md_text = self.run_bzr('merge-directive ../tree2')[0]
91
91
        self.assertNotContainsRe(md_text, 'message: Message for merge')
92
 
        md_text = self.run_bzr('merge-directive', '-m', 'Message for merge')[0]
93
 
        self.assertContainsRe(md_text, 'message: Message for merge')
 
92
        md_text = self.run_bzr('merge-directive -m Message_for_merge')[0]
 
93
        self.assertContainsRe(md_text, 'message: Message_for_merge')
94
94
 
95
95
    def test_signing(self):
96
96
        self.prepare_merge_directive()
97
97
        old_strategy = gpg.GPGStrategy
98
98
        gpg.GPGStrategy = gpg.LoopbackGPGStrategy
99
99
        try:
100
 
            md_text = self.run_bzr('merge-directive', '--sign', '../tree2')[0]
 
100
            md_text = self.run_bzr('merge-directive --sign ../tree2')[0]
101
101
        finally:
102
102
            gpg.GPGStrategy = old_strategy
103
103
        self.assertContainsRe(md_text, '^-----BEGIN PSEUDO-SIGNED CONTENT')
128
128
    def test_mail_default(self):
129
129
        tree1, tree2 = self.prepare_merge_directive()
130
130
        md_text, errr, connect_calls, sendmail_calls =\
131
 
            self.run_bzr_fakemail('merge-directive', '--mail-to',
132
 
                                  'pqm@example.com', '--plain', '../tree2',
133
 
                                  '.')
 
131
            self.run_bzr_fakemail(['merge-directive', '--mail-to',
 
132
                                   'pqm@example.com', '--plain', '../tree2',
 
133
                                   '.'])
134
134
        self.assertEqual('', md_text)
135
135
        self.assertEqual(1, len(connect_calls))
136
136
        call = connect_calls[0]
144
144
    def test_pull_raw(self):
145
145
        self.prepare_merge_directive()
146
146
        self.tree1.commit('baz', rev_id='baz-id')
147
 
        md_text = self.run_bzr('merge-directive', self.tree2.basedir,
148
 
                               '-r', '2', self.tree1.basedir, '--plain')[0]
 
147
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
 
148
                                '-r', '2', self.tree1.basedir, '--plain'])[0]
149
149
        self.build_tree_contents([('../directive', md_text)])
150
150
        os.chdir('../tree2')
151
 
        self.run_bzr('pull', '../directive')
 
151
        self.run_bzr('pull ../directive')
152
152
        wt = workingtree.WorkingTree.open('.')
153
153
        self.assertEqual('bar-id', wt.last_revision())
154
154
 
156
156
        """If the user supplies -r, an error is emitted"""
157
157
        self.prepare_merge_directive()
158
158
        self.tree1.commit('baz', rev_id='baz-id')
159
 
        md_text = self.run_bzr('merge-directive', self.tree2.basedir,
160
 
                               self.tree1.basedir, '--plain')[0]
 
159
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
 
160
                                self.tree1.basedir, '--plain'])[0]
161
161
        self.build_tree_contents([('../directive', md_text)])
162
162
        os.chdir('../tree2')
163
163
        self.run_bzr_error(
164
164
            ('Cannot use -r with merge directives or bundles',),
165
 
            'pull', '-r', '2', '../directive')
 
165
            'pull -r 2 ../directive')
166
166
 
167
167
    def test_pull_bundle(self):
168
168
        self.prepare_merge_directive()
169
169
        self.tree1.commit('baz', rev_id='baz-id')
170
 
        md_text = self.run_bzr('merge-directive', self.tree2.basedir,
171
 
                               '-r', '2', '/dev/null', '--bundle')[0]
 
170
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
 
171
                                '-r', '2', '/dev/null', '--bundle'])[0]
172
172
        self.build_tree_contents([('../directive', md_text)])
173
173
        os.chdir('../tree2')
174
 
        self.run_bzr('pull', '../directive')
 
174
        self.run_bzr('pull ../directive')
175
175
        wt = workingtree.WorkingTree.open('.')
176
176
        self.assertEqual('bar-id', wt.last_revision())
177
177
 
178
178
    def test_merge_raw(self):
179
179
        self.prepare_merge_directive()
180
180
        self.tree1.commit('baz', rev_id='baz-id')
181
 
        md_text = self.run_bzr('merge-directive', self.tree2.basedir,
182
 
                               '-r', '2', self.tree1.basedir, '--plain')[0]
 
181
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
 
182
                                '-r', '2', self.tree1.basedir, '--plain'])[0]
183
183
        self.build_tree_contents([('../directive', md_text)])
184
184
        os.chdir('../tree2')
185
 
        self.run_bzr('merge', '../directive')
 
185
        self.run_bzr('merge ../directive')
186
186
        wt = workingtree.WorkingTree.open('.')
187
187
        self.assertEqual('bar-id', wt.get_parent_ids()[1])
188
188
 
190
190
        """If the user supplies -r, an error is emitted"""
191
191
        self.prepare_merge_directive()
192
192
        self.tree1.commit('baz', rev_id='baz-id')
193
 
        md_text = self.run_bzr('merge-directive', self.tree2.basedir,
194
 
                               self.tree1.basedir, '--plain')[0]
 
193
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
 
194
                                self.tree1.basedir, '--plain'])[0]
195
195
        self.build_tree_contents([('../directive', md_text)])
196
196
        os.chdir('../tree2')
197
197
        self.run_bzr_error(
198
198
            ('Cannot use -r with merge directives or bundles',),
199
 
            'merge', '-r', '2', '../directive')
 
199
            'merge -r 2 ../directive')
200
200
 
201
201
    def test_merge_bundle(self):
202
202
        self.prepare_merge_directive()
203
203
        self.tree1.commit('baz', rev_id='baz-id')
204
 
        md_text = self.run_bzr('merge-directive', self.tree2.basedir,
205
 
                               '-r', '2', '/dev/null', '--bundle')[0]
 
204
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
 
205
                               '-r', '2', '/dev/null', '--bundle'])[0]
206
206
        self.build_tree_contents([('../directive', md_text)])
207
207
        os.chdir('../tree2')
208
 
        self.run_bzr('merge', '../directive')
 
208
        self.run_bzr('merge ../directive')
209
209
        wt = workingtree.WorkingTree.open('.')
210
210
        self.assertEqual('bar-id', wt.get_parent_ids()[1])
211
211
 
213
213
        tree1, tree2 = self.prepare_merge_directive()
214
214
        tree1.branch.get_config().set_user_option('smtp_server', 'bogushost')
215
215
        md_text, errr, connect_calls, sendmail_calls =\
216
 
            self.run_bzr_fakemail('merge-directive', '--mail-to',
217
 
                                  'pqm@example.com', '--plain', '../tree2',
218
 
                                  '.')
 
216
            self.run_bzr_fakemail('merge-directive --mail-to'
 
217
                                  ' pqm@example.com --plain ../tree2 .')
219
218
        call = connect_calls[0]
220
219
        self.assertEqual(('bogushost', 0), call[1:3])
221
220
 
224
223
        foo.commit('rev1')
225
224
        bar = self.make_branch_and_tree('bar')
226
225
        os.chdir('foo')
227
 
        self.run_bzr('merge-directive', '../bar')
 
226
        self.run_bzr('merge-directive ../bar')
228
227
 
229
228
    def test_no_commits(self):
230
229
        foo = self.make_branch_and_tree('foo')
231
230
        bar = self.make_branch_and_tree('bar')
232
231
        os.chdir('foo')
233
232
        self.run_bzr_error(('No revisions to bundle.', ),
234
 
                            'merge-directive', '../bar')
 
233
                            'merge-directive ../bar')