29
29
from bzrlib.branch import Branch
30
30
from bzrlib.config import extract_email_address
31
31
from bzrlib.tests import TestCaseWithTransport
32
from bzrlib.urlutils import joinpath
35
34
class TestAnnotate(TestCaseWithTransport):
140
139
out, err = self.run_bzr('annotate hello.txt -r 10',
142
141
self.assertEqual('', out)
143
self.assertContainsRe(err, "Requested revision: '10' does not exist")
142
self.assertContainsRe(err, 'Requested revision: \'10\' does not exist')
145
144
def test_annotate_cmd_two_revisions(self):
146
145
out, err = self.run_bzr('annotate hello.txt -r1..2',
154
153
class TestSimpleAnnotate(TestCaseWithTransport):
155
154
"""Annotate tests with no complex setup."""
157
def _setup_edited_file(self, relpath='.'):
156
def _setup_edited_file(self):
158
157
"""Create a tree with a locally edited file."""
159
tree = self.make_branch_and_tree(relpath)
160
file_relpath = joinpath(relpath, 'file')
161
self.build_tree_contents([(file_relpath, 'foo\ngam\n')])
158
tree = self.make_branch_and_tree('.')
159
self.build_tree_contents([('file', 'foo\ngam\n')])
163
161
tree.commit('add file', committer="test@host", rev_id="rev1")
164
self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
162
self.build_tree_contents([('file', 'foo\nbar\ngam\n')])
165
163
tree.branch.get_config().set_user_option('email', 'current@host2')
168
def test_annotate_cmd_revspec_branch(self):
169
tree = self._setup_edited_file('trunk')
170
tree.branch.create_checkout(self.get_url('work'), lightweight=True)
172
out, err = self.run_bzr('annotate file -r branch:../trunk')
173
self.assertEqual('', err)
179
165
def test_annotate_edited_file(self):
180
166
tree = self._setup_edited_file()
278
264
os.chdir('branch')
279
265
out, err = self.run_bzr('annotate empty')
280
266
self.assertEqual('', out)
282
def test_annotate_directory(self):
283
"""Test --directory option"""
284
wt = self.make_branch_and_tree('a')
285
self.build_tree_contents([('a/hello.txt', 'my helicopter\n')])
286
wt.add(['hello.txt'])
287
wt.commit('commit', committer='test@user')
288
out, err = self.run_bzr('annotate -d a hello.txt')
289
self.assertEqualDiff('1 test@us | my helicopter\n', out)