~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2007-06-26 08:02:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2555.
  • Revision ID: mbp@sourcefrog.net-20070626080236-14ihgomtffc9tezj
Cleanup old variations on run_bzr in the test suite

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
    def test_diff(self):
54
54
        self.make_example_branch()
55
55
        file('hello', 'wt').write('hello world!')
56
 
        self.runbzr('commit -m fixing hello')
57
 
        output = self.runbzr('diff -r 2..3', backtick=1, retcode=1)
 
56
        self.run_bzr('commit -m fixing hello')
 
57
        output = self.run_bzr_captured('diff -r 2..3', retcode=1)[0]
58
58
        self.assert_('\n+hello world!' in output)
59
 
        output = self.runbzr('diff -r last:3..last:1', backtick=1, retcode=1)
 
59
        output = self.run_bzr_captured('diff -r last:3..last:1',
 
60
                retcode=1)[0]
60
61
        self.assert_('\n+baz' in output)
61
 
        file('moo', 'wb').write('moo')
62
 
        self.runbzr('add moo')
 
62
        self.build_tree(['moo'])
 
63
        self.run_bzr('add moo')
63
64
        os.unlink('moo')
64
 
        self.runbzr('diff')
 
65
        self.run_bzr('diff')
65
66
 
66
67
    def test_diff_prefix(self):
67
68
        """diff --prefix appends to filenames in output"""
68
69
        self.make_example_branch()
69
70
        file('hello', 'wb').write('hello world!\n')
70
 
        out, err = self.runbzr('diff --prefix old/:new/', retcode=1)
 
71
        out, err = self.run_bzr('diff --prefix old/:new/', retcode=1)
71
72
        self.assertEquals(err, '')
