~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-07-05 01:04:27 UTC
  • mfrom: (2581.1.6 cleanup-runbzr)
  • Revision ID: pqm@pqm.ubuntu.com-20070705010427-0839hywgo4ioup2t
(mbp,vila) more run_bzr cleanups

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')
235
234
 
236
235
    def test_encoding_exact(self):
237
236
        tree1, tree2 = self.prepare_merge_directive()
238
237
        tree1.commit(u'messag\xe9')
239
 
        self.run_bzr('merge-directive', '../tree2') # no exception raised
 
238
        self.run_bzr('merge-directive ../tree2') # no exception raised