30
30
def make_example_branch(test):
31
31
# FIXME: copied from test_too_much -- share elsewhere?
32
32
test.runbzr('init')
33
file('hello', 'wt').write('foo')
33
file('hello', 'wt').write('foo\n')
34
34
test.runbzr('add hello')
35
35
test.runbzr('commit -m setup hello')
36
file('goodbye', 'wt').write('baz')
36
file('goodbye', 'wt').write('baz\n')
37
37
test.runbzr('add goodbye')
38
38
test.runbzr('commit -m setup goodbye')
51
51
self.runbzr('diff')
53
def test_diff_prefix(self):
54
"""diff --prefix appends to filenames in output"""
55
self.make_example_branch()
56
file('hello', 'wt').write('hello world!\n')
57
out, err = self.runbzr('diff --prefix old/:new/', retcode=1)
58
self.assertEquals(err, '')
59
self.assertEqualDiff(out, '''\
60
=== modified file 'hello'
69
def test_diff_p1(self):
70
"""diff -p1 produces lkml-style diffs"""
71
self.make_example_branch()
72
file('hello', 'wt').write('hello world!\n')
73
out, err = self.runbzr('diff -p1', retcode=1)
74
self.assertEquals(err, '')
75
self.assertEqualDiff(out, '''\
76
=== modified file 'hello'
85
def test_diff_p0(self):
86
"""diff -p0 produces diffs with no prefix"""
87
self.make_example_branch()
88
file('hello', 'wt').write('hello world!\n')
89
out, err = self.runbzr('diff -p0', retcode=1)
90
self.assertEquals(err, '')
91
self.assertEqualDiff(out, '''\
92
=== modified file 'hello'
53
101
def test_diff_nonexistent(self):
54
102
# Get an error from a file that does not exist at all
82
130
output = self.run_bzr_captured(['diff', '-r', 'branch:branch2',
85
self.assertEquals(("=== modified file 'a/file'\n"
133
self.assertEquals(("=== modified file 'file'\n"
88
136
"@@ -1,1 +1,1 @@\n"
90
138
"+contents of branch1/file\n"
91
139
"\n", ''), output)
92
140
output = self.run_bzr_captured(['diff', 'branch2', 'branch1'],
94
self.assertEqualDiff(("=== modified file 'a/file'\n"
142
self.assertEqualDiff(("=== modified file 'file'\n"
97
145
"@@ -1,1 +1,1 @@\n"
99
147
"+contents of branch1/file\n"
144
192
super(TestDiffLabels, self).make_example_branch()
145
193
self.runbzr('remove hello')
146
194
diff = self.run_bzr_captured(['diff'], retcode=1)
147
self.assertTrue("=== removed file 'a/hello'" in diff[0])
195
self.assertTrue("=== removed file 'hello'" in diff[0])
149
197
def test_diff_label_added(self):
150
198
super(TestDiffLabels, self).make_example_branch()
151
199
file('barbar', 'wt').write('barbar')
152
200
self.runbzr('add barbar')
153
201
diff = self.run_bzr_captured(['diff'], retcode=1)
154
self.assertTrue("=== added file 'b/barbar'" in diff[0])
202
self.assertTrue("=== added file 'barbar'" in diff[0])
156
204
def test_diff_label_modified(self):
157
205
super(TestDiffLabels, self).make_example_branch()
158
206
file('hello', 'wt').write('barbar')
159
207
diff = self.run_bzr_captured(['diff'], retcode=1)
160
self.assertTrue("=== modified file 'a/hello'" in diff[0])
208
self.assertTrue("=== modified file 'hello'" in diff[0])
162
210
def test_diff_label_renamed(self):
163
211
super(TestDiffLabels, self).make_example_branch()
164
212
self.runbzr('rename hello gruezi')
165
213
diff = self.run_bzr_captured(['diff'], retcode=1)
166
self.assertTrue("=== renamed file 'a/hello' => 'b/gruezi'" in diff[0])
214
self.assertTrue("=== renamed file 'hello' => 'gruezi'" in diff[0])