~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/tree_implementations/test_annotate_iter.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-03-15 17:44:41 UTC
  • mfrom: (3224.1.29 annotate_finish)
  • Revision ID: pqm@pqm.ubuntu.com-20080315174441-l8xpw6femn0syal1
(jam) Tweak annotate performance for pack repositories,
        improving speed and decreasing memory consumption.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""Test that all Tree's implement .annotate_iter()"""
 
18
 
 
19
from bzrlib.tests.tree_implementations import TestCaseWithTree
 
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')))