1
# Copyright (C) 2005 by Canonical Ltd
2
# -*- coding: utf-8 -*-
1
# Copyright (C) 2005, 2006 by Canonical Ltd
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
29
28
class TestDiff(ExternalBase):
30
def example_branch(test):
30
def make_example_branch(test):
31
31
# FIXME: copied from test_too_much -- share elsewhere?
32
32
test.runbzr('init')
33
33
file('hello', 'wt').write('foo')
38
38
test.runbzr('commit -m setup goodbye')
40
40
def test_diff(self):
41
self.make_example_branch()
42
42
file('hello', 'wt').write('hello world!')
43
43
self.runbzr('commit -m fixing hello')
44
44
output = self.runbzr('diff -r 2..3', backtick=1, retcode=1)
51
51
self.runbzr('diff')
53
def test_diff_nonexistent(self):
54
# Get an error from a file that does not exist at all
56
self.make_example_branch()
57
out, err = self.runbzr('diff does-not-exist', retcode=3)
58
self.assertContainsRe(err, 'not versioned.*does-not-exist')
60
def test_diff_unversioned(self):
61
# Get an error when diffing a non-versioned file.
63
self.make_example_branch()
64
self.build_tree(['unversioned-file'])
65
out, err = self.runbzr('diff unversioned-file', retcode=3)
66
self.assertContainsRe(err, 'not versioned.*unversioned-file')
68
# TODO: What should diff say for a file deleted in working tree?
53
70
def example_branches(self):
54
71
self.build_tree(['branch1/', 'branch1/file'], line_endings='binary')
55
72
self.capture('init branch1')
103
120
class TestCheckoutDiff(TestDiff):
105
def example_branch(self):
106
super(TestCheckoutDiff, self).example_branch()
122
def make_example_branch(self):
123
super(TestCheckoutDiff, self).make_example_branch()
107
124
self.runbzr('checkout . checkout')
108
125
os.chdir('checkout')
120
137
self.runbzr('checkout branch2 checkouts/branch2')
121
138
os.chdir('checkouts')
123
141
class TestDiffLabels(TestDiff):
125
143
def test_diff_label_removed(self):
126
super(TestDiffLabels, self).example_branch()
144
super(TestDiffLabels, self).make_example_branch()
127
145
self.runbzr('remove hello')
128
146
diff = self.run_bzr_captured(['diff'], retcode=1)
129
147
self.assertTrue("=== removed file 'a/hello'" in diff[0])
131
149
def test_diff_label_added(self):
132
super(TestDiffLabels, self).example_branch()
150
super(TestDiffLabels, self).make_example_branch()
133
151
file('barbar', 'wt').write('barbar')
134
152
self.runbzr('add barbar')
135
153
diff = self.run_bzr_captured(['diff'], retcode=1)
136
154
self.assertTrue("=== added file 'b/barbar'" in diff[0])
138
156
def test_diff_label_modified(self):
139
super(TestDiffLabels, self).example_branch()
157
super(TestDiffLabels, self).make_example_branch()
140
158
file('hello', 'wt').write('barbar')
141
159
diff = self.run_bzr_captured(['diff'], retcode=1)
142
160
self.assertTrue("=== modified file 'a/hello'" in diff[0])
144
162
def test_diff_label_renamed(self):
145
super(TestDiffLabels, self).example_branch()
163
super(TestDiffLabels, self).make_example_branch()
146
164
self.runbzr('rename hello gruezi')
147
165
diff = self.run_bzr_captured(['diff'], retcode=1)
148
166
self.assertTrue("=== renamed file 'a/hello' => 'b/gruezi'" in diff[0])