~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2007-02-06 14:52:16 UTC
  • mfrom: (2266 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2268.
  • Revision ID: abentley@panoramicfeedback.com-20070206145216-fcpi8o3ufvuzwbp9
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
34
34
                  'YYYY-MM-DD HH:MM:SS +ZZZZ', string)
35
35
 
36
36
 
37
 
class TestDiff(ExternalBase):
 
37
class DiffBase(ExternalBase):
 
38
    """Base class with common setup method"""
38
39
 
39
40
    def make_example_branch(self):
40
41
        # FIXME: copied from test_too_much -- share elsewhere?
46
47
        tree.add(['goodbye'])
47
48
        tree.commit('setup')
48
49
 
 
50
 
 
51
class TestDiff(DiffBase):
 
52
 
49
53
    def test_diff(self):
50
54
        self.make_example_branch()
51
55
        file('hello', 'wt').write('hello world!')
114
118
        out, err = self.runbzr('diff does-not-exist', retcode=3)
115
119
        self.assertContainsRe(err, 'not versioned.*does-not-exist')
116
120
 
 
121
    def test_diff_illegal_revision_specifiers(self):
 
122
        out, err = self.runbzr('diff -r 1..23..123', retcode=3)
 
123
        self.assertContainsRe(err, 'one or two revision specifiers')
 
124
 
117
125
    def test_diff_unversioned(self):
118
126
        # Get an error when diffing a non-versioned file.
119
127
        # (Malone #3619)
230
238
        os.chdir('checkouts')
231
239
 
232
240
 
233
 
class TestDiffLabels(TestDiff):
 
241
class TestDiffLabels(DiffBase):
234
242
 
235
243
    def test_diff_label_removed(self):
236
244
        super(TestDiffLabels, self).make_example_branch()
258
266
        self.assertTrue("=== renamed file 'hello' => 'gruezi'" in diff[0])
259
267
 
260
268
 
261
 
class TestExternalDiff(TestDiff):
 
269
class TestExternalDiff(DiffBase):
262
270
 
263
271
    def test_external_diff(self):
264
272
        """Test that we can spawn an external diff process"""
272
280
            os.environ['BZR_PROGRESS_BAR'] = 'none'
273
281
            out, err = self.run_bzr_subprocess('diff', '-r', '1',
274
282
                                               '--diff-options', '-ub',
 
283
                                               universal_newlines=True,
275
284
                                               retcode=None)
276
285
        finally:
277
286
            if orig_progress is None:
289
298
                                   "+++ goodbye\t")
290
299
        self.assertEndsWith(out, "\n@@ -0,0 +1 @@\n"
291
300
                                 "+baz\n\n")
 
301
 
 
302
 
 
303
class TestDiffOutput(DiffBase):
 
304
 
 
305
    def test_diff_output(self):
 
306
        # check that output doesn't mangle line-endings
 
307
        self.make_example_branch()
 
308
        file('hello', 'wb').write('hello world!\n')
 
309
        output = self.run_bzr_subprocess('diff', retcode=1)[0]
 
310
        self.assert_('\n+hello world!\n' in output)