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-2012, 2016 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
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
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
16 |
|
17 |
||
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
18 |
"""Black-box tests for brz push."""
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
19 |
|
|
3066.3.2
by jml at canonical
Add tests to check the handling of TooManyRedirections. |
20 |
import re |
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
21 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
22 |
from breezy import ( |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
23 |
branch, |
|
6207.3.3
by jelmer at samba
Fix tests and the like. |
24 |
controldir, |
|
7290.8.1
by Jelmer Vernooij
Add test for derefencing directories in --stacked-on. |
25 |
directory_service, |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
26 |
errors, |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
27 |
osutils, |
28 |
tests, |
|
|
3878.4.4
by Vincent Ladeuil
Cleanup. |
29 |
transport, |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
30 |
uncommit, |
|
2220.2.9
by Martin Pool
Add specific tests for push -d and pull -d |
31 |
urlutils, |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
32 |
workingtree
|
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
33 |
)
|
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
34 |
from breezy.bzr import ( |
35 |
bzrdir, |
|
36 |
)
|
|
|
6670.4.5
by Jelmer Vernooij
Move breezy.repofmt contents to breezy.bzr. |
37 |
from breezy.bzr import knitrepo |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
38 |
from breezy.tests import ( |
|
4925.1.1
by Jelmer Vernooij
Print a proper error when attempting to push to a foreign VCS for which |
39 |
http_server, |
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
40 |
scenarios, |
|
6175.2.4
by Vincent Ladeuil
Add script tests and documentation. |
41 |
script, |
|
4925.1.1
by Jelmer Vernooij
Print a proper error when attempting to push to a foreign VCS for which |
42 |
test_foreign, |
43 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
44 |
from breezy.transport import memory |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
45 |
|
46 |
||
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
47 |
load_tests = scenarios.load_tests_apply_scenarios |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
48 |
|
49 |
||
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
50 |
class TestPush(tests.TestCaseWithTransport): |
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
51 |
|
|
4017.2.3
by Robert Collins
Review feedback. |
52 |
def test_push_error_on_vfs_http(self): |
53 |
""" pushing a branch to a HTTP server fails cleanly. """ |
|
54 |
# the trunk is published on a web server
|
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
55 |
self.transport_readonly_server = http_server.HttpServer |
|
4017.2.3
by Robert Collins
Review feedback. |
56 |
self.make_branch('source') |
57 |
public_url = self.get_readonly_url('target') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
58 |
self.run_bzr_error(['http does not support mkdir'], |
|
4017.2.3
by Robert Collins
Review feedback. |
59 |
['push', public_url], |
60 |
working_dir='source') |
|
61 |
||
|
6394.1.1
by Jelmer Vernooij
Suggest using :parent in "bzr push" if there was no push location specified or remembered. |
62 |
def test_push_suggests_parent_alias(self): |
63 |
"""Push suggests using :parent if there is a known parent branch.""" |
|
64 |
tree_a = self.make_branch_and_tree('a') |
|
65 |
tree_a.commit('this is a commit') |
|
66 |
tree_b = self.make_branch_and_tree('b') |
|
67 |
||
68 |
# If there is no parent location set, :parent isn't mentioned.
|
|
69 |
out = self.run_bzr('push', working_dir='a', retcode=3) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
70 |
self.assertEqual(out, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
71 |
('', 'brz: ERROR: No push location known or specified.\n')) |
|
6394.1.1
by Jelmer Vernooij
Suggest using :parent in "bzr push" if there was no push location specified or remembered. |
72 |
|
73 |
# If there is a parent location set, the error suggests :parent.
|
|
74 |
tree_a.branch.set_parent(tree_b.branch.base) |
|
75 |
out = self.run_bzr('push', working_dir='a', retcode=3) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
76 |
self.assertEqual(out, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
77 |
('', 'brz: ERROR: No push location known or specified. ' |
78 |
'To push to the parent branch '
|
|
79 |
'(at %s), use \'brz push :parent\'.\n' % |
|
80 |
urlutils.unescape_for_display(tree_b.branch.base, 'utf-8'))) |
|
|
6394.1.1
by Jelmer Vernooij
Suggest using :parent in "bzr push" if there was no push location specified or remembered. |
81 |
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
82 |
def test_push_remember(self): |
83 |
"""Push changes from one branch to another and test push location.""" |
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
84 |
transport = self.get_transport() |
85 |
tree_a = self.make_branch_and_tree('branch_a') |
|
86 |
branch_a = tree_a.branch |
|
87 |
self.build_tree(['branch_a/a']) |
|
88 |
tree_a.add('a') |
|
89 |
tree_a.commit('commit a') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
90 |
tree_b = branch_a.controldir.sprout('branch_b').open_workingtree() |
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
91 |
branch_b = tree_b.branch |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
92 |
tree_c = branch_a.controldir.sprout('branch_c').open_workingtree() |
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
93 |
branch_c = tree_c.branch |
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
94 |
self.build_tree(['branch_a/b']) |
95 |
tree_a.add('b') |
|
96 |
tree_a.commit('commit b') |
|
97 |
self.build_tree(['branch_b/c']) |
|
98 |
tree_b.add('c') |
|
99 |
tree_b.commit('commit c') |
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
100 |
# initial push location must be empty
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
101 |
self.assertEqual(None, branch_b.get_push_location()) |
|
1785.1.2
by John Arbash Meinel
Push should only save the location if it can actually connect (doesn't need to succeed) |
102 |
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
103 |
# test push for failure without push location set
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
104 |
out = self.run_bzr('push', working_dir='branch_a', retcode=3) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
105 |
self.assertEqual(out, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
106 |
('', 'brz: ERROR: No push location known or specified.\n')) |
|
1785.1.2
by John Arbash Meinel
Push should only save the location if it can actually connect (doesn't need to succeed) |
107 |
|
108 |
# test not remembered if cannot actually push
|
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
109 |
self.run_bzr('push path/which/doesnt/exist', |
110 |
working_dir='branch_a', retcode=3) |
|
111 |
out = self.run_bzr('push', working_dir='branch_a', retcode=3) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
112 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
113 |
('', 'brz: ERROR: No push location known or specified.\n'), |
114 |
out) |
|
|
1785.1.2
by John Arbash Meinel
Push should only save the location if it can actually connect (doesn't need to succeed) |
115 |
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
116 |
# test implicit --remember when no push location set, push fails
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
117 |
out = self.run_bzr('push ../branch_b', |
118 |
working_dir='branch_a', retcode=3) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
119 |
self.assertEqual(out, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
120 |
('', 'brz: ERROR: These branches have diverged. ' |
121 |
'See "brz help diverged-branches" for more information.\n')) |
|
|
6404.6.6
by Vincent Ladeuil
Use idioms coherently and add comments to make their purpose clearer. |
122 |
# Refresh the branch as 'push' modified it
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
123 |
branch_a = branch_a.controldir.open_branch() |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
124 |
self.assertEqual(osutils.abspath(branch_a.get_push_location()), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
125 |
osutils.abspath(branch_b.controldir.root_transport.base)) |
|
1785.1.2
by John Arbash Meinel
Push should only save the location if it can actually connect (doesn't need to succeed) |
126 |
|
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
127 |
# test implicit --remember after resolving previous failure
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
128 |
uncommit.uncommit(branch=branch_b, tree=tree_b) |
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
129 |
transport.delete('branch_b/c') |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
130 |
out, err = self.run_bzr('push', working_dir='branch_a') |
|
6404.6.6
by Vincent Ladeuil
Use idioms coherently and add comments to make their purpose clearer. |
131 |
# Refresh the branch as 'push' modified it
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
132 |
branch_a = branch_a.controldir.open_branch() |
|
1785.1.1
by John Arbash Meinel
Fix the output of 'bzr push' so that it prints the location correctly. |
133 |
path = branch_a.get_push_location() |
|
2220.2.38
by Martin Pool
Tag conflicts from push go to stdout. |
134 |
self.assertEqual(err, |
|
5998.1.3
by Jonathan Riddell
add a test for bzr push -q |
135 |
'Using saved push location: %s\n' |
|
3978.2.2
by Jelmer Vernooij
Write status messages during push to stderr rather than stdout. |
136 |
'All changes applied successfully.\n' |
|
5998.1.3
by Jonathan Riddell
add a test for bzr push -q |
137 |
'Pushed up to revision 2.\n' |
138 |
% urlutils.local_path_from_url(path)) |
|
|
1785.1.1
by John Arbash Meinel
Fix the output of 'bzr push' so that it prints the location correctly. |
139 |
self.assertEqual(path, |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
140 |
branch_b.controldir.root_transport.base) |
|
1614.2.9
by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to |
141 |
# test explicit --remember
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
142 |
self.run_bzr('push ../branch_c --remember', working_dir='branch_a') |
|
6404.6.6
by Vincent Ladeuil
Use idioms coherently and add comments to make their purpose clearer. |
143 |
# Refresh the branch as 'push' modified it
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
144 |
branch_a = branch_a.controldir.open_branch() |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
145 |
self.assertEqual(branch_a.get_push_location(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
146 |
branch_c.controldir.root_transport.base) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
147 |
|
|
1692.3.1
by Robert Collins
Fix push to work with just a branch, no need for a working tree. |
148 |
def test_push_without_tree(self): |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
149 |
# brz push from a branch that does not have a checkout should work.
|
|
1692.3.1
by Robert Collins
Fix push to work with just a branch, no need for a working tree. |
150 |
b = self.make_branch('.') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
151 |
out, err = self.run_bzr('push pushed-location') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
152 |
self.assertEqual('', out) |
153 |
self.assertEqual('Created new branch.\n', err) |
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
154 |
b2 = branch.Branch.open('pushed-location') |
|
1692.3.1
by Robert Collins
Fix push to work with just a branch, no need for a working tree. |
155 |
self.assertEndsWith(b2.base, 'pushed-location/') |
|
1692.3.6
by Robert Collins
Show the correct number of revisions pushed when pushing a new branch (Robert Collins). |
156 |
|
|
5448.6.5
by Matthew Gordon
Added test for push --no-tree. |
157 |
def test_push_no_tree(self): |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
158 |
# brz push --no-tree of a branch with working trees
|
|
5448.6.5
by Matthew Gordon
Added test for push --no-tree. |
159 |
b = self.make_branch_and_tree('push-from') |
160 |
self.build_tree(['push-from/file']) |
|
161 |
b.add('file') |
|
162 |
b.commit('commit 1') |
|
163 |
out, err = self.run_bzr('push --no-tree -d push-from push-to') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
164 |
self.assertEqual('', out) |
165 |
self.assertEqual('Created new branch.\n', err) |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
166 |
self.assertPathDoesNotExist('push-to/file') |
|
5448.6.5
by Matthew Gordon
Added test for push --no-tree. |
167 |
|
|
1692.3.6
by Robert Collins
Show the correct number of revisions pushed when pushing a new branch (Robert Collins). |
168 |
def test_push_new_branch_revision_count(self): |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
169 |
# brz push of a branch with revisions to a new location
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
170 |
# should print the number of revisions equal to the length of the
|
|
1692.3.6
by Robert Collins
Show the correct number of revisions pushed when pushing a new branch (Robert Collins). |
171 |
# local branch.
|
172 |
t = self.make_branch_and_tree('tree') |
|
173 |
self.build_tree(['tree/file']) |
|
174 |
t.add('file') |
|
175 |
t.commit('commit 1') |
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
176 |
out, err = self.run_bzr('push -d tree pushed-to') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
177 |
self.assertEqual('', out) |
178 |
self.assertEqual('Created new branch.\n', err) |
|
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
179 |
|
|
5998.1.3
by Jonathan Riddell
add a test for bzr push -q |
180 |
def test_push_quiet(self): |
181 |
# test that using -q makes output quiet
|
|
182 |
t = self.make_branch_and_tree('tree') |
|
183 |
self.build_tree(['tree/file']) |
|
184 |
t.add('file') |
|
185 |
t.commit('commit 1') |
|
186 |
self.run_bzr('push -d tree pushed-to') |
|
|
6404.6.6
by Vincent Ladeuil
Use idioms coherently and add comments to make their purpose clearer. |
187 |
# Refresh the branch as 'push' modified it and get the push location
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
188 |
push_loc = t.branch.controldir.open_branch().get_push_location() |
|
5998.1.3
by Jonathan Riddell
add a test for bzr push -q |
189 |
out, err = self.run_bzr('push', working_dir="tree") |
|
6112.4.3
by Jelmer Vernooij
Fix push tests. |
190 |
self.assertEqual('Using saved push location: %s\n' |
191 |
'No new revisions or tags to push.\n' % |
|
|
6404.6.6
by Vincent Ladeuil
Use idioms coherently and add comments to make their purpose clearer. |
192 |
urlutils.local_path_from_url(push_loc), err) |
|
5998.1.3
by Jonathan Riddell
add a test for bzr push -q |
193 |
out, err = self.run_bzr('push -q', working_dir="tree") |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
194 |
self.assertEqual('', out) |
195 |
self.assertEqual('', err) |
|
|
5998.1.3
by Jonathan Riddell
add a test for bzr push -q |
196 |
|
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
197 |
def test_push_only_pushes_history(self): |
198 |
# Knit branches should only push the history for the current revision.
|
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
199 |
format = bzrdir.BzrDirMetaFormat1() |
200 |
format.repository_format = knitrepo.RepositoryFormatKnit1() |
|
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
201 |
shared_repo = self.make_repository('repo', format=format, shared=True) |
202 |
shared_repo.set_make_working_trees(True) |
|
203 |
||
204 |
def make_shared_tree(path): |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
205 |
shared_repo.controldir.root_transport.mkdir(path) |
|
6207.3.3
by jelmer at samba
Fix tests and the like. |
206 |
controldir.ControlDir.create_branch_convenience('repo/' + path) |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
207 |
return workingtree.WorkingTree.open('repo/' + path) |
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
208 |
tree_a = make_shared_tree('a') |
209 |
self.build_tree(['repo/a/file']) |
|
210 |
tree_a.add('file') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
211 |
tree_a.commit('commit a-1', rev_id=b'a-1') |
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
212 |
f = open('repo/a/file', 'ab') |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
213 |
f.write(b'more stuff\n') |
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
214 |
f.close() |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
215 |
tree_a.commit('commit a-2', rev_id=b'a-2') |
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
216 |
|
217 |
tree_b = make_shared_tree('b') |
|
218 |
self.build_tree(['repo/b/file']) |
|
219 |
tree_b.add('file') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
220 |
tree_b.commit('commit b-1', rev_id=b'b-1') |
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
221 |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
222 |
self.assertTrue(shared_repo.has_revision(b'a-1')) |
223 |
self.assertTrue(shared_repo.has_revision(b'a-2')) |
|
224 |
self.assertTrue(shared_repo.has_revision(b'b-1')) |
|
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
225 |
|
226 |
# Now that we have a repository with shared files, make sure
|
|
227 |
# that things aren't copied out by a 'push'
|
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
228 |
self.run_bzr('push ../../push-b', working_dir='repo/b') |
229 |
pushed_tree = workingtree.WorkingTree.open('push-b') |
|
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
230 |
pushed_repo = pushed_tree.branch.repository |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
231 |
self.assertFalse(pushed_repo.has_revision(b'a-1')) |
232 |
self.assertFalse(pushed_repo.has_revision(b'a-2')) |
|
233 |
self.assertTrue(pushed_repo.has_revision(b'b-1')) |
|
|
1711.2.3
by John Arbash Meinel
Fix push to only push revisions in the current ancestry. (bug???) |
234 |
|
|
1843.2.1
by Aaron Bentley
Add failing tests for funky ids |
235 |
def test_push_funky_id(self): |
236 |
t = self.make_branch_and_tree('tree') |
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
237 |
self.build_tree(['tree/filename']) |
|
7045.1.14
by Jelmer Vernooij
More fixes. |
238 |
t.add('filename', b'funky-chars<>%&;"\'') |
|
1843.2.1
by Aaron Bentley
Add failing tests for funky ids |
239 |
t.commit('commit filename') |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
240 |
self.run_bzr('push -d tree new-tree') |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
241 |
|
|
2220.2.9
by Martin Pool
Add specific tests for push -d and pull -d |
242 |
def test_push_dash_d(self): |
243 |
t = self.make_branch_and_tree('from') |
|
244 |
t.commit(allow_pointless=True, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
245 |
message='first commit') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
246 |
self.run_bzr('push -d from to-one') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
247 |
self.assertPathExists('to-one') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
248 |
self.run_bzr('push -d %s %s' |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
249 |
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two']))) |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
250 |
self.assertPathExists('to-two') |
|
2279.3.1
by mbp at sourcefrog
Add a -d option to push, pull, merge (ported from tags branch) |
251 |
|
|
5609.26.1
by John Arbash Meinel
Fix bug #465517, 'bzr push' to a target with a repo but no branch |
252 |
def test_push_repository_no_branch_doesnt_fetch_all_revs(self): |
253 |
# See https://bugs.launchpad.net/bzr/+bug/465517
|
|
254 |
target_repo = self.make_repository('target') |
|
255 |
source = self.make_branch_builder('source') |
|
256 |
source.start_series() |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
257 |
source.build_snapshot(None, [ |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
258 |
('add', ('', b'root-id', 'directory', None))], |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
259 |
revision_id=b'A') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
260 |
source.build_snapshot([b'A'], [], revision_id=b'B') |
261 |
source.build_snapshot([b'A'], [], revision_id=b'C') |
|
|
5609.26.1
by John Arbash Meinel
Fix bug #465517, 'bzr push' to a target with a repo but no branch |
262 |
source.finish_series() |
263 |
self.run_bzr('push target -d source') |
|
264 |
self.addCleanup(target_repo.lock_read().unlock) |
|
265 |
# We should have pushed 'C', but not 'B', since it isn't in the
|
|
266 |
# ancestry
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
267 |
self.assertEqual([(b'A',), (b'C',)], sorted( |
268 |
target_repo.revisions.keys())) |
|
|
5609.26.1
by John Arbash Meinel
Fix bug #465517, 'bzr push' to a target with a repo but no branch |
269 |
|
|
4416.3.1
by Jonathan Lange
Add two tests, the second of which demonstrates bug 385132. |
270 |
def test_push_smart_with_default_stacking_url_path_segment(self): |
|
4416.3.2
by Jonathan Lange
Comment the blackbox tests, for my own sanity. |
271 |
# If the default stacked-on location is a path element then branches
|
272 |
# we push there over the smart server are stacked and their
|
|
273 |
# stacked_on_url is that exact path segment. Added to nail bug 385132.
|
|
|
4416.3.1
by Jonathan Lange
Add two tests, the second of which demonstrates bug 385132. |
274 |
self.setup_smart_server_with_call_log() |
275 |
self.make_branch('stack-on', format='1.9') |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
276 |
self.make_controldir('.').get_config().set_default_stack_on( |
|
4416.3.9
by Jonathan Lange
Put the test back the way it was. |
277 |
'/stack-on') |
|
4416.3.1
by Jonathan Lange
Add two tests, the second of which demonstrates bug 385132. |
278 |
self.make_branch('from', format='1.9') |
279 |
out, err = self.run_bzr(['push', '-d', 'from', self.get_url('to')]) |
|
|
4416.3.10
by Jonathan Lange
Merge trunk |
280 |
b = branch.Branch.open(self.get_url('to')) |
|
4416.3.12
by Jonathan Lange
This makes the test pass, but it's a bit ick. |
281 |
self.assertEqual('/extra/stack-on', b.get_stacked_on_url()) |
|
4416.3.1
by Jonathan Lange
Add two tests, the second of which demonstrates bug 385132. |
282 |
|
283 |
def test_push_smart_with_default_stacking_relative_path(self): |
|
|
4416.3.2
by Jonathan Lange
Comment the blackbox tests, for my own sanity. |
284 |
# If the default stacked-on location is a relative path then branches
|
285 |
# we push there over the smart server are stacked and their
|
|
286 |
# stacked_on_url is a relative path. Added to nail bug 385132.
|
|
|
4416.3.1
by Jonathan Lange
Add two tests, the second of which demonstrates bug 385132. |
287 |
self.setup_smart_server_with_call_log() |
288 |
self.make_branch('stack-on', format='1.9') |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
289 |
self.make_controldir('.').get_config().set_default_stack_on('stack-on') |
|
4416.3.1
by Jonathan Lange
Add two tests, the second of which demonstrates bug 385132. |
290 |
self.make_branch('from', format='1.9') |
291 |
out, err = self.run_bzr(['push', '-d', 'from', self.get_url('to')]) |
|
|
4416.3.10
by Jonathan Lange
Merge trunk |
292 |
b = branch.Branch.open(self.get_url('to')) |
293 |
self.assertEqual('../stack-on', b.get_stacked_on_url()) |
|
|
4416.3.1
by Jonathan Lange
Add two tests, the second of which demonstrates bug 385132. |
294 |
|
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
295 |
def create_simple_tree(self): |
296 |
tree = self.make_branch_and_tree('tree') |
|
297 |
self.build_tree(['tree/a']) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
298 |
tree.add(['a'], [b'a-id']) |
299 |
tree.commit('one', rev_id=b'r1') |
|
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
300 |
return tree |
301 |
||
302 |
def test_push_create_prefix(self): |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
303 |
"""'brz push --create-prefix' will create leading directories.""" |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
304 |
tree = self.create_simple_tree() |
305 |
||
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
306 |
self.run_bzr_error(['Parent directory of ../new/tree does not exist'], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
307 |
'push ../new/tree', |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
308 |
working_dir='tree') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
309 |
self.run_bzr('push ../new/tree --create-prefix', |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
310 |
working_dir='tree') |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
311 |
new_tree = workingtree.WorkingTree.open('new/tree') |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
312 |
self.assertEqual(tree.last_revision(), new_tree.last_revision()) |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
313 |
self.assertPathExists('new/tree/a') |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
314 |
|
315 |
def test_push_use_existing(self): |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
316 |
"""'brz push --use-existing-dir' can push into an existing dir. |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
317 |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
318 |
By default, 'brz push' will not use an existing, non-versioned dir.
|
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
319 |
"""
|
320 |
tree = self.create_simple_tree() |
|
321 |
self.build_tree(['target/']) |
|
322 |
||
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
323 |
self.run_bzr_error(['Target directory ../target already exists', |
324 |
'Supply --use-existing-dir', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
325 |
],
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
326 |
'push ../target', working_dir='tree') |
|
2227.3.4
by John Arbash Meinel
Switch back to --use-existing-dir |
327 |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
328 |
self.run_bzr('push --use-existing-dir ../target', |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
329 |
working_dir='tree') |
330 |
||
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
331 |
new_tree = workingtree.WorkingTree.open('target') |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
332 |
self.assertEqual(tree.last_revision(), new_tree.last_revision()) |
333 |
# The push should have created target/a
|
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
334 |
self.assertPathExists('target/a') |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
335 |
|
|
4634.105.1
by Andrew Bennetts
Fix traceback when doing 'bzr push --use-existing-dir' into a dir with an invalid .bzr directory. |
336 |
def test_push_use_existing_into_empty_bzrdir(self): |
|
6622.1.30
by Jelmer Vernooij
Some more test fixes. |
337 |
"""'brz push --use-existing-dir' into a dir with an empty .bzr dir |
|
4634.105.1
by Andrew Bennetts
Fix traceback when doing 'bzr push --use-existing-dir' into a dir with an invalid .bzr directory. |
338 |
fails.
|
339 |
"""
|
|
340 |
tree = self.create_simple_tree() |
|
341 |
self.build_tree(['target/', 'target/.bzr/']) |
|
342 |
self.run_bzr_error( |
|
|
6622.1.30
by Jelmer Vernooij
Some more test fixes. |
343 |
['Target directory ../target already contains a .bzr directory, ' |
|
4634.105.2
by Andrew Bennetts
Clearer code and error message. |
344 |
'but it is not valid.'], |
|
4634.105.1
by Andrew Bennetts
Fix traceback when doing 'bzr push --use-existing-dir' into a dir with an invalid .bzr directory. |
345 |
'push ../target --use-existing-dir', working_dir='tree') |
346 |
||
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
347 |
def test_push_onto_repo(self): |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
348 |
"""We should be able to 'brz push' into an existing bzrdir.""" |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
349 |
tree = self.create_simple_tree() |
350 |
repo = self.make_repository('repo', shared=True) |
|
351 |
||
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
352 |
self.run_bzr('push ../repo', |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
353 |
working_dir='tree') |
354 |
||
355 |
# Pushing onto an existing bzrdir will create a repository and
|
|
356 |
# branch as needed, but will only create a working tree if there was
|
|
357 |
# no BzrDir before.
|
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
358 |
self.assertRaises(errors.NoWorkingTree, |
359 |
workingtree.WorkingTree.open, 'repo') |
|
360 |
new_branch = branch.Branch.open('repo') |
|
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
361 |
self.assertEqual(tree.last_revision(), new_branch.last_revision()) |
362 |
||
363 |
def test_push_onto_just_bzrdir(self): |
|
364 |
"""We don't handle when the target is just a bzrdir. |
|
365 |
||
366 |
Because you shouldn't be able to create *just* a bzrdir in the wild.
|
|
367 |
"""
|
|
368 |
# TODO: jam 20070109 Maybe it would be better to create the repository
|
|
369 |
# if at this point
|
|
370 |
tree = self.create_simple_tree() |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
371 |
a_controldir = self.make_controldir('dir') |
|
2227.3.1
by John Arbash Meinel
Allow push to create Branch when necessary, and add --use-existing |
372 |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
373 |
self.run_bzr_error(['At ../dir you have a valid .bzr control'], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
374 |
'push ../dir', |
375 |
working_dir='tree') |
|
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
376 |
|
|
3256.1.1
by Daniel Watkins
Added test for push with a revspec. |
377 |
def test_push_with_revisionspec(self): |
|
3256.1.3
by Daniel Watkins
Clarified test intent. |
378 |
"""We should be able to push a revision older than the tip.""" |
|
3256.1.1
by Daniel Watkins
Added test for push with a revspec. |
379 |
tree_from = self.make_branch_and_tree('from') |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
380 |
tree_from.commit("One.", rev_id=b"from-1") |
381 |
tree_from.commit("Two.", rev_id=b"from-2") |
|
|
3256.1.1
by Daniel Watkins
Added test for push with a revspec. |
382 |
|
383 |
self.run_bzr('push -r1 ../to', working_dir='from') |
|
384 |
||
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
385 |
tree_to = workingtree.WorkingTree.open('to') |
|
3256.1.1
by Daniel Watkins
Added test for push with a revspec. |
386 |
repo_to = tree_to.branch.repository |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
387 |
self.assertTrue(repo_to.has_revision(b'from-1')) |
388 |
self.assertFalse(repo_to.has_revision(b'from-2')) |
|
389 |
self.assertEqual(tree_to.branch.last_revision_info()[1], b'from-1') |
|
|
6519.3.2
by Neil Martinsen-Burrell
add direct test as well |
390 |
self.assertFalse( |
391 |
tree_to.changes_from(tree_to.basis_tree()).has_changed()) |
|
|
3256.1.1
by Daniel Watkins
Added test for push with a revspec. |
392 |
|
|
3256.1.4
by Daniel Watkins
Added test to ensure that passing a range of revisions errors. |
393 |
self.run_bzr_error( |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
394 |
['brz: ERROR: brz push --revision ' |
|
4325.4.6
by Vincent Ladeuil
Fixed as per John's and Markus reviews. |
395 |
'takes exactly one revision identifier\n'], |
|
3256.1.4
by Daniel Watkins
Added test to ensure that passing a range of revisions errors. |
396 |
'push -r0..2 ../to', working_dir='from') |
397 |
||
|
3221.11.13
by Robert Collins
Allow push --shallow to just work, and fix the testing HTTPServer to not be affected by chdir() calls. |
398 |
def create_trunk_and_feature_branch(self): |
|
3221.11.12
by Robert Collins
Basic push --reference support, requires url, slow. |
399 |
# We have a mainline
|
400 |
trunk_tree = self.make_branch_and_tree('target', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
401 |
format='1.9') |
|
3221.11.12
by Robert Collins
Basic push --reference support, requires url, slow. |
402 |
trunk_tree.commit('mainline') |
403 |
# and a branch from it
|
|
404 |
branch_tree = self.make_branch_and_tree('branch', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
405 |
format='1.9') |
|
3221.11.12
by Robert Collins
Basic push --reference support, requires url, slow. |
406 |
branch_tree.pull(trunk_tree.branch) |
|
3221.11.13
by Robert Collins
Allow push --shallow to just work, and fix the testing HTTPServer to not be affected by chdir() calls. |
407 |
branch_tree.branch.set_parent(trunk_tree.branch.base) |
|
3221.11.12
by Robert Collins
Basic push --reference support, requires url, slow. |
408 |
# with some work on it
|
|
3221.11.13
by Robert Collins
Allow push --shallow to just work, and fix the testing HTTPServer to not be affected by chdir() calls. |
409 |
branch_tree.commit('moar work plz') |
410 |
return trunk_tree, branch_tree |
|
411 |
||
|
3221.11.14
by Robert Collins
Refactor to reduce duplication. |
412 |
def assertPublished(self, branch_revid, stacked_on): |
413 |
"""Assert that the branch 'published' has been published correctly.""" |
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
414 |
published_branch = branch.Branch.open('published') |
|
3221.11.14
by Robert Collins
Refactor to reduce duplication. |
415 |
# The published branch refers to the mainline
|
|
3537.3.1
by Martin Pool
Rename branch.get_stacked_on to get_stacked_on_url |
416 |
self.assertEqual(stacked_on, published_branch.get_stacked_on_url()) |
|
3221.11.14
by Robert Collins
Refactor to reduce duplication. |
417 |
# and the branch's work was pushed
|
418 |
self.assertTrue(published_branch.repository.has_revision(branch_revid)) |
|
419 |
||
|
3549.1.1
by Martin Pool
rename push --reference to --stacked-on |
420 |
def test_push_new_branch_stacked_on(self): |
421 |
"""Pushing a new branch with --stacked-on creates a stacked branch.""" |
|
|
3221.11.13
by Robert Collins
Allow push --shallow to just work, and fix the testing HTTPServer to not be affected by chdir() calls. |
422 |
trunk_tree, branch_tree = self.create_trunk_and_feature_branch() |
423 |
# we publish branch_tree with a reference to the mainline.
|
|
|
3549.1.1
by Martin Pool
rename push --reference to --stacked-on |
424 |
out, err = self.run_bzr(['push', '--stacked-on', trunk_tree.branch.base, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
425 |
self.get_url('published')], working_dir='branch') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
426 |
self.assertEqual('', out) |
427 |
self.assertEqual('Created new stacked branch referring to %s.\n' % |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
428 |
trunk_tree.branch.base, err) |
|
3221.11.14
by Robert Collins
Refactor to reduce duplication. |
429 |
self.assertPublished(branch_tree.last_revision(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
430 |
trunk_tree.branch.base) |
|
3221.11.13
by Robert Collins
Allow push --shallow to just work, and fix the testing HTTPServer to not be affected by chdir() calls. |
431 |
|
|
7290.8.1
by Jelmer Vernooij
Add test for derefencing directories in --stacked-on. |
432 |
def test_push_new_branch_stacked_on(self): |
433 |
"""Pushing a new branch with --stacked-on can use directory URLs.""" |
|
434 |
trunk_tree, branch_tree = self.create_trunk_and_feature_branch() |
|
435 |
class FooDirectory(object): |
|
436 |
def look_up(self, name, url, purpose=None): |
|
437 |
if url == 'foo:': |
|
438 |
return trunk_tree.branch.base |
|
439 |
return url |
|
440 |
directory_service.directories.register('foo:', FooDirectory, 'Foo directory') |
|
441 |
self.addCleanup(directory_service.directories.remove, 'foo:') |
|
442 |
# we publish branch_tree with a reference to the mainline.
|
|
443 |
out, err = self.run_bzr(['push', '--stacked-on', 'foo:', |
|
444 |
self.get_url('published')], working_dir='branch') |
|
445 |
self.assertEqual('', out) |
|
446 |
self.assertEqual('Created new stacked branch referring to %s.\n' % |
|
447 |
trunk_tree.branch.base, err) |
|
448 |
self.assertPublished(branch_tree.last_revision(), |
|
449 |
trunk_tree.branch.base) |
|
450 |
||
|
3221.19.4
by Ian Clatworthy
shallow -> stacked |
451 |
def test_push_new_branch_stacked_uses_parent_when_no_public_url(self): |
|
3221.11.17
by Robert Collins
no public location causes the parent to be used directly with push --shallow. |
452 |
"""When the parent has no public url the parent is used as-is.""" |
453 |
trunk_tree, branch_tree = self.create_trunk_and_feature_branch() |
|
|
3221.19.4
by Ian Clatworthy
shallow -> stacked |
454 |
# now we do a stacked push, which should determine the public location
|
|
3221.11.17
by Robert Collins
no public location causes the parent to be used directly with push --shallow. |
455 |
# for us.
|
|
3221.19.4
by Ian Clatworthy
shallow -> stacked |
456 |
out, err = self.run_bzr(['push', '--stacked', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
457 |
self.get_url('published')], working_dir='branch') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
458 |
self.assertEqual('', out) |
459 |
self.assertEqual('Created new stacked branch referring to %s.\n' % |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
460 |
trunk_tree.branch.base, err) |
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
461 |
self.assertPublished(branch_tree.last_revision(), |
462 |
trunk_tree.branch.base) |
|
|
3221.11.17
by Robert Collins
no public location causes the parent to be used directly with push --shallow. |
463 |
|
|
3221.19.4
by Ian Clatworthy
shallow -> stacked |
464 |
def test_push_new_branch_stacked_uses_parent_public(self): |
465 |
"""Pushing a new branch with --stacked creates a stacked branch.""" |
|
|
3221.11.13
by Robert Collins
Allow push --shallow to just work, and fix the testing HTTPServer to not be affected by chdir() calls. |
466 |
trunk_tree, branch_tree = self.create_trunk_and_feature_branch() |
467 |
# the trunk is published on a web server
|
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
468 |
self.transport_readonly_server = http_server.HttpServer |
|
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
469 |
trunk_public = self.make_branch('public_trunk', format='1.9') |
|
3221.11.13
by Robert Collins
Allow push --shallow to just work, and fix the testing HTTPServer to not be affected by chdir() calls. |
470 |
trunk_public.pull(trunk_tree.branch) |
471 |
trunk_public_url = self.get_readonly_url('public_trunk') |
|
|
6404.6.1
by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. |
472 |
br = trunk_tree.branch |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
473 |
br.set_public_branch(trunk_public_url) |
|
3221.19.4
by Ian Clatworthy
shallow -> stacked |
474 |
# now we do a stacked push, which should determine the public location
|
|
3221.11.13
by Robert Collins
Allow push --shallow to just work, and fix the testing HTTPServer to not be affected by chdir() calls. |
475 |
# for us.
|
|
3221.19.4
by Ian Clatworthy
shallow -> stacked |
476 |
out, err = self.run_bzr(['push', '--stacked', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
477 |
self.get_url('published')], working_dir='branch') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
478 |
self.assertEqual('', out) |
479 |
self.assertEqual('Created new stacked branch referring to %s.\n' % |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
480 |
trunk_public_url, err) |
|
3221.11.14
by Robert Collins
Refactor to reduce duplication. |
481 |
self.assertPublished(branch_tree.last_revision(), trunk_public_url) |
|
3221.11.12
by Robert Collins
Basic push --reference support, requires url, slow. |
482 |
|
|
3221.19.4
by Ian Clatworthy
shallow -> stacked |
483 |
def test_push_new_branch_stacked_no_parent(self): |
484 |
"""Pushing with --stacked and no parent branch errors.""" |
|
|
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
485 |
branch = self.make_branch_and_tree('branch', format='1.9') |
|
3221.19.4
by Ian Clatworthy
shallow -> stacked |
486 |
# now we do a stacked push, which should fail as the place to refer too
|
|
3221.11.15
by Robert Collins
no parent branch causes an error on push --shallow. |
487 |
# cannot be determined.
|
488 |
out, err = self.run_bzr_error( |
|
|
3221.19.4
by Ian Clatworthy
shallow -> stacked |
489 |
['Could not determine branch to refer to\\.'], ['push', '--stacked', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
490 |
self.get_url('published')], working_dir='branch') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
491 |
self.assertEqual('', out) |
|
3221.11.15
by Robert Collins
no parent branch causes an error on push --shallow. |
492 |
self.assertFalse(self.get_transport('published').has('.')) |
493 |
||
|
3606.8.3
by John Arbash Meinel
push doesn't notify because it doesn't notice by default. |
494 |
def test_push_notifies_default_stacking(self): |
|
3735.1.2
by Robert Collins
Remove 1.5 series dev formats and document development2 a little better. |
495 |
self.make_branch('stack_on', format='1.6') |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
496 |
self.make_controldir('.').get_config().set_default_stack_on('stack_on') |
|
3735.1.2
by Robert Collins
Remove 1.5 series dev formats and document development2 a little better. |
497 |
self.make_branch('from', format='1.6') |
|
3242.3.34
by Aaron Bentley
Add notification of default stacking |
498 |
out, err = self.run_bzr('push -d from to') |
|
3641.1.1
by John Arbash Meinel
Merge in 1.6rc5 and revert disabling default stack on policy |
499 |
self.assertContainsRe(err, |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
500 |
'Using default stacking branch stack_on at .*') |
|
3242.3.34
by Aaron Bentley
Add notification of default stacking |
501 |
|
|
4165.2.1
by Robert Collins
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can. |
502 |
def test_push_stacks_with_default_stacking_if_target_is_stackable(self): |
503 |
self.make_branch('stack_on', format='1.6') |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
504 |
self.make_controldir('.').get_config().set_default_stack_on('stack_on') |
|
4165.2.1
by Robert Collins
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can. |
505 |
self.make_branch('from', format='pack-0.92') |
506 |
out, err = self.run_bzr('push -d from to') |
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
507 |
b = branch.Branch.open('to') |
508 |
self.assertEqual('../stack_on', b.get_stacked_on_url()) |
|
|
4165.2.1
by Robert Collins
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can. |
509 |
|
510 |
def test_push_does_not_change_format_with_default_if_target_cannot(self): |
|
511 |
self.make_branch('stack_on', format='pack-0.92') |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
512 |
self.make_controldir('.').get_config().set_default_stack_on('stack_on') |
|
4165.2.1
by Robert Collins
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can. |
513 |
self.make_branch('from', format='pack-0.92') |
514 |
out, err = self.run_bzr('push -d from to') |
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
515 |
b = branch.Branch.open('to') |
|
6734.1.11
by Jelmer Vernooij
Move UnstackableBranchFormat. |
516 |
self.assertRaises(branch.UnstackableBranchFormat, b.get_stacked_on_url) |
|
4165.2.1
by Robert Collins
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can. |
517 |
|
|
3904.3.2
by Andrew Bennetts
Blackbox test that triggers the bug. Should get replaced with a unit test. |
518 |
def test_push_doesnt_create_broken_branch(self): |
|
3904.3.7
by Andrew Bennetts
Comment the new tests. |
519 |
"""Pushing a new standalone branch works even when there's a default |
520 |
stacking policy at the destination.
|
|
521 |
||
522 |
The new branch will preserve the repo format (even if it isn't the
|
|
523 |
default for the branch), and will be stacked when the repo format
|
|
524 |
allows (which means that the branch format isn't necessarly preserved).
|
|
525 |
"""
|
|
|
3904.3.2
by Andrew Bennetts
Blackbox test that triggers the bug. Should get replaced with a unit test. |
526 |
self.make_repository('repo', shared=True, format='1.6') |
527 |
builder = self.make_branch_builder('repo/local', format='pack-0.92') |
|
528 |
builder.start_series() |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
529 |
builder.build_snapshot(None, [ |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
530 |
('add', ('', b'root-id', 'directory', '')), |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
531 |
('add', ('filename', b'f-id', 'file', b'content\n'))], |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
532 |
revision_id=b'rev-1') |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
533 |
builder.build_snapshot([b'rev-1'], [], revision_id=b'rev-2') |
534 |
builder.build_snapshot([b'rev-2'], |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
535 |
[('modify', ('filename', b'new-content\n'))], |
536 |
revision_id=b'rev-3') |
|
|
3904.3.2
by Andrew Bennetts
Blackbox test that triggers the bug. Should get replaced with a unit test. |
537 |
builder.finish_series() |
538 |
branch = builder.get_branch() |
|
|
3904.3.7
by Andrew Bennetts
Comment the new tests. |
539 |
# Push rev-1 to "trunk", so that we can stack on it.
|
|
3904.3.2
by Andrew Bennetts
Blackbox test that triggers the bug. Should get replaced with a unit test. |
540 |
self.run_bzr('push -d repo/local trunk -r 1') |
|
3904.3.7
by Andrew Bennetts
Comment the new tests. |
541 |
# Set a default stacking policy so that new branches will automatically
|
542 |
# stack on trunk.
|
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
543 |
self.make_controldir('.').get_config().set_default_stack_on('trunk') |
|
3904.3.7
by Andrew Bennetts
Comment the new tests. |
544 |
# Push rev-2 to a new branch "remote". It will be stacked on "trunk".
|
|
3904.3.2
by Andrew Bennetts
Blackbox test that triggers the bug. Should get replaced with a unit test. |
545 |
out, err = self.run_bzr('push -d repo/local remote -r 2') |
546 |
self.assertContainsRe( |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
547 |
err, 'Using default stacking branch trunk at .*') |
|
3904.3.7
by Andrew Bennetts
Comment the new tests. |
548 |
# Push rev-3 onto "remote". If "remote" not stacked and is missing the
|
549 |
# fulltext record for f-id @ rev-1, then this will fail.
|
|
|
3904.3.2
by Andrew Bennetts
Blackbox test that triggers the bug. Should get replaced with a unit test. |
550 |
out, err = self.run_bzr('push -d repo/local remote -r 3') |
551 |
||
|
3848.1.19
by Aaron Bentley
Show log for non-initial push -v |
552 |
def test_push_verbose_shows_log(self): |
553 |
tree = self.make_branch_and_tree('source') |
|
554 |
tree.commit('rev1') |
|
555 |
out, err = self.run_bzr('push -v -d source target') |
|
556 |
# initial push contains log
|
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
557 |
self.assertContainsRe(out, 'rev1') |
|
3848.1.19
by Aaron Bentley
Show log for non-initial push -v |
558 |
tree.commit('rev2') |
559 |
out, err = self.run_bzr('push -v -d source target') |
|
560 |
# subsequent push contains log
|
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
561 |
self.assertContainsRe(out, 'rev2') |
|
3848.1.19
by Aaron Bentley
Show log for non-initial push -v |
562 |
# subsequent log is accurate
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
563 |
self.assertNotContainsRe(out, 'rev1') |
|
3848.1.19
by Aaron Bentley
Show log for non-initial push -v |
564 |
|
|
4453.1.2
by Matthew Fuller
Add a test for pushing from subdir. |
565 |
def test_push_from_subdir(self): |
566 |
t = self.make_branch_and_tree('tree') |
|
567 |
self.build_tree(['tree/dir/', 'tree/dir/file']) |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
568 |
t.add(['dir', 'dir/file']) |
|
4453.1.2
by Matthew Fuller
Add a test for pushing from subdir. |
569 |
t.commit('r1') |
570 |
out, err = self.run_bzr('push ../../pushloc', working_dir='tree/dir') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
571 |
self.assertEqual('', out) |
572 |
self.assertEqual('Created new branch.\n', err) |
|
|
4453.1.2
by Matthew Fuller
Add a test for pushing from subdir. |
573 |
|
|
6159.2.1
by Jelmer Vernooij
Add some tests for 'bzr push --overwrite-tags'. |
574 |
def test_overwrite_tags(self): |
575 |
"""--overwrite-tags only overwrites tags, not revisions.""" |
|
576 |
from_tree = self.make_branch_and_tree('from') |
|
|
7027.10.1
by Jelmer Vernooij
Various blackbox test fixes. |
577 |
from_tree.branch.tags.set_tag("mytag", b"somerevid") |
|
6159.2.1
by Jelmer Vernooij
Add some tests for 'bzr push --overwrite-tags'. |
578 |
to_tree = self.make_branch_and_tree('to') |
|
7027.10.1
by Jelmer Vernooij
Various blackbox test fixes. |
579 |
to_tree.branch.tags.set_tag("mytag", b"anotherrevid") |
|
6159.2.1
by Jelmer Vernooij
Add some tests for 'bzr push --overwrite-tags'. |
580 |
revid1 = to_tree.commit('my commit') |
581 |
out = self.run_bzr(['push', '-d', 'from', 'to']) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
582 |
self.assertEqual(out, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
583 |
('Conflicting tags:\n mytag\n', 'No new revisions to push.\n')) |
|
6159.2.1
by Jelmer Vernooij
Add some tests for 'bzr push --overwrite-tags'. |
584 |
out = self.run_bzr(['push', '-d', 'from', '--overwrite-tags', 'to']) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
585 |
self.assertEqual(out, ('', '1 tag updated.\n')) |
586 |
self.assertEqual(to_tree.branch.tags.lookup_tag('mytag'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
587 |
b'somerevid') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
588 |
self.assertEqual(to_tree.branch.last_revision(), revid1) |
|
6159.2.1
by Jelmer Vernooij
Add some tests for 'bzr push --overwrite-tags'. |
589 |
|
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
590 |
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
591 |
class RedirectingMemoryTransport(memory.MemoryTransport): |
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
592 |
|
|
3878.4.4
by Vincent Ladeuil
Cleanup. |
593 |
def mkdir(self, relpath, mode=None): |
594 |
if self._cwd == '/source/': |
|
595 |
raise errors.RedirectRequested(self.abspath(relpath), |
|
596 |
self.abspath('../target'), |
|
597 |
is_permanent=True) |
|
598 |
elif self._cwd == '/infinite-loop/': |
|
599 |
raise errors.RedirectRequested(self.abspath(relpath), |
|
600 |
self.abspath('../infinite-loop'), |
|
601 |
is_permanent=True) |
|
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
602 |
else: |
603 |
return super(RedirectingMemoryTransport, self).mkdir( |
|
|
3878.4.4
by Vincent Ladeuil
Cleanup. |
604 |
relpath, mode) |
605 |
||
|
4547.2.2
by Andrew Bennetts
Add test for read_mergeable_from_transport raising NotABundle when TooManyRedirections happens. |
606 |
def get(self, relpath): |
607 |
if self.clone(relpath)._cwd == '/infinite-loop/': |
|
608 |
raise errors.RedirectRequested(self.abspath(relpath), |
|
609 |
self.abspath('../infinite-loop'), |
|
610 |
is_permanent=True) |
|
611 |
else: |
|
612 |
return super(RedirectingMemoryTransport, self).get(relpath) |
|
613 |
||
|
3878.4.5
by Vincent Ladeuil
Don't use the exception as a parameter for _redirected_to. |
614 |
def _redirected_to(self, source, target): |
|
3878.4.4
by Vincent Ladeuil
Cleanup. |
615 |
# We do accept redirections
|
|
3878.4.5
by Vincent Ladeuil
Don't use the exception as a parameter for _redirected_to. |
616 |
return transport.get_transport(target) |
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
617 |
|
618 |
||
|
5017.3.45
by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry. |
619 |
class RedirectingMemoryServer(memory.MemoryServer): |
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
620 |
|
|
4934.3.3
by Martin Pool
Rename Server.setUp to Server.start_server |
621 |
def start_server(self): |
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
622 |
self._dirs = {'/': None} |
623 |
self._files = {} |
|
624 |
self._locks = {} |
|
625 |
self._scheme = 'redirecting-memory+%s:///' % id(self) |
|
|
3878.4.4
by Vincent Ladeuil
Cleanup. |
626 |
transport.register_transport(self._scheme, self._memory_factory) |
|
3066.3.3
by jml at canonical
Unregister the test transport in order to be clean and to make test_selftest pass. |
627 |
|
628 |
def _memory_factory(self, url): |
|
629 |
result = RedirectingMemoryTransport(url) |
|
630 |
result._dirs = self._dirs |
|
631 |
result._files = self._files |
|
632 |
result._locks = self._locks |
|
633 |
return result |
|
634 |
||
|
4934.3.1
by Martin Pool
Rename Server.tearDown to .stop_server |
635 |
def stop_server(self): |
|
3878.4.4
by Vincent Ladeuil
Cleanup. |
636 |
transport.unregister_transport(self._scheme, self._memory_factory) |
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
637 |
|
638 |
||
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
639 |
class TestPushRedirect(tests.TestCaseWithTransport): |
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
640 |
|
641 |
def setUp(self): |
|
|
6552.1.4
by Vincent Ladeuil
Remaining tests matching setup(self) that can be rewritten with super(). |
642 |
super(TestPushRedirect, self).setUp() |
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
643 |
self.memory_server = RedirectingMemoryServer() |
|
4659.1.2
by Robert Collins
Refactor creation and shutdown of test servers to use a common helper, |
644 |
self.start_server(self.memory_server) |
|
3066.3.2
by jml at canonical
Add tests to check the handling of TooManyRedirections. |
645 |
# Make the branch and tree that we'll be pushing.
|
646 |
t = self.make_branch_and_tree('tree') |
|
647 |
self.build_tree(['tree/file']) |
|
648 |
t.add('file') |
|
649 |
t.commit('commit 1') |
|
650 |
||
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
651 |
def test_push_redirects_on_mkdir(self): |
652 |
"""If the push requires a mkdir, push respects redirect requests. |
|
653 |
||
654 |
This is added primarily to handle lp:/ URI support, so that users can
|
|
655 |
push to new branches by specifying lp:/ URIs.
|
|
656 |
"""
|
|
657 |
destination_url = self.memory_server.get_url() + 'source' |
|
|
3878.4.4
by Vincent Ladeuil
Cleanup. |
658 |
self.run_bzr(['push', '-d', 'tree', destination_url]) |
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
659 |
|
|
4420.1.1
by Vincent Ladeuil
Cleanup imports. |
660 |
local_revision = branch.Branch.open('tree').last_revision() |
661 |
remote_revision = branch.Branch.open( |
|
|
3066.3.1
by jml at canonical
Catch redirects raised by mkdir() in the push command. This is primarily |
662 |
self.memory_server.get_url() + 'target').last_revision() |
663 |
self.assertEqual(remote_revision, local_revision) |
|
|
3066.3.2
by jml at canonical
Add tests to check the handling of TooManyRedirections. |
664 |
|
665 |
def test_push_gracefully_handles_too_many_redirects(self): |
|
666 |
"""Push fails gracefully if the mkdir generates a large number of |
|
667 |
redirects.
|
|
668 |
"""
|
|
669 |
destination_url = self.memory_server.get_url() + 'infinite-loop' |
|
670 |
out, err = self.run_bzr_error( |
|
671 |
['Too many redirections trying to make %s\\.\n' |
|
672 |
% re.escape(destination_url)], |
|
|
3878.4.4
by Vincent Ladeuil
Cleanup. |
673 |
['push', '-d', 'tree', destination_url], retcode=3) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
674 |
self.assertEqual('', out) |
|
4420.1.2
by Vincent Ladeuil
Fix bug #284038 by adding a --strict option to push. |
675 |
|
676 |
||
|
4487.2.6
by Vincent Ladeuil
Fixed as per jam's review. |
677 |
class TestPushStrictMixin(object): |
|
4420.1.2
by Vincent Ladeuil
Fix bug #284038 by adding a --strict option to push. |
678 |
|
679 |
def make_local_branch_and_tree(self): |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
680 |
self.tree = self.make_branch_and_tree('local') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
681 |
self.build_tree_contents([('local/file', b'initial')]) |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
682 |
self.tree.add('file') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
683 |
self.tree.commit('adding file', rev_id=b'added') |
684 |
self.build_tree_contents([('local/file', b'modified')]) |
|
685 |
self.tree.commit('modify file', rev_id=b'modified') |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
686 |
|
687 |
def set_config_push_strict(self, value): |
|
|
6404.6.1
by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. |
688 |
br = branch.Branch.open('local') |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
689 |
br.get_config_stack().set('push_strict', value) |
|
4420.1.5
by Vincent Ladeuil
Start implementing jam's review feedback. |
690 |
|
|
4487.2.6
by Vincent Ladeuil
Fixed as per jam's review. |
691 |
_default_command = ['push', '../to'] |
692 |
_default_wd = 'local' |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
693 |
_default_errors = ['Working tree ".*/local/" has uncommitted ' |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
694 |
'changes \\(See brz status\\)\\.', ] |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
695 |
_default_additional_error = 'Use --no-strict to force the push.\n' |
696 |
_default_additional_warning = 'Uncommitted changes will not be pushed.' |
|
|
5171.2.3
by Vincent Ladeuil
Fixed as per Andrew's review. |
697 |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
698 |
def assertPushFails(self, args): |
|
5171.2.3
by Vincent Ladeuil
Fixed as per Andrew's review. |
699 |
out, err = self.run_bzr_error(self._default_errors, |
700 |
self._default_command + args, |
|
701 |
working_dir=self._default_wd, retcode=3) |
|
702 |
self.assertContainsRe(err, self._default_additional_error) |
|
|
4420.1.5
by Vincent Ladeuil
Start implementing jam's review feedback. |
703 |
|
|
5171.2.3
by Vincent Ladeuil
Fixed as per Andrew's review. |
704 |
def assertPushSucceeds(self, args, with_warning=False, revid_to_push=None): |
|
5147.2.1
by Vincent Ladeuil
Failing tests for bug #519319. |
705 |
if with_warning: |
706 |
error_regexes = self._default_errors |
|
707 |
else: |
|
708 |
error_regexes = [] |
|
|
5171.2.3
by Vincent Ladeuil
Fixed as per Andrew's review. |
709 |
out, err = self.run_bzr(self._default_command + args, |
710 |
working_dir=self._default_wd, |
|
711 |
error_regexes=error_regexes) |
|
712 |
if with_warning: |
|
713 |
self.assertContainsRe(err, self._default_additional_warning) |
|
714 |
else: |
|
715 |
self.assertNotContainsRe(err, self._default_additional_warning) |
|
716 |
branch_from = branch.Branch.open(self._default_wd) |
|
717 |
if revid_to_push is None: |
|
718 |
revid_to_push = branch_from.last_revision() |
|
719 |
branch_to = branch.Branch.open('to') |
|
720 |
repo_to = branch_to.repository |
|
721 |
self.assertTrue(repo_to.has_revision(revid_to_push)) |
|
722 |
self.assertEqual(revid_to_push, branch_to.last_revision()) |
|
|
4420.1.2
by Vincent Ladeuil
Fix bug #284038 by adding a --strict option to push. |
723 |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
724 |
|
|
4487.2.6
by Vincent Ladeuil
Fixed as per jam's review. |
725 |
class TestPushStrictWithoutChanges(tests.TestCaseWithTransport, |
726 |
TestPushStrictMixin): |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
727 |
|
728 |
def setUp(self): |
|
729 |
super(TestPushStrictWithoutChanges, self).setUp() |
|
730 |
self.make_local_branch_and_tree() |
|
731 |
||
732 |
def test_push_default(self): |
|
733 |
self.assertPushSucceeds([]) |
|
734 |
||
735 |
def test_push_strict(self): |
|
736 |
self.assertPushSucceeds(['--strict']) |
|
737 |
||
738 |
def test_push_no_strict(self): |
|
739 |
self.assertPushSucceeds(['--no-strict']) |
|
740 |
||
741 |
def test_push_config_var_strict(self): |
|
742 |
self.set_config_push_strict('true') |
|
743 |
self.assertPushSucceeds([]) |
|
744 |
||
745 |
def test_push_config_var_no_strict(self): |
|
746 |
self.set_config_push_strict('false') |
|
747 |
self.assertPushSucceeds([]) |
|
748 |
||
749 |
||
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
750 |
strict_push_change_scenarios = [ |
751 |
('uncommitted', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
752 |
dict(_changes_type='_uncommitted_changes')), |
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
753 |
('pending-merges', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
754 |
dict(_changes_type='_pending_merges')), |
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
755 |
('out-of-sync-trees', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
756 |
dict(_changes_type='_out_of_sync_trees')), |
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
757 |
]
|
758 |
||
759 |
||
|
4487.2.6
by Vincent Ladeuil
Fixed as per jam's review. |
760 |
class TestPushStrictWithChanges(tests.TestCaseWithTransport, |
761 |
TestPushStrictMixin): |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
762 |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
763 |
scenarios = strict_push_change_scenarios |
764 |
_changes_type = None # Set by load_tests |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
765 |
|
766 |
def setUp(self): |
|
767 |
super(TestPushStrictWithChanges, self).setUp() |
|
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
768 |
# Apply the changes defined in load_tests: one of _uncommitted_changes,
|
769 |
# _pending_merges or _out_of_sync_trees
|
|
|
4487.2.3
by Vincent Ladeuil
--strict is meaningless when --revision is specified. |
770 |
getattr(self, self._changes_type)() |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
771 |
|
|
4487.2.3
by Vincent Ladeuil
--strict is meaningless when --revision is specified. |
772 |
def _uncommitted_changes(self): |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
773 |
self.make_local_branch_and_tree() |
774 |
# Make a change without committing it
|
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
775 |
self.build_tree_contents([('local/file', b'in progress')]) |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
776 |
|
|
4487.2.3
by Vincent Ladeuil
--strict is meaningless when --revision is specified. |
777 |
def _pending_merges(self): |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
778 |
self.make_local_branch_and_tree() |
779 |
# Create 'other' branch containing a new file
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
780 |
other_bzrdir = self.tree.controldir.sprout('other') |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
781 |
other_tree = other_bzrdir.open_workingtree() |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
782 |
self.build_tree_contents([('other/other-file', b'other')]) |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
783 |
other_tree.add('other-file') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
784 |
other_tree.commit('other commit', rev_id=b'other') |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
785 |
# Merge and revert, leaving a pending merge
|
786 |
self.tree.merge_from_branch(other_tree.branch) |
|
787 |
self.tree.revert(filenames=['other-file'], backups=False) |
|
788 |
||
|
4487.2.6
by Vincent Ladeuil
Fixed as per jam's review. |
789 |
def _out_of_sync_trees(self): |
790 |
self.make_local_branch_and_tree() |
|
791 |
self.run_bzr(['checkout', '--lightweight', 'local', 'checkout']) |
|
792 |
# Make a change and commit it
|
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
793 |
self.build_tree_contents([('local/file', b'modified in local')]) |
794 |
self.tree.commit('modify file', rev_id=b'modified-in-local') |
|
|
4487.2.6
by Vincent Ladeuil
Fixed as per jam's review. |
795 |
# Exercise commands from the checkout directory
|
796 |
self._default_wd = 'checkout' |
|
797 |
self._default_errors = ["Working tree is out of date, please run" |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
798 |
" 'brz update'\\.", ] |
|
4487.2.6
by Vincent Ladeuil
Fixed as per jam's review. |
799 |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
800 |
def test_push_default(self): |
|
5147.2.1
by Vincent Ladeuil
Failing tests for bug #519319. |
801 |
self.assertPushSucceeds([], with_warning=True) |
|
4420.1.5
by Vincent Ladeuil
Start implementing jam's review feedback. |
802 |
|
|
4487.2.3
by Vincent Ladeuil
--strict is meaningless when --revision is specified. |
803 |
def test_push_with_revision(self): |
|
7045.3.1
by Jelmer Vernooij
Fix another ~500 tests. |
804 |
self.assertPushSucceeds(['-r', 'revid:added'], revid_to_push=b'added') |
|
4487.2.3
by Vincent Ladeuil
--strict is meaningless when --revision is specified. |
805 |
|
806 |
def test_push_no_strict(self): |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
807 |
self.assertPushSucceeds(['--no-strict']) |
|
4420.1.2
by Vincent Ladeuil
Fix bug #284038 by adding a --strict option to push. |
808 |
|
809 |
def test_push_strict_with_changes(self): |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
810 |
self.assertPushFails(['--strict']) |
|
4420.1.5
by Vincent Ladeuil
Start implementing jam's review feedback. |
811 |
|
812 |
def test_push_respect_config_var_strict(self): |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
813 |
self.set_config_push_strict('true') |
814 |
self.assertPushFails([]) |
|
|
4420.1.5
by Vincent Ladeuil
Start implementing jam's review feedback. |
815 |
|
|
4420.1.6
by Vincent Ladeuil
Fixed as per John's review feedback. |
816 |
def test_push_bogus_config_var_ignored(self): |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
817 |
self.set_config_push_strict("I don't want you to be strict") |
|
5147.2.1
by Vincent Ladeuil
Failing tests for bug #519319. |
818 |
self.assertPushSucceeds([], with_warning=True) |
|
4420.1.6
by Vincent Ladeuil
Fixed as per John's review feedback. |
819 |
|
|
4420.1.5
by Vincent Ladeuil
Start implementing jam's review feedback. |
820 |
def test_push_no_strict_command_line_override_config(self): |
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
821 |
self.set_config_push_strict('yES') |
822 |
self.assertPushFails([]) |
|
823 |
self.assertPushSucceeds(['--no-strict']) |
|
|
4420.1.5
by Vincent Ladeuil
Start implementing jam's review feedback. |
824 |
|
825 |
def test_push_strict_command_line_override_config(self): |
|
|
4487.2.2
by Vincent Ladeuil
Add tests for push --strict against pending merges. |
826 |
self.set_config_push_strict('oFF') |
827 |
self.assertPushFails(['--strict']) |
|
828 |
self.assertPushSucceeds([]) |
|
|
4925.1.1
by Jelmer Vernooij
Print a proper error when attempting to push to a foreign VCS for which |
829 |
|
830 |
||
|
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
831 |
class TestPushForeign(tests.TestCaseWithTransport): |
|
4925.1.1
by Jelmer Vernooij
Print a proper error when attempting to push to a foreign VCS for which |
832 |
|
833 |
def setUp(self): |
|
834 |
super(TestPushForeign, self).setUp() |
|
835 |
test_foreign.register_dummy_foreign_for_test(self) |
|
836 |
||
837 |
def make_dummy_builder(self, relpath): |
|
838 |
builder = self.make_branch_builder( |
|
839 |
relpath, format=test_foreign.DummyForeignVcsDirFormat()) |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
840 |
builder.build_snapshot(None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
841 |
[('add', ('', b'TREE_ROOT', 'directory', None)), |
842 |
('add', ('foo', b'fooid', 'file', b'bar'))], |
|
843 |
revision_id=b'revid') |
|
|
4925.1.1
by Jelmer Vernooij
Print a proper error when attempting to push to a foreign VCS for which |
844 |
return builder |
845 |
||
846 |
def test_no_roundtripping(self): |
|
847 |
target_branch = self.make_dummy_builder('dp').get_branch() |
|
848 |
source_tree = self.make_branch_and_tree("dc") |
|
849 |
output, error = self.run_bzr("push -d dc dp", retcode=3) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
850 |
self.assertEqual("", output) |
|
7143.15.10
by Jelmer Vernooij
Merge trunk. |
851 |
self.assertEqual( |
852 |
error, |
|
853 |
"brz: ERROR: It is not possible to losslessly"
|
|
|
7143.13.2
by Jelmer Vernooij
Fix test. |
854 |
" push to dummy. You may want to use --lossy.\n") |
|
6175.2.4
by Vincent Ladeuil
Add script tests and documentation. |
855 |
|
856 |
||
857 |
class TestPushOutput(script.TestCaseWithTransportAndScript): |
|
858 |
||
859 |
def test_push_log_format(self): |
|
860 |
self.run_script(""" |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
861 |
$ brz init trunk
|
|
6175.2.4
by Vincent Ladeuil
Add script tests and documentation. |
862 |
Created a standalone tree (format: 2a)
|
863 |
$ cd trunk
|
|
864 |
$ echo foo > file
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
865 |
$ brz add
|
|
6175.2.4
by Vincent Ladeuil
Add script tests and documentation. |
866 |
adding file
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
867 |
$ brz commit -m 'we need some foo'
|
|
6175.2.4
by Vincent Ladeuil
Add script tests and documentation. |
868 |
2>Committing to:...trunk/
|
869 |
2>added file
|
|
870 |
2>Committed revision 1.
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
871 |
$ brz init ../feature
|
|
6175.2.4
by Vincent Ladeuil
Add script tests and documentation. |
872 |
Created a standalone tree (format: 2a)
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
873 |
$ brz push -v ../feature -Olog_format=line
|
|
6175.2.4
by Vincent Ladeuil
Add script tests and documentation. |
874 |
Added Revisions:
|
875 |
1: jrandom@example.com ...we need some foo
|
|
876 |
2>All changes applied successfully.
|
|
877 |
2>Pushed up to revision 1.
|
|
878 |
""") |
|
|
6519.3.1
by Neil Martinsen-Burrell
when pushing specific revision, create working tree at that revision |
879 |
|
880 |
def test_push_with_revspec(self): |
|
881 |
self.run_script(""" |
|
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
882 |
$ brz init-shared-repo .
|
|
6519.3.1
by Neil Martinsen-Burrell
when pushing specific revision, create working tree at that revision |
883 |
Shared repository with trees (format: 2a)
|
884 |
Location:
|
|
885 |
shared repository: .
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
886 |
$ brz init trunk
|
|
6519.3.1
by Neil Martinsen-Burrell
when pushing specific revision, create working tree at that revision |
887 |
Created a repository tree (format: 2a)
|
888 |
Using shared repository...
|
|
889 |
$ cd trunk
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
890 |
$ brz commit -m 'first rev' --unchanged
|
|
6519.3.1
by Neil Martinsen-Burrell
when pushing specific revision, create working tree at that revision |
891 |
2>Committing to:...trunk/
|
892 |
2>Committed revision 1.
|
|
893 |
$ echo foo > file
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
894 |
$ brz add
|
|
6519.3.1
by Neil Martinsen-Burrell
when pushing specific revision, create working tree at that revision |
895 |
adding file
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
896 |
$ brz commit -m 'we need some foo'
|
|
6519.3.1
by Neil Martinsen-Burrell
when pushing specific revision, create working tree at that revision |
897 |
2>Committing to:...trunk/
|
898 |
2>added file
|
|
899 |
2>Committed revision 2.
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
900 |
$ brz push -r 1 ../other
|
|
6519.3.1
by Neil Martinsen-Burrell
when pushing specific revision, create working tree at that revision |
901 |
2>Created new branch.
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
902 |
$ brz st ../other # checking that file is not created (#484516)
|
|
6519.3.1
by Neil Martinsen-Burrell
when pushing specific revision, create working tree at that revision |
903 |
""") |