39
39
super(TestAnnotate, self).setUp()
40
40
wt = self.make_branch_and_tree('.')
42
self.build_tree_contents([('hello.txt', b'my helicopter\n'),
43
('nomail.txt', b'nomail\n')])
42
self.build_tree_contents([('hello.txt', 'my helicopter\n'),
43
('nomail.txt', 'nomail\n')])
44
44
wt.add(['hello.txt'])
45
45
self.revision_id_1 = wt.commit('add hello',
46
committer='test@user',
47
timestamp=1165960000.00, timezone=0)
46
committer='test@user',
47
timestamp=1165960000.00, timezone=0)
48
48
wt.add(['nomail.txt'])
49
49
self.revision_id_2 = wt.commit('add nomail',
51
timestamp=1165970000.00, timezone=0)
52
self.build_tree_contents([('hello.txt', b'my helicopter\n'
53
b'your helicopter\n')])
51
timestamp=1165970000.00, timezone=0)
52
self.build_tree_contents([('hello.txt', 'my helicopter\n'
53
'your helicopter\n')])
54
54
self.revision_id_3 = wt.commit('mod hello',
55
committer='user@test',
56
timestamp=1166040000.00, timezone=0)
57
self.build_tree_contents([('hello.txt', b'my helicopter\n'
55
committer='user@test',
56
timestamp=1166040000.00, timezone=0)
57
self.build_tree_contents([('hello.txt', 'my helicopter\n'
62
62
self.revision_id_4 = wt.commit('mod hello',
63
committer='user@test',
64
timestamp=1166050000.00, timezone=0)
63
committer='user@test',
64
timestamp=1166050000.00, timezone=0)
66
66
def test_help_annotate(self):
67
67
"""Annotate command exists"""
108
108
%*s | your helicopter
110
110
%*s | our helicopters
111
''' % (max_len, self.revision_id_1.decode('utf-8'),
112
max_len, self.revision_id_3.decode('utf-8'),
113
max_len, self.revision_id_4.decode('utf-8'),
111
''' % (max_len, self.revision_id_1,
112
max_len, self.revision_id_3,
113
max_len, self.revision_id_4,
117
118
def test_no_mail(self):
118
119
out, err = self.run_bzr('annotate nomail.txt')
158
159
"""Create a tree with a locally edited file."""
159
160
tree = self.make_branch_and_tree(relpath)
160
161
file_relpath = joinpath(relpath, 'file')
161
self.build_tree_contents([(file_relpath, b'foo\ngam\n')])
162
self.build_tree_contents([(file_relpath, 'foo\ngam\n')])
163
tree.commit('add file', committer="test@host", rev_id=b"rev1")
164
self.build_tree_contents([(file_relpath, b'foo\nbar\ngam\n')])
164
tree.commit('add file', committer="test@host", rev_id="rev1")
165
self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
167
168
def test_annotate_cmd_revspec_branch(self):
188
189
def test_annotate_edited_file_no_default(self):
189
190
# Ensure that when no username is available annotate still works.
190
override_whoami(self)
191
self.overrideEnv('EMAIL', None)
192
self.overrideEnv('BRZ_EMAIL', None)
193
# Also, make sure that it's not inferred from mailname.
194
self.overrideAttr(config, '_auto_user_id',
195
lambda: (None, None))
191
196
tree = self._setup_edited_file()
192
197
out, err = self.run_bzr('annotate file')
193
198
self.assertEqual(
209
214
def _create_merged_file(self):
210
215
"""Create a file with a pending merge and local edit."""
211
216
tree = self.make_branch_and_tree('.')
212
self.build_tree_contents([('file', b'foo\ngam\n')])
217
self.build_tree_contents([('file', 'foo\ngam\n')])
214
tree.commit('add file', rev_id=b"rev1", committer="test@host")
219
tree.commit('add file', rev_id="rev1", committer="test@host")
216
self.build_tree_contents([('file', b'foo\nbar\ngam\n')])
217
tree.commit("right", rev_id=b"rev1.1.1", committer="test@host")
218
tree.pull(tree.branch, True, b"rev1")
221
self.build_tree_contents([('file', 'foo\nbar\ngam\n')])
222
tree.commit("right", rev_id="rev1.1.1", committer="test@host")
223
tree.pull(tree.branch, True, "rev1")
220
self.build_tree_contents([('file', b'foo\nbaz\ngam\n')])
221
tree.commit("left", rev_id=b"rev2", committer="test@host")
225
self.build_tree_contents([('file', 'foo\nbaz\ngam\n')])
226
tree.commit("left", rev_id="rev2", committer="test@host")
223
tree.merge_from_branch(tree.branch, b"rev1.1.1")
228
tree.merge_from_branch(tree.branch, "rev1.1.1")
224
229
# edit the file to be 'resolved' and have a further local edit
225
self.build_tree_contents([('file', b'local\nfoo\nbar\nbaz\ngam\n')])
230
self.build_tree_contents([('file', 'local\nfoo\nbar\nbaz\ngam\n')])
228
233
def test_annotated_edited_merged_file_revnos(self):
252
257
def test_annotate_empty_file(self):
253
258
tree = self.make_branch_and_tree('.')
254
self.build_tree_contents([('empty', b'')])
259
self.build_tree_contents([('empty', '')])
255
260
tree.add('empty')
256
261
tree.commit('add empty file')
257
262
out, err = self.run_bzr(['annotate', 'empty'])
260
265
def test_annotate_removed_file(self):
261
266
tree = self.make_branch_and_tree('.')
262
self.build_tree_contents([('empty', b'')])
267
self.build_tree_contents([('empty', '')])
263
268
tree.add('empty')
264
269
tree.commit('add empty file')
265
270
# delete the file.
271
276
def test_annotate_empty_file_show_ids(self):
272
277
tree = self.make_branch_and_tree('.')
273
self.build_tree_contents([('empty', b'')])
278
self.build_tree_contents([('empty', '')])
274
279
tree.add('empty')
275
280
tree.commit('add empty file')
276
281
out, err = self.run_bzr(['annotate', '--show-ids', 'empty'])
288
293
def test_annotate_without_workingtree(self):
289
294
tree = self.make_branch_and_tree('.')
290
self.build_tree_contents([('empty', b'')])
295
self.build_tree_contents([('empty', '')])
291
296
tree.add('empty')
292
297
tree.commit('add empty file')
293
298
bzrdir = tree.branch.controldir
299
304
def test_annotate_directory(self):
300
305
"""Test --directory option"""
301
306
wt = self.make_branch_and_tree('a')
302
self.build_tree_contents([('a/hello.txt', b'my helicopter\n')])
307
self.build_tree_contents([('a/hello.txt', 'my helicopter\n')])
303
308
wt.add(['hello.txt'])
304
309
wt.commit('commit', committer='test@user')
305
310
out, err = self.run_bzr(['annotate', '-d', 'a', 'hello.txt'])
306
311
self.assertEqualDiff('1 test@us | my helicopter\n', out)
314
class TestSmartServerAnnotate(tests.TestCaseWithTransport):
316
def test_simple_annotate(self):
317
self.setup_smart_server_with_call_log()
318
wt = self.make_branch_and_tree('branch')
319
self.build_tree_contents([('branch/hello.txt', 'my helicopter\n')])
320
wt.add(['hello.txt'])
321
wt.commit('commit', committer='test@user')
322
self.reset_smart_call_log()
323
out, err = self.run_bzr(['annotate', "-d", self.get_url('branch'),
325
# This figure represent the amount of work to perform this use case. It
326
# is entirely ok to reduce this number if a test fails due to rpc_count
327
# being too low. If rpc_count increases, more network roundtrips have
328
# become necessary for this use case. Please do not adjust this number
329
# upwards without agreement from bzr's network support maintainers.
330
self.assertLength(16, self.hpss_calls)
331
self.assertLength(1, self.hpss_connections)
332
self.expectFailure("annotate accesses inventories, which require VFS access",
333
self.assertThat, self.hpss_calls, ContainsNoVfsCalls)