1
# Copyright (C) 2008 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Test that all Tree's implement .annotate_iter()"""
19
from bzrlib.tests.tree_implementations import TestCaseWithTree
22
class TestAnnotate(TestCaseWithTree):
24
def get_simple_tree(self):
25
tree = self.make_branch_and_tree('tree')
26
self.build_tree_contents([('tree/one', 'first\ncontent\n')])
27
tree.add(['one'], ['one-id'])
28
tree.commit('one', rev_id='one')
29
self.build_tree_contents([('tree/one', 'second\ncontent\n')])
30
tree.commit('two', rev_id='two')
31
return self._convert_tree(tree)
33
def get_tree_with_ghost(self):
34
tree = self.make_branch_and_tree('tree')
35
self.build_tree_contents([('tree/one', 'first\ncontent\n')])
36
tree.add(['one'], ['one-id'])
37
tree.commit('one', rev_id='one')
38
tree.set_parent_ids(['one', 'ghost-one'])
39
self.build_tree_contents([('tree/one', 'second\ncontent\n')])
40
tree.commit('two', rev_id='two')
41
return self._convert_tree(tree)
43
def test_annotate_simple(self):
44
tree = self.get_simple_tree()
46
self.addCleanup(tree.unlock)
47
self.assertEqual([('two', 'second\n'), ('one', 'content\n')],
48
list(tree.annotate_iter('one-id')))
50
def test_annotate_with_ghost(self):
51
tree = self.get_tree_with_ghost()
53
self.addCleanup(tree.unlock)
54
self.assertEqual([('two', 'second\n'), ('one', 'content\n')],
55
list(tree.annotate_iter('one-id')))