/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
19
from breezy.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')])
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
27
        tree.add(['one'])
6747.4.2 by Jelmer Vernooij
Avoid setting revision ids in a few more places.
28
        rev_1 = tree.commit('one')
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
29
        self.build_tree_contents([('tree/one', 'second\ncontent\n')])
6747.4.2 by Jelmer Vernooij
Avoid setting revision ids in a few more places.
30
        rev_2 = tree.commit('two')
31
        return self._convert_tree(tree), [rev_1, rev_2]
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
32
33
    def get_tree_with_ghost(self):
34
        tree = self.make_branch_and_tree('tree')
6829.2.1 by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places.
35
        if not tree.branch.repository._format.supports_ghosts:
36
            self.skipTest('repository format does not support ghosts')
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
37
        self.build_tree_contents([('tree/one', 'first\ncontent\n')])
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
38
        tree.add(['one'])
6747.4.2 by Jelmer Vernooij
Avoid setting revision ids in a few more places.
39
        rev_1 = tree.commit('one')
40
        tree.set_parent_ids([rev_1, 'ghost-one'])
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
41
        self.build_tree_contents([('tree/one', 'second\ncontent\n')])
6747.4.2 by Jelmer Vernooij
Avoid setting revision ids in a few more places.
42
        rev_2 = tree.commit('two')
43
        return self._convert_tree(tree), [rev_1, rev_2]
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
44
45
    def test_annotate_simple(self):
6747.4.2 by Jelmer Vernooij
Avoid setting revision ids in a few more places.
46
        tree, revids = self.get_simple_tree()
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
47
        tree.lock_read()
48
        self.addCleanup(tree.unlock)
6747.4.2 by Jelmer Vernooij
Avoid setting revision ids in a few more places.
49
        self.assertEqual([(revids[1], 'second\n'), (revids[0], 'content\n')],
6809.4.2 by Jelmer Vernooij
Swap arguments for annotate_iter.
50
                         list(tree.annotate_iter('one')))
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
51
52
    def test_annotate_with_ghost(self):
6747.4.2 by Jelmer Vernooij
Avoid setting revision ids in a few more places.
53
        tree, revids = self.get_tree_with_ghost()
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
54
        tree.lock_read()
55
        self.addCleanup(tree.unlock)
6747.4.2 by Jelmer Vernooij
Avoid setting revision ids in a few more places.
56
        self.assertEqual([(revids[1], 'second\n'), (revids[0], 'content\n')],
6809.4.2 by Jelmer Vernooij
Swap arguments for annotate_iter.
57
                         list(tree.annotate_iter('one')))