bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2006, 2007, 2009-2012, 2016 Canonical Ltd
|
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
2 |
# Authors: Robert Collins <robert.collins@canonical.com>
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
17 |
|
5409.1.1
by Vincent Ladeuil
Cleanup imports (most of them were useless). |
18 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
19 |
from breezy import tests |
20 |
from breezy.revision import NULL_REVISION |
|
21 |
from breezy.tests import per_workingtree |
|
5409.1.1
by Vincent Ladeuil
Cleanup imports (most of them were useless). |
22 |
|
23 |
||
24 |
class TestPull(per_workingtree.TestCaseWithWorkingTree): |
|
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
25 |
|
26 |
def get_pullable_trees(self): |
|
27 |
self.build_tree(['from/', 'from/file', 'to/']) |
|
28 |
tree = self.make_branch_and_tree('from') |
|
29 |
tree.add('file') |
|
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
30 |
a = tree.commit('foo') |
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
31 |
tree_b = self.make_branch_and_tree('to') |
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
32 |
return tree, tree_b, a |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
33 |
|
6243.1.1
by Jelmer Vernooij
Fix WorkingTree.pull(stop_revision='null:', overwrite=True). |
34 |
def test_pull_null(self): |
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
35 |
tree_a, tree_b, rev_a = self.get_pullable_trees() |
6243.1.1
by Jelmer Vernooij
Fix WorkingTree.pull(stop_revision='null:', overwrite=True). |
36 |
root_id = tree_a.get_root_id() |
37 |
tree_a.pull(tree_b.branch, stop_revision=NULL_REVISION, overwrite=True) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
38 |
self.assertEqual(root_id, tree_a.get_root_id()) |
6243.1.1
by Jelmer Vernooij
Fix WorkingTree.pull(stop_revision='null:', overwrite=True). |
39 |
|
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
40 |
def test_pull(self): |
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
41 |
tree_a, tree_b, rev_a = self.get_pullable_trees() |
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
42 |
tree_b.pull(tree_a.branch) |
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
43 |
self.assertTrue(tree_b.branch.repository.has_revision(rev_a)) |
44 |
self.assertEqual([rev_a], tree_b.get_parent_ids()) |
|
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
45 |
|
46 |
def test_pull_overwrites(self): |
|
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
47 |
tree_a, tree_b, rev_a = self.get_pullable_trees() |
48 |
rev_b = tree_b.commit('foo') |
|
49 |
self.assertEqual(rev_b, tree_b.branch.last_revision()) |
|
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
50 |
tree_b.pull(tree_a.branch, overwrite=True) |
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
51 |
self.assertTrue(tree_b.branch.repository.has_revision(rev_a)) |
52 |
self.assertTrue(tree_b.branch.repository.has_revision(rev_b)) |
|
53 |
self.assertEqual([rev_a], tree_b.get_parent_ids()) |
|
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
54 |
|
55 |
def test_pull_merges_tree_content(self): |
|
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
56 |
tree_a, tree_b, rev_a = self.get_pullable_trees() |
1563.1.4
by Robert Collins
Fix 'bzr pull' on metadir trees. |
57 |
tree_b.pull(tree_a.branch) |
58 |
self.assertFileEqual('contents of from/file\n', 'to/file') |
|
59 |
||
4634.123.2
by John Arbash Meinel
pull also is broken wrt root-id changes. |
60 |
def test_pull_changes_root_id(self): |
61 |
tree = self.make_branch_and_tree('from') |
|
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
62 |
if not tree._format.supports_versioned_directories: |
63 |
self.skipTest('format does not support custom root ids') |
|
4634.123.2
by John Arbash Meinel
pull also is broken wrt root-id changes. |
64 |
tree.set_root_id('first_root_id') |
65 |
self.build_tree(['from/file']) |
|
66 |
tree.add(['file']) |
|
67 |
tree.commit('first') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
68 |
to_tree = tree.controldir.sprout('to').open_workingtree() |
4634.123.2
by John Arbash Meinel
pull also is broken wrt root-id changes. |
69 |
self.assertEqual('first_root_id', to_tree.get_root_id()) |
70 |
tree.set_root_id('second_root_id') |
|
71 |
tree.commit('second') |
|
72 |
to_tree.pull(tree.branch) |
|
73 |
self.assertEqual('second_root_id', to_tree.get_root_id()) |
|
5409.1.6
by Vincent Ladeuil
Add failing tests for bug #323111. |
74 |
|
75 |
||
76 |
class TestPullWithOrphans(per_workingtree.TestCaseWithWorkingTree): |
|
77 |
||
78 |
def make_branch_deleting_dir(self, relpath=None): |
|
79 |
if relpath is None: |
|
80 |
relpath = 'trunk' |
|
81 |
builder = self.make_branch_builder(relpath) |
|
82 |
builder.start_series() |
|
83 |
||
84 |
# Create an empty trunk
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
85 |
builder.build_snapshot(None, [ |
86 |
('add', ('', 'root-id', 'directory', ''))], |
|
87 |
revision_id='1') |
|
88 |
builder.build_snapshot(['1'], [ |
|
5409.1.6
by Vincent Ladeuil
Add failing tests for bug #323111. |
89 |
('add', ('dir', 'dir-id', 'directory', '')), |
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
90 |
('add', ('file', 'file-id', 'file', 'trunk content\n')),], |
91 |
revision_id='2') |
|
92 |
builder.build_snapshot(['2'], [ |
|
93 |
('unversion', 'dir-id'),], |
|
94 |
revision_id='3') |
|
5409.1.6
by Vincent Ladeuil
Add failing tests for bug #323111. |
95 |
builder.finish_series() |
96 |
return builder.get_branch() |
|
97 |
||
98 |
def test_pull_orphans(self): |
|
5661.1.1
by Jelmer Vernooij
Add 'WorkingTreeFormat.missing_parent_conflicts' flag to use in tests. |
99 |
if not self.workingtree_format.missing_parent_conflicts: |
5409.1.6
by Vincent Ladeuil
Add failing tests for bug #323111. |
100 |
raise tests.TestSkipped( |
5661.1.1
by Jelmer Vernooij
Add 'WorkingTreeFormat.missing_parent_conflicts' flag to use in tests. |
101 |
'%r does not support missing parent conflicts' % |
102 |
self.workingtree_format) |
|
5409.1.6
by Vincent Ladeuil
Add failing tests for bug #323111. |
103 |
trunk = self.make_branch_deleting_dir('trunk') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
104 |
work = trunk.controldir.sprout('work', revision_id='2').open_workingtree() |
6449.3.2
by Jelmer Vernooij
Use config stack in tests, too. |
105 |
work.branch.get_config_stack().set( |
6883.13.1
by Jelmer Vernooij
Rename bzr.transform.orphan_policy -> transform.orphan_policy. |
106 |
'transform.orphan_policy', 'move') |
5409.7.2
by Vincent Ladeuil
Add NEWS entry, a missing test and some cleanup. |
107 |
# Add some unversioned files in dir
|
108 |
self.build_tree(['work/dir/foo', |
|
109 |
'work/dir/subdir/', |
|
110 |
'work/dir/subdir/foo']) |
|
5409.1.6
by Vincent Ladeuil
Add failing tests for bug #323111. |
111 |
work.pull(trunk) |
112 |
self.assertLength(0, work.conflicts()) |
|
5409.7.2
by Vincent Ladeuil
Add NEWS entry, a missing test and some cleanup. |
113 |
# The directory removal should succeed
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
114 |
self.assertPathDoesNotExist('work/dir') |