72
73
        self.assertEqualDiff(subst_dates(out), '''\
73
74
=== modified file 'hello'
81
82
 
82
83
    def test_diff_illegal_prefix_value(self):
83
84
        # There was an error in error reporting for this option
84
 
        out, err = self.runbzr('diff --prefix old/', retcode=3)
 
85
        out, err = self.run_bzr('diff --prefix old/', retcode=3)
85
86
        self.assertContainsRe(err,
86
87
            '--prefix expects two values separated by a colon')
87
88
 
89
90
        """diff -p1 produces lkml-style diffs"""
90
91
        self.make_example_branch()
91
92
        file('hello', 'wb').write('hello world!\n')
92
 
        out, err = self.runbzr('diff -p1', retcode=1)
 
93
        out, err = self.run_bzr('diff -p1', retcode=1)
93
94
        self.assertEquals(err, '')
94
95
        self.assertEqualDiff(subst_dates(out), '''\
95
96
=== modified file 'hello'
105
106
        """diff -p0 produces diffs with no prefix"""
106
107
        self.make_example_branch()
107
108
        file('hello', 'wb').write('hello world!\n')
108
 
        out, err = self.runbzr('diff -p0', retcode=1)
 
109
        out, err = self.run_bzr('diff -p0', retcode=1)
109
110
        self.assertEquals(err, '')
110
111
        self.assertEqualDiff(subst_dates(out), '''\
111
112
=== modified file 'hello'
121
122
        # Get an error from a file that does not exist at all
122
123
        # (Malone #3619)
123
124
        self.make_example_branch()
124
 
        out, err = self.runbzr('diff does-not-exist', retcode=3)
 
125
        out, err = self.run_bzr('diff does-not-exist', retcode=3)
125
126
        self.assertContainsRe(err, 'not versioned.*does-not-exist')
126
127
 
127
128
    def test_diff_illegal_revision_specifiers(self):
128
 
        out, err = self.runbzr('diff -r 1..23..123', retcode=3)
 
129
        out, err = self.run_bzr('diff -r 1..23..123', retcode=3)
129
130
        self.assertContainsRe(err, 'one or two revision specifiers')
130
131
 
131
132
    def test_diff_unversioned(self):
133
134
        # (Malone #3619)
134
135
        self.make_example_branch()
135
136
        self.build_tree(['unversioned-file'])
136
 
        out, err = self.runbzr('diff unversioned-file', retcode=3)
 
137
        out, err = self.run_bzr('diff unversioned-file', retcode=3)
137
138
        self.assertContainsRe(err, 'not versioned.*unversioned-file')
138
139
 
139
140
    # TODO: What should diff say for a file deleted in working tree?
140
141
 
141
142
    def example_branches(self):
142
143
        self.build_tree(['branch1/', 'branch1/file'], line_endings='binary')
143
 
        self.capture('init branch1')
144
 
        self.capture('add branch1/file')
 
144
        self.run_bzr_captured(['init', 'branch1'])[0]
 
145
        self.run_bzr_captured(['add', 'branch1/file'])[0]
145
146
        self.run_bzr_captured(['commit', '-m', 'add file', 'branch1'])
146
 
        self.capture('branch branch1 branch2')
147
 
        print >> open('branch2/file', 'wb'), 'new content'
 
147
        self.run_bzr_captured(['branch', 'branch1', 'branch2'])[0]
 
148
        self.build_tree_contents([('branch2/file', 'new content\n')])
148
149
        self.run_bzr_captured(['commit', '-m', 'update file', 'branch2'])
149
150
 
150
151
    def test_diff_branches(self):
197
198
 
198
199
    def example_branch2(self):
199
200
        self.build_tree(['branch1/', 'branch1/file1'], line_endings='binary')
200
 
        self.capture('init branch1')
201
 
        self.capture('add branch1/file1')
 
201
        self.run_bzr_captured(['init', 'branch1'])[0]
 
202
        self.run_bzr_captured(['add', 'branch1/file1'])[0]
202
203
        print >> open('branch1/file1', 'wb'), 'original line'
203
204
        self.run_bzr_captured(['commit', '-m', 'first commit', 'branch1'])
204
205
        
227
228
 
228
229
    def make_example_branch(self):
229
230
        super(TestCheckoutDiff, self).make_example_branch()
230
 
        self.runbzr('checkout . checkout')
 
231
        self.run_bzr('checkout . checkout')
231
232
        os.chdir('checkout')
232
233
 
233
234
    def example_branch2(self):
234
235
        super(TestCheckoutDiff, self).example_branch2()
235
236
        os.mkdir('checkouts')
236
 
        self.runbzr('checkout branch1 checkouts/branch1')
 
237
        self.run_bzr('checkout branch1 checkouts/branch1')
237
238
        os.chdir('checkouts')
238
239
 
239
240
    def example_branches(self):
240
241
        super(TestCheckoutDiff, self).example_branches()
241
242
        os.mkdir('checkouts')
242
 
        self.runbzr('checkout branch1 checkouts/branch1')
243
 
        self.runbzr('checkout branch2 checkouts/branch2')
 
243
        self.run_bzr('checkout branch1 checkouts/branch1')
 
244
        self.run_bzr('checkout branch2 checkouts/branch2')
244
245
        os.chdir('checkouts')
245
246
 
246
247
 
248
249
 
249
250
    def test_diff_label_removed(self):
250
251
        super(TestDiffLabels, self).make_example_branch()
251
 
        self.runbzr('remove hello')
 
252
        self.run_bzr('remove hello')
252
253
        diff = self.run_bzr_captured(['diff'], retcode=1)
253
254
        self.assertTrue("=== removed file 'hello'" in diff[0])
254
255
 
255
256
    def test_diff_label_added(self):
256
257
        super(TestDiffLabels, self).make_example_branch()
257
258
        file('barbar', 'wt').write('barbar')
258
 
        self.runbzr('add barbar')
 
259
        self.run_bzr('add barbar')
259
260
        diff = self.run_bzr_captured(['diff'], retcode=1)
260
261
        self.assertTrue("=== added file 'barbar'" in diff[0])
261
262
 
267
268
 
268
269
    def test_diff_label_renamed(self):
269
270
        super(TestDiffLabels, self).make_example_branch()
270
 
        self.runbzr('rename hello gruezi')
 
271
        self.run_bzr('rename hello gruezi')
271
272
        diff = self.run_bzr_captured(['diff'], retcode=1)
272
273
        self.assertTrue("=== renamed file 'hello' => 'gruezi'" in diff[0])
273
274