1
# Copyright (C) 2006 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
from bzrlib import inventory, tests
18
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
21
class TestWorkingTree(TestCaseWithWorkingTree):
23
def test_subsume_tree(self):
24
self.build_tree(['tree/', 'tree/file', 'tree/subtree/',
25
'tree/subtree/file2'])
26
base_tree = self.make_branch_and_tree('tree')
27
if base_tree.get_root_id() == inventory.ROOT_ID:
28
raise tests.TestSkipped('This test requires unique roots')
29
base_tree.add('file', 'file-id')
30
base_tree.commit('first commit', rev_id='tree-1')
31
sub_tree = self.make_branch_and_tree('tree/subtree')
32
sub_tree.add('file2', 'file2-id')
33
sub_tree.commit('first commit', rev_id='subtree-1')
34
sub_root_id = sub_tree.get_root_id()
35
base_tree.subsume(sub_tree)
36
self.assertEqual(['tree-1', 'subtree-1'], base_tree.get_parent_ids())
37
self.assertEqual(sub_root_id, base_tree.path2id('subtree'))
38
self.assertEqual('file2-id', base_tree.path2id('subtree/file2'))