~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_join.py

  • Committer: Robert Collins
  • Date: 2005-10-08 00:03:38 UTC
  • mto: (1185.1.51)
  • mto: This revision was merged to the branch mainline in revision 1422.
  • Revision ID: robertc@robertcollins.net-20051008000338-91e577a411df6c37
make reweave visible as a weave method, and quickly integrate into fetch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
 
18
 
import os
19
 
 
20
 
from bzrlib import (
21
 
    osutils,
22
 
    tests,
23
 
    workingtree,
24
 
    )
25
 
 
26
 
 
27
 
class TestJoin(tests.TestCaseWithTransport):
28
 
 
29
 
    def make_trees(self):
30
 
        base_tree = self.make_branch_and_tree('tree',
31
 
            format='development-subtree')
32
 
        base_tree.commit('empty commit')
33
 
        self.build_tree(['tree/subtree/', 'tree/subtree/file1'])
34
 
        sub_tree = self.make_branch_and_tree('tree/subtree')
35
 
        sub_tree.set_root_id('subtree-root-id')
36
 
        sub_tree.add('file1', 'file1-id')
37
 
        sub_tree.commit('added file1')
38
 
        return base_tree, sub_tree
39
 
 
40
 
    def check_success(self, path):
41
 
        base_tree = workingtree.WorkingTree.open(path)
42
 
        self.assertEqual('file1-id', base_tree.path2id('subtree/file1'))
43
 
 
44
 
    def test_join(self):
45
 
        base_tree, sub_tree = self.make_trees()
46
 
        self.run_bzr('join tree/subtree')
47
 
        self.check_success('tree')
48
 
 
49
 
    def test_join_dot(self):
50
 
        base_tree, sub_tree = self.make_trees()
51
 
        self.run_bzr('join .', working_dir='tree/subtree')
52
 
        self.check_success('tree')
53
 
 
54
 
    def test_join_error(self):
55
 
        base_tree, sub_tree = self.make_trees()
56
 
        os.mkdir('tree/subtree2')
57
 
        osutils.rename('tree/subtree', 'tree/subtree2/subtree')
58
 
        self.run_bzr_error(
59
 
            ('Cannot join .*subtree.  Parent directory is not versioned',),
60
 
             'join tree/subtree2/subtree')
61
 
        # disabled because this gives an ugly error at present -- mbp 20070306
62
 
        ## self.run_bzr_error(
63
 
        ##     ('Cannot join .*subtree.  Parent directory is not versioned',),
64
 
        ##      'join', '--reference', 'tree/subtree2/subtree')
65
 
        self.run_bzr_error(('Not a branch:.*subtree2',),
66
 
                           'join tree/subtree2')
67
 
 
68
 
    def test_join_reference(self):
69
 
        """Join can add a reference if --reference is supplied"""
70
 
        base_tree, sub_tree = self.make_trees()
71
 
        self.run_bzr('join . --reference', working_dir='tree/subtree')
72
 
        sub_tree.lock_read()
73
 
        self.addCleanup(sub_tree.unlock)
74
 
        self.assertEqual('file1-id', sub_tree.path2id('file1'))
75
 
        self.assertTrue(sub_tree.has_id('file1-id'))
76
 
        self.assertEqual('subtree-root-id', sub_tree.path2id(''))
77
 
        self.assertEqual('', sub_tree.id2path('subtree-root-id'))
78
 
        self.assertIs(None, base_tree.path2id('subtree/file1'))
79
 
        base_tree.lock_read()
80
 
        self.addCleanup(base_tree.unlock)
81
 
        self.assertFalse(base_tree.has_id('file1-id'))
82
 
        self.assertEqual('subtree-root-id', base_tree.path2id('subtree'))
83
 
        self.assertEqual('subtree', base_tree.id2path('subtree-root-id'))
84
 
 
85
 
    def test_references_check_repository_support(self):
86
 
        """Users are stopped from adding a reference that can't be committed."""
87
 
        # in 0.15 the default format has a dirstate workingtree, that can
88
 
        # support tree references, but the default repository format
89
 
        # cannot.
90
 
        tree = self.make_branch_and_tree('tree', format='dirstate')
91
 
        tree2 = self.make_branch_and_tree('tree/subtree')
92
 
        out, err = self.run_bzr('join --reference tree/subtree',
93
 
                                retcode=3)
94
 
        self.assertContainsRe(err, r"Can't join trees")
95
 
        self.assertContainsRe(err, r"use bzr upgrade")