58
58
self.capture('branch branch1 branch2')
59
59
print >> open('branch2/file', 'wb'), 'new content'
60
60
self.run_bzr_captured(['commit', '-m', 'update file', 'branch2'])
62
def test_diff_branches(self):
63
self.example_branches()
61
64
# should open branch1 and diff against branch2,
62
65
output = self.run_bzr_captured(['diff', '-r', 'branch:branch2',
65
self.assertEquals(("=== modified file 'file'\n"
68
self.assertEquals(("=== modified file 'a/file'\n"
68
71
"@@ -1,1 +1,1 @@\n"
70
73
"+contents of branch1/file\n"
72
75
output = self.run_bzr_captured(['diff', 'branch2', 'branch1'],
74
self.assertEqualDiff(("=== modified file 'file'\n"
77
self.assertEqualDiff(("=== modified file 'a/file'\n"
77
80
"@@ -1,1 +1,1 @@\n"
79
82
"+contents of branch1/file\n"
82
def test_diff_to_working_tree(self):
85
def example_branch2(self):
83
86
self.build_tree(['branch1/', 'branch1/file1'], line_endings='binary')
84
87
self.capture('init branch1')
85
88
self.capture('add branch1/file1')
89
92
print >> open('branch1/file1', 'wb'), 'repo line'
90
93
self.run_bzr_captured(['commit', '-m', 'second commit', 'branch1'])
95
def test_diff_to_working_tree(self):
96
self.example_branch2()
92
98
print >> open('branch1/file1', 'wb'), 'new line'
93
99
output = self.run_bzr_captured(['diff', '-r', '1..', 'branch1'], retcode=1)
94
100
self.assertTrue('\n-original line\n+new line\n' in output[0])
103
class TestCheckoutDiff(TestDiff):
105
def example_branch(self):
106
super(TestCheckoutDiff, self).example_branch()
107
self.runbzr('checkout . checkout')
110
def example_branch2(self):
111
super(TestCheckoutDiff, self).example_branch2()
112
os.mkdir('checkouts')
113
self.runbzr('checkout branch1 checkouts/branch1')
114
os.chdir('checkouts')
116
def example_branches(self):
117
super(TestCheckoutDiff, self).example_branches()
118
os.mkdir('checkouts')
119
self.runbzr('checkout branch1 checkouts/branch1')
120
self.runbzr('checkout branch2 checkouts/branch2')
121
os.chdir('checkouts')
123
class TestDiffLabels(TestDiff):
125
def test_diff_label_removed(self):
126
super(TestDiffLabels, self).example_branch()
127
self.runbzr('remove hello')
128
diff = self.run_bzr_captured(['diff'], retcode=1)
129
self.assertTrue("=== removed file 'a/hello'" in diff[0])
131
def test_diff_label_added(self):
132
super(TestDiffLabels, self).example_branch()
133
file('barbar', 'wt').write('barbar')
134
self.runbzr('add barbar')
135
diff = self.run_bzr_captured(['diff'], retcode=1)
136
self.assertTrue("=== added file 'b/barbar'" in diff[0])
138
def test_diff_label_modified(self):
139
super(TestDiffLabels, self).example_branch()
140
file('hello', 'wt').write('barbar')
141
diff = self.run_bzr_captured(['diff'], retcode=1)
142
self.assertTrue("=== modified file 'a/hello'" in diff[0])
144
def test_diff_label_renamed(self):
145
super(TestDiffLabels, self).example_branch()
146
self.runbzr('rename hello gruezi')
147
diff = self.run_bzr_captured(['diff'], retcode=1)
148
self.assertTrue("=== renamed file 'a/hello' => 'b/gruezi'" in diff[0])