2100.3.5
by Aaron Bentley
Merge nested-trees work |
1 |
# Copyright (C) 2006 Canonical Ltd
|
1731.2.20
by Aaron Bentley
Add copyright notice to join tests |
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 |
||
1731.2.7
by Aaron Bentley
Add join command |
18 |
import os |
19 |
||
20 |
from bzrlib import bzrdir, repository, tests, workingtree |
|
21 |
||
22 |
||
23 |
class TestJoin(tests.TestCaseWithTransport): |
|
24 |
||
25 |
def make_trees(self): |
|
2100.3.17
by Aaron Bentley
Remove get_format_*, make FormatRegistry.register_metadir vary working tree |
26 |
base_tree = self.make_branch_and_tree('tree', |
2255.2.208
by Robert Collins
Remove more references to 'experimental' formats. |
27 |
format='dirstate-with-subtree') |
1731.2.7
by Aaron Bentley
Add join command |
28 |
base_tree.commit('empty commit') |
29 |
self.build_tree(['tree/subtree/', 'tree/subtree/file1']) |
|
30 |
sub_tree = self.make_branch_and_tree('tree/subtree') |
|
2100.3.11
by Aaron Bentley
Add join --reference support |
31 |
sub_tree.set_root_id('subtree-root-id') |
1731.2.7
by Aaron Bentley
Add join command |
32 |
sub_tree.add('file1', 'file1-id') |
33 |
sub_tree.commit('added file1') |
|
34 |
return base_tree, sub_tree |
|
35 |
||
36 |
def check_success(self, path): |
|
37 |
base_tree = workingtree.WorkingTree.open(path) |
|
38 |
self.assertEqual('file1-id', base_tree.path2id('subtree/file1')) |
|
39 |
||
40 |
def test_join(self): |
|
41 |
base_tree, sub_tree = self.make_trees() |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
42 |
self.run_bzr('join tree/subtree') |
1731.2.7
by Aaron Bentley
Add join command |
43 |
self.check_success('tree') |
44 |
||
45 |
def test_join_dot(self): |
|
46 |
base_tree, sub_tree = self.make_trees() |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
47 |
self.run_bzr('join .', working_dir='tree/subtree') |
1731.2.7
by Aaron Bentley
Add join command |
48 |
self.check_success('tree') |
49 |
||
50 |
def test_join_error(self): |
|
51 |
base_tree, sub_tree = self.make_trees() |
|
52 |
os.mkdir('tree/subtree2') |
|
53 |
os.rename('tree/subtree', 'tree/subtree2/subtree') |
|
2255.2.223
by Martin Pool
add stubbed out join blackbox test |
54 |
self.run_bzr_error( |
55 |
('Cannot join .*subtree. Parent directory is not versioned',), |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
56 |
'join tree/subtree2/subtree') |
2255.2.223
by Martin Pool
add stubbed out join blackbox test |
57 |
# disabled because this gives an ugly error at present -- mbp 20070306
|
58 |
## self.run_bzr_error(
|
|
59 |
## ('Cannot join .*subtree. Parent directory is not versioned',),
|
|
60 |
## 'join', '--reference', 'tree/subtree2/subtree')
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
61 |
self.run_bzr_error(('Not a branch:.*subtree2',), |
62 |
'join tree/subtree2') |
|
2100.3.11
by Aaron Bentley
Add join --reference support |
63 |
|
64 |
def test_join_reference(self): |
|
65 |
"""Join can add a reference if --reference is supplied"""
|
|
66 |
base_tree, sub_tree = self.make_trees() |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
67 |
self.run_bzr('join . --reference', working_dir='tree/subtree') |
2255.2.210
by Robert Collins
Fix test_join with dirstate default. |
68 |
sub_tree.lock_read() |
69 |
self.addCleanup(sub_tree.unlock) |
|
2100.3.11
by Aaron Bentley
Add join --reference support |
70 |
self.assertEqual('file1-id', sub_tree.path2id('file1')) |
71 |
self.assertTrue('file1-id' in sub_tree) |
|
72 |
self.assertEqual('subtree-root-id', sub_tree.path2id('')) |
|
73 |
self.assertEqual('', sub_tree.id2path('subtree-root-id')) |
|
74 |
self.assertIs(None, base_tree.path2id('subtree/file1')) |
|
2255.2.198
by Robert Collins
All test_join tests passing. |
75 |
base_tree.lock_read() |
76 |
self.addCleanup(base_tree.unlock) |
|
2100.3.11
by Aaron Bentley
Add join --reference support |
77 |
self.assertTrue('file1-id' not in base_tree) |
78 |
self.assertEqual('subtree-root-id', base_tree.path2id('subtree')) |
|
79 |
self.assertEqual('subtree', base_tree.id2path('subtree-root-id')) |
|
2255.2.235
by Martin Pool
Add blackbox test that join gives clean error when the repository doesn't support rich roots |
80 |
|
81 |
def test_references_check_repository_support(self): |
|
82 |
"""Users are stopped from adding a reference that can't be committed."""
|
|
83 |
# in 0.15 the default format has a dirstate workingtree, that can
|
|
84 |
# support tree references, but the default repository format
|
|
85 |
# cannot.
|
|
86 |
tree = self.make_branch_and_tree('tree', format='dirstate') |
|
87 |
tree2 = self.make_branch_and_tree('tree/subtree') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
88 |
out, err = self.run_bzr('join --reference tree/subtree', |
89 |
retcode=3) |
|
90 |
self.assertContainsRe(err, r"Can't join trees") |
|
91 |
self.assertContainsRe(err, r"use bzr upgrade") |
|
2255.2.235
by Martin Pool
Add blackbox test that join gives clean error when the repository doesn't support rich roots |
92 |
|
93 |