1731.2.16
by Aaron Bentley
Get extract working for standalone trees |
1 |
# Copyright (C) 2006 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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1731.2.16
by Aaron Bentley
Get extract working for standalone trees |
16 |
|
1731.2.17
by Aaron Bentley
Support extracting with checkouts |
17 |
from bzrlib import ( |
1731.2.18
by Aaron Bentley
Get extract in repository under test |
18 |
branch, |
19 |
bzrdir, |
|
1731.2.17
by Aaron Bentley
Support extracting with checkouts |
20 |
errors, |
21 |
)
|
|
1731.2.16
by Aaron Bentley
Get extract working for standalone trees |
22 |
from bzrlib.tests import TestCaseWithTransport |
23 |
||
24 |
||
25 |
class TestExtract(TestCaseWithTransport): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
26 |
|
1731.2.16
by Aaron Bentley
Get extract working for standalone trees |
27 |
def test_extract(self): |
28 |
self.build_tree(['a/', 'a/b/', 'a/b/c', 'a/d']) |
|
3113.6.5
by Aaron Bentley
Update tests |
29 |
wt = self.make_branch_and_tree('a', format='rich-root-pack') |
1731.2.16
by Aaron Bentley
Get extract working for standalone trees |
30 |
wt.add(['b', 'b/c', 'd'], ['b-id', 'c-id', 'd-id']) |
31 |
wt.commit('added files') |
|
32 |
b_wt = wt.extract('b-id') |
|
33 |
self.assertEqual('b-id', b_wt.get_root_id()) |
|
34 |
self.assertEqual('c-id', b_wt.path2id('c')) |
|
35 |
self.assertEqual('c', b_wt.id2path('c-id')) |
|
36 |
self.assertRaises(errors.BzrError, wt.id2path, 'b-id') |
|
37 |
self.assertEqual(b_wt.basedir, wt.abspath('b')) |
|
38 |
self.assertEqual(wt.get_parent_ids(), b_wt.get_parent_ids()) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
39 |
self.assertEqual(wt.branch.last_revision(), |
1731.2.21
by Aaron Bentley
Ensure extracting a subtree dupes the branch |
40 |
b_wt.branch.last_revision()) |
1731.2.17
by Aaron Bentley
Support extracting with checkouts |
41 |
|
1731.2.18
by Aaron Bentley
Get extract in repository under test |
42 |
def extract_in_checkout(self, a_branch): |
1731.2.17
by Aaron Bentley
Support extracting with checkouts |
43 |
self.build_tree(['a/', 'a/b/', 'a/b/c/', 'a/b/c/d']) |
44 |
wt = a_branch.create_checkout('a', lightweight=True) |
|
45 |
wt.add(['b', 'b/c', 'b/c/d'], ['b-id', 'c-id', 'd-id']) |
|
46 |
wt.commit('added files') |
|
1731.2.18
by Aaron Bentley
Get extract in repository under test |
47 |
return wt.extract('b-id') |
48 |
||
49 |
def test_extract_in_checkout(self): |
|
3113.6.5
by Aaron Bentley
Update tests |
50 |
a_branch = self.make_branch('branch', format='rich-root-pack') |
1731.2.18
by Aaron Bentley
Get extract in repository under test |
51 |
self.extract_in_checkout(a_branch) |
1731.2.17
by Aaron Bentley
Support extracting with checkouts |
52 |
b_branch = branch.Branch.open('branch/b') |
53 |
b_branch_ref = branch.Branch.open('a/b') |
|
54 |
self.assertEqual(b_branch.base, b_branch_ref.base) |
|
55 |
||
56 |
def test_extract_in_deep_checkout(self): |
|
3113.6.5
by Aaron Bentley
Update tests |
57 |
a_branch = self.make_branch('branch', format='rich-root-pack') |
1731.2.17
by Aaron Bentley
Support extracting with checkouts |
58 |
self.build_tree(['a/', 'a/b/', 'a/b/c/', 'a/b/c/d/', 'a/b/c/d/e']) |
59 |
wt = a_branch.create_checkout('a', lightweight=True) |
|
60 |
wt.add(['b', 'b/c', 'b/c/d', 'b/c/d/e/'], ['b-id', 'c-id', 'd-id', |
|
61 |
'e-id']) |
|
62 |
wt.commit('added files') |
|
63 |
b_wt = wt.extract('d-id') |
|
64 |
b_branch = branch.Branch.open('branch/b/c/d') |
|
65 |
b_branch_ref = branch.Branch.open('a/b/c/d') |
|
66 |
self.assertEqual(b_branch.base, b_branch_ref.base) |
|
1731.2.18
by Aaron Bentley
Get extract in repository under test |
67 |
|
68 |
def test_bad_repo_format(self): |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
69 |
repo = self.make_repository('branch', shared=True, |
2100.3.17
by Aaron Bentley
Remove get_format_*, make FormatRegistry.register_metadir vary working tree |
70 |
format='knit') |
1731.2.18
by Aaron Bentley
Get extract in repository under test |
71 |
a_branch = repo.bzrdir.create_branch() |
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
72 |
self.assertRaises(errors.RootNotRich, self.extract_in_checkout, |
1731.2.18
by Aaron Bentley
Get extract in repository under test |
73 |
a_branch) |
74 |
||
75 |
def test_good_repo_format(self): |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
76 |
repo = self.make_repository('branch', shared=True, |
77 |
format='dirstate-with-subtree') |
|
1731.2.18
by Aaron Bentley
Get extract in repository under test |
78 |
a_branch = repo.bzrdir.create_branch() |
79 |
wt_b = self.extract_in_checkout(a_branch) |
|
80 |
self.assertEqual(wt_b.branch.repository.bzrdir.transport.base, |
|
81 |
repo.bzrdir.transport.base) |