54
54
self.make_example_branch()
55
55
file('hello', 'wt').write('hello world!')
56
56
self.run_bzr('commit -m fixing hello')
57
output = self.run_bzr_captured('diff -r 2..3', retcode=1)[0]
57
output = self.run_bzr('diff -r 2..3', retcode=1)[0]
58
58
self.assert_('\n+hello world!' in output)
59
output = self.run_bzr_captured('diff -r last:3..last:1',
59
output = self.run_bzr('diff -r last:3..last:1',
61
61
self.assert_('\n+baz' in output)
62
62
self.build_tree(['moo'])
142
142
def example_branches(self):
143
143
self.build_tree(['branch1/', 'branch1/file'], line_endings='binary')
144
self.run_bzr_captured(['init', 'branch1'])[0]
145
self.run_bzr_captured(['add', 'branch1/file'])[0]
146
self.run_bzr_captured(['commit', '-m', 'add file', 'branch1'])
147
self.run_bzr_captured(['branch', 'branch1', 'branch2'])[0]
144
self.run_bzr(['init', 'branch1'])[0]
145
self.run_bzr(['add', 'branch1/file'])[0]
146
self.run_bzr(['commit', '-m', 'add file', 'branch1'])
147
self.run_bzr(['branch', 'branch1', 'branch2'])[0]
148
148
self.build_tree_contents([('branch2/file', 'new content\n')])
149
self.run_bzr_captured(['commit', '-m', 'update file', 'branch2'])
149
self.run_bzr(['commit', '-m', 'update file', 'branch2'])
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_captured(['diff', '-r', 'branch:branch2',
154
out, err = self.run_bzr(['diff', '-r', 'branch:branch2',
157
157
self.assertEquals('', err)
163
163
"+contents of branch1/file\n"
164
164
"\n", subst_dates(out))
165
out, err = self.run_bzr_captured(['diff', 'branch2', 'branch1'],
165
out, err = self.run_bzr(['diff', 'branch2', 'branch1'],
167
167
self.assertEquals('', err)
168
168
self.assertEqualDiff("=== modified file 'file'\n"
176
176
def test_diff_revno_branches(self):
177
177
self.example_branches()
178
178
print >> open('branch2/file', 'wb'), 'even newer content'
179
self.run_bzr_captured(['commit', '-m',
179
self.run_bzr(['commit', '-m',
180
180
'update file once more', 'branch2'])
182
out, err = self.run_bzr_captured(['diff', '-r',
182
out, err = self.run_bzr(['diff', '-r',
183
183
'revno:1:branch2..revno:1:branch1'],
185
185
self.assertEquals('', err)
186
186
self.assertEquals('', out)
187
out, err = self.run_bzr_captured(['diff', '-r',
187
out, err = self.run_bzr(['diff', '-r',
188
188
'revno:2:branch2..revno:1:branch1'],
190
190
self.assertEquals('', err)
199
199
def example_branch2(self):
200
200
self.build_tree(['branch1/', 'branch1/file1'], line_endings='binary')
201
self.run_bzr_captured(['init', 'branch1'])[0]
202
self.run_bzr_captured(['add', 'branch1/file1'])[0]
201
self.run_bzr(['init', 'branch1'])[0]
202
self.run_bzr(['add', 'branch1/file1'])[0]
203
203
print >> open('branch1/file1', 'wb'), 'original line'
204
self.run_bzr_captured(['commit', '-m', 'first commit', 'branch1'])
204
self.run_bzr(['commit', '-m', 'first commit', 'branch1'])
206
206
print >> open('branch1/file1', 'wb'), 'repo line'
207
self.run_bzr_captured(['commit', '-m', 'second commit', 'branch1'])
207
self.run_bzr(['commit', '-m', 'second commit', 'branch1'])
209
209
def test_diff_to_working_tree(self):
210
210
self.example_branch2()
212
212
print >> open('branch1/file1', 'wb'), 'new line'
213
output = self.run_bzr_captured(['diff', '-r', '1..', 'branch1'],
213
output = self.run_bzr(['diff', '-r', '1..', 'branch1'],
215
215
self.assertTrue('\n-original line\n+new line\n' in output[0])
250
250
def test_diff_label_removed(self):
251
251
super(TestDiffLabels, self).make_example_branch()
252
252
self.run_bzr('remove hello')
253
diff = self.run_bzr_captured(['diff'], retcode=1)
253
diff = self.run_bzr(['diff'], retcode=1)
254
254
self.assertTrue("=== removed file 'hello'" in diff[0])
256
256
def test_diff_label_added(self):
257
257
super(TestDiffLabels, self).make_example_branch()
258
258
file('barbar', 'wt').write('barbar')
259
259
self.run_bzr('add barbar')
260
diff = self.run_bzr_captured(['diff'], retcode=1)
260
diff = self.run_bzr(['diff'], retcode=1)
261
261
self.assertTrue("=== added file 'barbar'" in diff[0])
263
263
def test_diff_label_modified(self):
264
264
super(TestDiffLabels, self).make_example_branch()
265
265
file('hello', 'wt').write('barbar')
266
diff = self.run_bzr_captured(['diff'], retcode=1)
266
diff = self.run_bzr(['diff'], retcode=1)
267
267
self.assertTrue("=== modified file 'hello'" in diff[0])
269
269
def test_diff_label_renamed(self):
270
270
super(TestDiffLabels, self).make_example_branch()
271
271
self.run_bzr('rename hello gruezi')
272
diff = self.run_bzr_captured(['diff'], retcode=1)
272
diff = self.run_bzr(['diff'], retcode=1)
273
273
self.assertTrue("=== renamed file 'hello' => 'gruezi'" in diff[0])