~bzr-pqm/bzr/bzr.dev

3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
1
# Copyright (C) 2008 Canonical Ltd
2
#
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.
7
#
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.
12
#
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
16
17
"""Test that all Tree's implement .annotate_iter()"""
18
4523.1.4 by Martin Pool
Rename remaining *_implementations tests
19
from bzrlib.tests.per_tree import TestCaseWithTree
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
20
21
22
class TestAnnotate(TestCaseWithTree):
23
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)
32
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)
42
43
    def test_annotate_simple(self):
44
        tree = self.get_simple_tree()
45
        tree.lock_read()
46
        self.addCleanup(tree.unlock)
47
        self.assertEqual([('two', 'second\n'), ('one', 'content\n')],
48
                         list(tree.annotate_iter('one-id')))
49
50
    def test_annotate_with_ghost(self):
51
        tree = self.get_tree_with_ghost()
52
        tree.lock_read()
53
        self.addCleanup(tree.unlock)
54
        self.assertEqual([('two', 'second\n'), ('one', 'content\n')],
55
                         list(tree.annotate_iter('one-id')))