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) 2009, 2010, 2016 Canonical Ltd
|
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
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 |
"""Tests for bzrdir implementations - push."""
|
|
18 |
||
|
7289.1.1
by Jelmer Vernooij
Add test for push_branch with tags. |
19 |
from ...errors import ( |
20 |
LossyPushToSameVCS, |
|
21 |
TagsNotSupported, |
|
|
7490.68.1
by Jelmer Vernooij
Raise NoSuchRevision rather than KeyError. |
22 |
NoSuchRevision, |
|
7289.1.1
by Jelmer Vernooij
Add test for push_branch with tags. |
23 |
)
|
24 |
from ...revision import NULL_REVISION |
|
25 |
from .. import TestNotApplicable |
|
|
6929.14.2
by Jelmer Vernooij
Support --lossy argument to 'brz push'. |
26 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
27 |
from breezy.tests.per_controldir import ( |
|
5363.2.18
by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir. |
28 |
TestCaseWithControlDir, |
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
29 |
)
|
30 |
||
31 |
||
|
5363.2.18
by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir. |
32 |
class TestPush(TestCaseWithControlDir): |
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
33 |
|
34 |
def create_simple_tree(self): |
|
35 |
tree = self.make_branch_and_tree('tree') |
|
36 |
self.build_tree(['tree/a']) |
|
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
37 |
tree.add(['a']) |
|
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
38 |
rev_1 = tree.commit('one') |
39 |
return tree, rev_1 |
|
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
40 |
|
|
4462.3.1
by Robert Collins
Whitespace cleanup. |
41 |
def test_push_new_branch(self): |
|
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
42 |
tree, rev_1 = self.create_simple_tree() |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
43 |
dir = self.make_repository('dir').controldir |
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
44 |
result = dir.push_branch(tree.branch) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
45 |
self.assertEqual(tree.branch, result.source_branch) |
46 |
self.assertEqual(dir.open_branch().base, result.target_branch.base) |
|
47 |
self.assertEqual(dir.open_branch().base, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
48 |
tree.branch.get_push_location()) |
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
49 |
|
|
7490.68.1
by Jelmer Vernooij
Raise NoSuchRevision rather than KeyError. |
50 |
def test_push_no_such_revision(self): |
51 |
tree, rev_1 = self.create_simple_tree() |
|
52 |
dir = self.make_repository('dir').controldir |
|
53 |
self.assertRaises( |
|
54 |
NoSuchRevision, dir.push_branch, |
|
55 |
tree.branch, revision_id=b'idonotexist') |
|
56 |
||
|
7289.1.1
by Jelmer Vernooij
Add test for push_branch with tags. |
57 |
def test_push_new_branch_fetch_tags(self): |
58 |
builder = self.make_branch_builder('from') |
|
59 |
builder.start_series() |
|
60 |
rev_1 = builder.build_snapshot(None, [ |
|
61 |
('add', ('', None, 'directory', '')), |
|
62 |
('add', ('filename', None, 'file', b'content'))]) |
|
63 |
rev_2 = builder.build_snapshot( |
|
64 |
[rev_1], [('modify', ('filename', b'new-content\n'))]) |
|
65 |
rev_3 = builder.build_snapshot( |
|
66 |
[rev_1], [('modify', ('filename', b'new-new-content\n'))]) |
|
67 |
builder.finish_series() |
|
68 |
branch = builder.get_branch() |
|
69 |
try: |
|
70 |
branch.tags.set_tag('atag', rev_2) |
|
71 |
except TagsNotSupported: |
|
72 |
raise TestNotApplicable('source format does not support tags') |
|
73 |
||
74 |
dir = self.make_repository('target').controldir |
|
75 |
branch.get_config().set_user_option('branch.fetch_tags', True) |
|
76 |
result = dir.push_branch(branch) |
|
77 |
self.assertEqual( |
|
78 |
set([rev_1, rev_2, rev_3]), |
|
79 |
set(result.source_branch.repository.all_revision_ids())) |
|
80 |
self.assertEqual( |
|
81 |
{'atag': rev_2}, result.source_branch.tags.get_tag_dict()) |
|
82 |
||
|
6929.14.2
by Jelmer Vernooij
Support --lossy argument to 'brz push'. |
83 |
def test_push_new_branch_lossy(self): |
84 |
tree, rev_1 = self.create_simple_tree() |
|
85 |
dir = self.make_repository('dir').controldir |
|
86 |
self.assertRaises(LossyPushToSameVCS, dir.push_branch, |
|
87 |
tree.branch, lossy=True) |
|
88 |
||
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
89 |
def test_push_new_empty(self): |
90 |
tree = self.make_branch_and_tree('tree') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
91 |
dir = self.make_repository('dir').controldir |
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
92 |
result = dir.push_branch(tree.branch) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
93 |
self.assertEqual(tree.branch.base, result.source_branch.base) |
94 |
self.assertEqual(dir.open_branch().base, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
95 |
result.target_branch.base) |
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
96 |
|
97 |
def test_push_incremental(self): |
|
|
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
98 |
tree, rev1 = self.create_simple_tree() |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
99 |
dir = self.make_repository('dir').controldir |
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
100 |
dir.push_branch(tree.branch) |
101 |
self.build_tree(['tree/b']) |
|
102 |
tree.add(['b']) |
|
|
6747.4.2
by Jelmer Vernooij
Avoid setting revision ids in a few more places. |
103 |
rev_2 = tree.commit('two') |
|
3978.3.16
by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch(). |
104 |
result = dir.push_branch(tree.branch) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
105 |
self.assertEqual(tree.last_revision(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
106 |
result.branch_push_result.new_revid) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
107 |
self.assertEqual(2, result.branch_push_result.new_revno) |
108 |
self.assertEqual(tree.branch.base, result.source_branch.base) |
|
109 |
self.assertEqual(dir.open_branch().base, result.target_branch.base) |
|
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
110 |
|
111 |
def test_push_tag_selector(self): |
|
112 |
tree, rev1 = self.create_simple_tree() |
|
113 |
try: |
|
114 |
tree.branch.tags.set_tag('tag1', rev1) |
|
115 |
except TagsNotSupported: |
|
116 |
raise TestNotApplicable('tags not supported') |
|
117 |
tree.branch.tags.set_tag('tag2', rev1) |
|
118 |
dir = self.make_repository('dir').controldir |
|
119 |
dir.push_branch(tree.branch, tag_selector=lambda x: x == 'tag1') |
|
120 |
self.assertEqual({'tag1': rev1}, dir.open_branch().tags.get_tag_dict()) |