~jelmer/ubuntu/maverick/bzr/2.2.5

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_revision_tree.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-08-07 00:54:52 UTC
  • mfrom: (1.4.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100807005452-g4zb99ezl3xn44r4
* New upstream release.
 + Adds support for setting timestamps to originating revisions.
   Closes: #473450
 + Removes remaining string exception. Closes: #585193, LP: #586926
 + Add C extension to work around Python issue 1628205. LP: #583941,
   Closes: #577110
 + Avoids showing progress bars when --quiet is used. Closes: #542105,
   LP: #320035
 + No longer creates ~/.bazaar as root when run under sudo. LP: #376388
 + 'bzr commit' now supports -p as alternative for --show-diff. LP: #571467
 + 'bzr add' no longer adds .THIS/.BASE/.THEIRS files unless
   explicitly requested. LP: #322767
 + When parsing patch files, Bazaar now supports diff lines before each
   patch. LP: #502076
 + WorkingTrees now no longer requires using signal.signal, so can
   be used in a threaded environment. LP: #521989
 + An assertion error is no longer triggered when pushing to a pre-1.6
   Bazaar server. LP: #528041
* Bump standards version to 3.9.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
23
23
so these tests are testing that when there is a cache, it performs correctly.
24
24
"""
25
25
 
26
 
from bzrlib import errors
27
 
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
28
 
 
29
 
 
30
 
class TestRevisionTree(TestCaseWithWorkingTree):
 
26
from bzrlib import (
 
27
    branchbuilder,
 
28
    errors,
 
29
    tests,
 
30
    )
 
31
from bzrlib.tests import per_workingtree
 
32
 
 
33
 
 
34
class TestRevisionTree(per_workingtree.TestCaseWithWorkingTree):
31
35
 
32
36
    def test_get_zeroth_basis_tree_via_revision_tree(self):
33
37
        tree = self.make_branch_and_tree('.')
83
87
            return
84
88
        repository_revision_tree = tree.branch.repository.revision_tree(rev1)
85
89
        self.assertTreesEqual(repository_revision_tree, cached_revision_tree)
 
90
 
 
91
 
 
92
class TestRevisionTreeKind(per_workingtree.TestCaseWithWorkingTree):
 
93
 
 
94
    def make_branch_with_merged_deletions(self, relpath='tree'):
 
95
        tree = self.make_branch_and_tree(relpath)
 
96
        files = ['a', 'b/', 'b/c']
 
97
        self.build_tree(files, line_endings='binary',
 
98
                        transport=tree.bzrdir.root_transport)
 
99
        tree.set_root_id('root-id')
 
100
        tree.add(files, ['a-id', 'b-id', 'c-id'])
 
101
        tree.commit('a, b and b/c', rev_id='base')
 
102
        tree2 = tree.bzrdir.sprout(relpath + '2').open_workingtree()
 
103
        # Delete 'a' in tree
 
104
        tree.remove('a', keep_files=False)
 
105
        tree.commit('remove a', rev_id='this')
 
106
        # Delete 'c' in tree2
 
107
        tree2.remove('b/c', keep_files=False)
 
108
        tree2.remove('b', keep_files=False)
 
109
        tree2.commit('remove b/c', rev_id='other')
 
110
        # Merge tree2 into tree
 
111
        tree.merge_from_branch(tree2.branch)
 
112
        return tree
 
113
 
 
114
    def test_kind_parent_tree(self):
 
115
        tree = self.make_branch_with_merged_deletions()
 
116
        tree.lock_read()
 
117
        self.addCleanup(tree.unlock)
 
118
        parents = tree.get_parent_ids()
 
119
        self.assertEqual(['this', 'other'], parents)
 
120
        basis = tree.revision_tree(parents[0])
 
121
        basis.lock_read()
 
122
        self.addCleanup(basis.unlock)
 
123
        self.assertRaises(errors.NoSuchId, basis.kind, 'a-id')
 
124
        self.assertEqual(['directory', 'file'],
 
125
                         [basis.kind('b-id'), basis.kind('c-id')])
 
126
        try:
 
127
            other = tree.revision_tree(parents[1])
 
128
        except errors.NoSuchRevisionInTree:
 
129
            raise tests.TestNotApplicable(
 
130
                'Tree type %s caches only the basis revision tree.'
 
131
                % type(tree))
 
132
        other.lock_read()
 
133
        self.addCleanup(other.unlock)
 
134
        self.assertRaises(errors.NoSuchId, other.kind, 'b-id')
 
135
        self.assertRaises(errors.NoSuchId, other.kind, 'c-id')
 
136
        self.assertEqual('file', other.kind('a-id'))