~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
 
142
142
    def example_branches(self):
143
143
        self.build_tree(['branch1/', 'branch1/file'], line_endings='binary')
144
 
        self.run_bzr(['init', 'branch1'])[0]
145
 
        self.run_bzr(['add', 'branch1/file'])[0]
 
144
        self.run_bzr('init branch1')[0]
 
145
        self.run_bzr('add branch1/file')[0]
146
146
        self.run_bzr(['commit', '-m', 'add file', 'branch1'])
147
 
        self.run_bzr(['branch', 'branch1', 'branch2'])[0]
 
147
        self.run_bzr('branch branch1 branch2')[0]
148
148
        self.build_tree_contents([('branch2/file', 'new content\n')])
149
149
        self.run_bzr(['commit', '-m', 'update file', 'branch2'])
150
150
 
151
151
    def test_diff_branches(self):
152
152
        self.example_branches()
153
153
        # should open branch1 and diff against branch2, 
154
 
        out, err = self.run_bzr(['diff', '-r', 'branch:branch2', 
155
 
                                          'branch1'],
156
 
                                         retcode=1)
 
154
        out, err = self.run_bzr('diff -r branch:branch2 branch1',
 
155
                                retcode=1)
157
156
        self.assertEquals('', err)
158
157
        self.assertEquals("=== modified file 'file'\n"
159
158
                          "--- file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
162
161
                          "-new content\n"
163
162
                          "+contents of branch1/file\n"
164
163
                          "\n", subst_dates(out))
165
 
        out, err = self.run_bzr(['diff', 'branch2', 'branch1'],
 
164
        out, err = self.run_bzr('diff branch2 branch1',
166
165
                                         retcode=1)
167
166
        self.assertEquals('', err)
168
167
        self.assertEqualDiff("=== modified file 'file'\n"
176
175
    def test_diff_revno_branches(self):
177
176
        self.example_branches()
178
177
        print >> open('branch2/file', 'wb'), 'even newer content'
179
 
        self.run_bzr(['commit', '-m', 
180
 
                               'update file once more', 'branch2'])
 
178
        self.run_bzr(['commit', '-m',
 
179
                      'update file once more', 'branch2'])
181
180
 
182
 
        out, err = self.run_bzr(['diff', '-r',
183
 
                                          'revno:1:branch2..revno:1:branch1'],
184
 
                                         retcode=0)
 
181
        out, err = self.run_bzr('diff -r revno:1:branch2..revno:1:branch1',
 
182
                                )
185
183
        self.assertEquals('', err)
186
184
        self.assertEquals('', out)
187
 
        out, err = self.run_bzr(['diff', '-r', 
188
 
                                          'revno:2:branch2..revno:1:branch1'],
189
 
                                         retcode=1)
 
185
        out, err = self.run_bzr('diff -r revno:2:branch2..revno:1:branch1',
 
186
                                retcode=1)
190
187
        self.assertEquals('', err)
191
188
        self.assertEqualDiff("=== modified file 'file'\n"
192
189
                              "--- file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
198
195
 
199
196
    def example_branch2(self):
200
197
        self.build_tree(['branch1/', 'branch1/file1'], line_endings='binary')
201
 
        self.run_bzr(['init', 'branch1'])[0]
202
 
        self.run_bzr(['add', 'branch1/file1'])[0]
 
198
        self.run_bzr('init branch1')[0]
 
199
        self.run_bzr('add branch1/file1')[0]
203
200
        print >> open('branch1/file1', 'wb'), 'original line'
204
201
        self.run_bzr(['commit', '-m', 'first commit', 'branch1'])
205
202
        
210
207
        self.example_branch2()
211
208
        
212
209
        print >> open('branch1/file1', 'wb'), 'new line'
213
 
        output = self.run_bzr(['diff', '-r', '1..', 'branch1'],
214
 
                                       retcode=1)
 
210
        output = self.run_bzr('diff -r 1.. branch1',
 
211
                              retcode=1)
215
212
        self.assertTrue('\n-original line\n+new line\n' in output[0])
216
213
 
217
214
    def test_diff_across_rename(self):
218
215
        """The working tree path should always be considered for diffing"""
219
216
        self.make_example_branch()
220
 
        self.run_bzr('diff', '-r', '0..1', 'hello', retcode=1)
 
217
        self.run_bzr('diff -r 0..1 hello', retcode=1)
221
218
        wt = workingtree.WorkingTree.open_containing('.')[0]
222
219
        wt.rename_one('hello', 'hello1')
223
 
        self.run_bzr('diff', 'hello1', retcode=1)
224
 
        self.run_bzr('diff', '-r', '0..1', 'hello1', retcode=1)
 
220
        self.run_bzr('diff hello1', retcode=1)
 
221
        self.run_bzr('diff -r 0..1 hello1', retcode=1)
225
222
 
226
223
 
227
224
class TestCheckoutDiff(TestDiff):
250
247
    def test_diff_label_removed(self):
251
248
        super(TestDiffLabels, self).make_example_branch()
252
249
        self.run_bzr('remove hello')
253
 
        diff = self.run_bzr(['diff'], retcode=1)
 
250
        diff = self.run_bzr('diff', retcode=1)
254
251
        self.assertTrue("=== removed file 'hello'" in diff[0])
255
252
 
256
253
    def test_diff_label_added(self):
257
254
        super(TestDiffLabels, self).make_example_branch()
258
255
        file('barbar', 'wt').write('barbar')
259
256
        self.run_bzr('add barbar')
260
 
        diff = self.run_bzr(['diff'], retcode=1)
 
257
        diff = self.run_bzr('diff', retcode=1)
261
258
        self.assertTrue("=== added file 'barbar'" in diff[0])
262
259
 
263
260
    def test_diff_label_modified(self):
264
261
        super(TestDiffLabels, self).make_example_branch()
265
262
        file('hello', 'wt').write('barbar')
266
 
        diff = self.run_bzr(['diff'], retcode=1)
 
263
        diff = self.run_bzr('diff', retcode=1)
267
264
        self.assertTrue("=== modified file 'hello'" in diff[0])
268
265
 
269
266
    def test_diff_label_renamed(self):
270
267
        super(TestDiffLabels, self).make_example_branch()
271
268
        self.run_bzr('rename hello gruezi')
272
 
        diff = self.run_bzr(['diff'], retcode=1)
 
269
        diff = self.run_bzr('diff', retcode=1)
273
270
        self.assertTrue("=== renamed file 'hello' => 'gruezi'" in diff[0])
274
271
 
275
272