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
|
|
1711.2.5
by John Arbash Meinel
Factoring blackbox tests into their own file. |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1711.2.5
by John Arbash Meinel
Factoring blackbox tests into their own file. |
16 |
|
17 |
||
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
18 |
"""Black-box tests for brz branch."""
|
|
1711.2.5
by John Arbash Meinel
Factoring blackbox tests into their own file. |
19 |
|
20 |
import os |
|
21 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
22 |
from breezy import ( |
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
23 |
branch, |
|
6207.3.3
by jelmer at samba
Fix tests and the like. |
24 |
controldir, |
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
25 |
errors, |
26 |
revision as _mod_revision, |
|
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
27 |
tests, |
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
28 |
)
|
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
29 |
from breezy.bzr import ( |
30 |
bzrdir, |
|
31 |
)
|
|
|
6670.4.5
by Jelmer Vernooij
Move breezy.repofmt contents to breezy.bzr. |
32 |
from breezy.bzr.knitrepo import RepositoryFormatKnit1 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
33 |
from breezy.tests import ( |
|
5651.5.3
by Andrew Bennetts
Use new fixture in more tests. |
34 |
fixtures, |
|
5017.3.40
by Vincent Ladeuil
-s bb.test_branch passing |
35 |
test_server, |
|
4580.4.2
by Martin Pool
Add KnownFailure for branch --hardlink |
36 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
37 |
from breezy.tests.features import ( |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
38 |
HardlinkFeature, |
39 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
40 |
from breezy.tests.blackbox import test_switch |
41 |
from breezy.tests.test_sftp_transport import TestCaseWithSFTPServer |
|
42 |
from breezy.tests.script import run_script |
|
43 |
from breezy.urlutils import local_path_to_url, strip_trailing_slash |
|
44 |
from breezy.workingtree import WorkingTree |
|
|
1711.2.5
by John Arbash Meinel
Factoring blackbox tests into their own file. |
45 |
|
46 |
||
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
47 |
class TestBranch(tests.TestCaseWithTransport): |
|
1711.2.5
by John Arbash Meinel
Factoring blackbox tests into their own file. |
48 |
|
|
6240.3.1
by Jelmer Vernooij
Name new branches after colocated branches. |
49 |
def example_branch(self, path='.', format=None): |
50 |
tree = self.make_branch_and_tree(path, format=format) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
51 |
self.build_tree_contents([(path + '/hello', b'foo')]) |
|
2664.8.2
by Daniel Watkins
tests.blackbox.test_branch now uses internals where appropriate. |
52 |
tree.add('hello') |
53 |
tree.commit(message='setup') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
54 |
self.build_tree_contents([(path + '/goodbye', b'baz')]) |
|
2664.8.2
by Daniel Watkins
tests.blackbox.test_branch now uses internals where appropriate. |
55 |
tree.add('goodbye') |
56 |
tree.commit(message='setup') |
|
|
6240.3.1
by Jelmer Vernooij
Name new branches after colocated branches. |
57 |
return tree |
|
1711.2.5
by John Arbash Meinel
Factoring blackbox tests into their own file. |
58 |
|
59 |
def test_branch(self): |
|
60 |
"""Branch from one branch to another.""" |
|
|
2664.8.2
by Daniel Watkins
tests.blackbox.test_branch now uses internals where appropriate. |
61 |
self.example_branch('a') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
62 |
self.run_bzr('branch a b') |
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
63 |
b = branch.Branch.open('b') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
64 |
self.run_bzr('branch a c -r 1') |
|
3400.1.3
by Martin Pool
Merge trunk |
65 |
# previously was erroneously created by branching
|
|
3407.2.14
by Martin Pool
Remove more cases of getting transport via control_files |
66 |
self.assertFalse(b._transport.has('branch-name')) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
67 |
b.controldir.open_workingtree().commit(message='foo', allow_pointless=True) |
|
1711.2.5
by John Arbash Meinel
Factoring blackbox tests into their own file. |
68 |
|
|
6437.15.1
by Jelmer Vernooij
Fix target branch locations. |
69 |
def test_branch_no_to_location(self): |
70 |
"""The to_location is derived from the source branch name.""" |
|
71 |
os.mkdir("something") |
|
72 |
a = self.example_branch('something/a').branch |
|
73 |
self.run_bzr('branch something/a') |
|
74 |
b = branch.Branch.open('a') |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
75 |
self.assertEqual(b.last_revision_info(), a.last_revision_info()) |
|
6437.15.1
by Jelmer Vernooij
Fix target branch locations. |
76 |
|
|
6207.2.1
by jelmer at samba
Fix cloning to colocated branch. |
77 |
def test_into_colocated(self): |
78 |
"""Branch from a branch into a colocated branch.""" |
|
79 |
self.example_branch('a') |
|
80 |
out, err = self.run_bzr( |
|
81 |
'init --format=development-colo file:b,branch=orig') |
|
82 |
self.assertEqual( |
|
|
6874.1.3
by Jelmer Vernooij
Fix format names. |
83 |
"""Created a standalone tree (format: development-colo)\n""", |
|
6207.2.1
by jelmer at samba
Fix cloning to colocated branch. |
84 |
out) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
85 |
self.assertEqual('', err) |
|
6207.2.1
by jelmer at samba
Fix cloning to colocated branch. |
86 |
out, err = self.run_bzr( |
|
6266.1.1
by Jelmer Vernooij
Support branching into colocated branch. |
87 |
'branch a file:b,branch=thiswasa') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
88 |
self.assertEqual('', out) |
89 |
self.assertEqual('Branched 2 revisions.\n', err) |
|
|
6207.2.1
by jelmer at samba
Fix cloning to colocated branch. |
90 |
out, err = self.run_bzr('branches b') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
91 |
self.assertEqual(" orig\n thiswasa\n", out) |
92 |
self.assertEqual('', err) |
|
|
6809.1.1
by Martin
Apply 2to3 ws_comma fixer |
93 |
out, err = self.run_bzr('branch a file:b,branch=orig', retcode=3) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
94 |
self.assertEqual('', out) |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
95 |
self.assertEqual( |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
96 |
'brz: ERROR: Already a branch: "file:b,branch=orig".\n', err) |
|
6207.2.1
by jelmer at samba
Fix cloning to colocated branch. |
97 |
|
|
6240.3.1
by Jelmer Vernooij
Name new branches after colocated branches. |
98 |
def test_from_colocated(self): |
99 |
"""Branch from a colocated branch into a regular branch.""" |
|
|
7111.1.1
by Jelmer Vernooij
Don't let the default directory name derive from a branch name. |
100 |
os.mkdir('b') |
101 |
tree = self.example_branch('b/a', format='development-colo') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
102 |
tree.controldir.create_branch(name='somecolo') |
|
6240.3.1
by Jelmer Vernooij
Name new branches after colocated branches. |
103 |
out, err = self.run_bzr('branch %s,branch=somecolo' % |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
104 |
local_path_to_url('b/a')) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
105 |
self.assertEqual('', out) |
106 |
self.assertEqual('Branched 0 revisions.\n', err) |
|
|
7111.1.1
by Jelmer Vernooij
Don't let the default directory name derive from a branch name. |
107 |
self.assertPathExists('a') |
|
6240.3.1
by Jelmer Vernooij
Name new branches after colocated branches. |
108 |
|
|
7490.18.1
by Jelmer Vernooij
Add a -b option to ''brz branch''. |
109 |
def test_from_name(self): |
110 |
"""Branch from a colocated branch into a regular branch.""" |
|
111 |
os.mkdir('b') |
|
112 |
tree = self.example_branch('b/a', format='development-colo') |
|
113 |
tree.controldir.create_branch(name='somecolo') |
|
114 |
out, err = self.run_bzr('branch -b somecolo %s' % |
|
115 |
local_path_to_url('b/a')) |
|
116 |
self.assertEqual('', out) |
|
117 |
self.assertEqual('Branched 0 revisions.\n', err) |
|
118 |
self.assertPathExists('a') |
|
119 |
||
|
5927.2.1
by Jonathan Riddell
start a test case for corrupt pack files |
120 |
def test_branch_broken_pack(self): |
121 |
"""branching with a corrupted pack file.""" |
|
122 |
self.example_branch('a') |
|
|
6158.1.1
by Vincent Ladeuil
Fix random test failure by making the test not random |
123 |
# add some corruption
|
124 |
packs_dir = 'a/.bzr/repository/packs/' |
|
125 |
fname = packs_dir + os.listdir(packs_dir)[0] |
|
|
5927.2.8
by Jonathan Riddell
tidy up file opening in test |
126 |
with open(fname, 'rb+') as f: |
|
6158.1.1
by Vincent Ladeuil
Fix random test failure by making the test not random |
127 |
# Start from the end of the file to avoid choosing a place bigger
|
128 |
# than the file itself.
|
|
129 |
f.seek(-5, os.SEEK_END) |
|
130 |
c = f.read(1) |
|
131 |
f.seek(-5, os.SEEK_END) |
|
132 |
# Make sure we inject a value different than the one we just read
|
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
133 |
if c == b'\xFF': |
|
7122.2.1
by Jelmer Vernooij
Fix byteness when we happen to write a xFF in the wrong place.. |
134 |
corrupt = b'\x00' |
|
6158.1.1
by Vincent Ladeuil
Fix random test failure by making the test not random |
135 |
else: |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
136 |
corrupt = b'\xFF' |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
137 |
f.write(corrupt) # make sure we corrupt something |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
138 |
self.run_bzr_error(['Corruption while decompressing repository file'], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
139 |
'branch a b', retcode=3) |
|
5927.2.1
by Jonathan Riddell
start a test case for corrupt pack files |
140 |
|
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
141 |
def test_branch_switch_no_branch(self): |
142 |
# No branch in the current directory:
|
|
143 |
# => new branch will be created, but switch fails
|
|
144 |
self.example_branch('a') |
|
145 |
self.make_repository('current') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
146 |
self.run_bzr_error(['No WorkingTree exists for'], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
147 |
'branch --switch ../a ../b', working_dir='current') |
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
148 |
a = branch.Branch.open('a') |
149 |
b = branch.Branch.open('b') |
|
150 |
self.assertEqual(a.last_revision(), b.last_revision()) |
|
151 |
||
152 |
def test_branch_switch_no_wt(self): |
|
153 |
# No working tree in the current directory:
|
|
154 |
# => new branch will be created, but switch fails and the current
|
|
155 |
# branch is unmodified
|
|
156 |
self.example_branch('a') |
|
157 |
self.make_branch('current') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
158 |
self.run_bzr_error(['No WorkingTree exists for'], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
159 |
'branch --switch ../a ../b', working_dir='current') |
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
160 |
a = branch.Branch.open('a') |
161 |
b = branch.Branch.open('b') |
|
162 |
self.assertEqual(a.last_revision(), b.last_revision()) |
|
163 |
work = branch.Branch.open('current') |
|
164 |
self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION) |
|
165 |
||
|
4596.2.1
by Lukáš Lalinský
Add support for `bzr branch --switch` |
166 |
def test_branch_switch_no_checkout(self): |
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
167 |
# Standalone branch in the current directory:
|
168 |
# => new branch will be created, but switch fails and the current
|
|
169 |
# branch is unmodified
|
|
|
4596.2.1
by Lukáš Lalinský
Add support for `bzr branch --switch` |
170 |
self.example_branch('a') |
|
6437.21.7
by Jelmer Vernooij
Fix remaining tests. |
171 |
tree = self.make_branch_and_tree('current') |
172 |
c1 = tree.commit('some diverged change') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
173 |
self.run_bzr_error(['Cannot switch a branch, only a checkout'], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
174 |
'branch --switch ../a ../b', working_dir='current') |
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
175 |
a = branch.Branch.open('a') |
176 |
b = branch.Branch.open('b') |
|
177 |
self.assertEqual(a.last_revision(), b.last_revision()) |
|
178 |
work = branch.Branch.open('current') |
|
|
6437.21.7
by Jelmer Vernooij
Fix remaining tests. |
179 |
self.assertEqual(work.last_revision(), c1) |
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
180 |
|
|
6379.13.1
by Jelmer Vernooij
Fix branching into empty control directories. |
181 |
def test_branch_into_empty_dir(self): |
182 |
t = self.example_branch('source') |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
183 |
self.make_controldir('target') |
|
6379.13.1
by Jelmer Vernooij
Fix branching into empty control directories. |
184 |
self.run_bzr("branch source target") |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
185 |
self.assertEqual(2, len(t.branch.repository.all_revision_ids())) |
|
6379.13.1
by Jelmer Vernooij
Fix branching into empty control directories. |
186 |
|
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
187 |
def test_branch_switch_checkout(self): |
188 |
# Checkout in the current directory:
|
|
189 |
# => new branch will be created and checkout bound to the new branch
|
|
190 |
self.example_branch('a') |
|
191 |
self.run_bzr('checkout a current') |
|
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
192 |
out, err = self.run_bzr('branch --switch ../a ../b', |
193 |
working_dir='current') |
|
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
194 |
a = branch.Branch.open('a') |
195 |
b = branch.Branch.open('b') |
|
196 |
self.assertEqual(a.last_revision(), b.last_revision()) |
|
197 |
work = WorkingTree.open('current') |
|
198 |
self.assertEndsWith(work.branch.get_bound_location(), '/b/') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
199 |
self.assertContainsRe(err, "Switched to branch: .*/b/") |
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
200 |
|
201 |
def test_branch_switch_lightweight_checkout(self): |
|
202 |
# Lightweight checkout in the current directory:
|
|
203 |
# => new branch will be created and lightweight checkout pointed to
|
|
204 |
# the new branch
|
|
205 |
self.example_branch('a') |
|
206 |
self.run_bzr('checkout --lightweight a current') |
|
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
207 |
out, err = self.run_bzr('branch --switch ../a ../b', |
208 |
working_dir='current') |
|
|
4596.2.3
by Lukáš Lalinský
Add tests for various situations |
209 |
a = branch.Branch.open('a') |
210 |
b = branch.Branch.open('b') |
|
211 |
self.assertEqual(a.last_revision(), b.last_revision()) |
|
212 |
work = WorkingTree.open('current') |
|
213 |
self.assertEndsWith(work.branch.base, '/b/') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
214 |
self.assertContainsRe(err, "Switched to branch: .*/b/") |
|
4596.2.1
by Lukáš Lalinský
Add support for `bzr branch --switch` |
215 |
|
|
1711.2.6
by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing |
216 |
def test_branch_only_copies_history(self): |
217 |
# Knit branches should only push the history for the current revision.
|
|
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
218 |
format = bzrdir.BzrDirMetaFormat1() |
|
1711.2.6
by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing |
219 |
format.repository_format = RepositoryFormatKnit1() |
220 |
shared_repo = self.make_repository('repo', format=format, shared=True) |
|
221 |
shared_repo.set_make_working_trees(True) |
|
222 |
||
223 |
def make_shared_tree(path): |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
224 |
shared_repo.controldir.root_transport.mkdir(path) |
|
6207.3.3
by jelmer at samba
Fix tests and the like. |
225 |
controldir.ControlDir.create_branch_convenience('repo/' + path) |
|
1711.2.6
by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing |
226 |
return WorkingTree.open('repo/' + path) |
227 |
tree_a = make_shared_tree('a') |
|
228 |
self.build_tree(['repo/a/file']) |
|
229 |
tree_a.add('file') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
230 |
tree_a.commit('commit a-1', rev_id=b'a-1') |
|
6973.7.5
by Jelmer Vernooij
s/file/open. |
231 |
with open('repo/a/file', 'ab') as f: |
232 |
f.write(b'more stuff\n') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
233 |
tree_a.commit('commit a-2', rev_id=b'a-2') |
|
1711.2.6
by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing |
234 |
|
235 |
tree_b = make_shared_tree('b') |
|
236 |
self.build_tree(['repo/b/file']) |
|
237 |
tree_b.add('file') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
238 |
tree_b.commit('commit b-1', rev_id=b'b-1') |
|
1711.2.6
by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing |
239 |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
240 |
self.assertTrue(shared_repo.has_revision(b'a-1')) |
241 |
self.assertTrue(shared_repo.has_revision(b'a-2')) |
|
242 |
self.assertTrue(shared_repo.has_revision(b'b-1')) |
|
|
1711.2.6
by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing |
243 |
|
244 |
# Now that we have a repository with shared files, make sure
|
|
245 |
# that things aren't copied out by a 'branch'
|
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
246 |
self.run_bzr('branch repo/b branch-b') |
|
1711.2.6
by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing |
247 |
pushed_tree = WorkingTree.open('branch-b') |
248 |
pushed_repo = pushed_tree.branch.repository |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
249 |
self.assertFalse(pushed_repo.has_revision(b'a-1')) |
250 |
self.assertFalse(pushed_repo.has_revision(b'a-2')) |
|
251 |
self.assertTrue(pushed_repo.has_revision(b'b-1')) |
|
|
1711.2.6
by John Arbash Meinel
Creating a test case for bug 43713, bzr branch does the right thing |
252 |
|
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
253 |
def test_branch_hardlink(self): |
254 |
self.requireFeature(HardlinkFeature) |
|
255 |
source = self.make_branch_and_tree('source') |
|
256 |
self.build_tree(['source/file1']) |
|
257 |
source.add('file1') |
|
258 |
source.commit('added file') |
|
|
4580.4.2
by Martin Pool
Add KnownFailure for branch --hardlink |
259 |
out, err = self.run_bzr(['branch', 'source', 'target', '--hardlink']) |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
260 |
source_stat = os.stat('source/file1') |
261 |
target_stat = os.stat('target/file1') |
|
|
4826.1.3
by Andrew Bennetts
Remove KnownFailure from test_branch_hardlink. |
262 |
self.assertEqual(source_stat, target_stat) |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
263 |
|
|
5353.2.2
by John Arbash Meinel
update the test suite. |
264 |
def test_branch_files_from(self): |
265 |
source = self.make_branch_and_tree('source') |
|
266 |
self.build_tree(['source/file1']) |
|
267 |
source.add('file1') |
|
268 |
source.commit('added file') |
|
269 |
out, err = self.run_bzr('branch source target --files-from source') |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
270 |
self.assertPathExists('target/file1') |
|
5353.2.2
by John Arbash Meinel
update the test suite. |
271 |
|
272 |
def test_branch_files_from_hardlink(self): |
|
273 |
self.requireFeature(HardlinkFeature) |
|
274 |
source = self.make_branch_and_tree('source') |
|
275 |
self.build_tree(['source/file1']) |
|
276 |
source.add('file1') |
|
277 |
source.commit('added file') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
278 |
source.controldir.sprout('second') |
|
5353.2.2
by John Arbash Meinel
update the test suite. |
279 |
out, err = self.run_bzr('branch source target --files-from second' |
280 |
' --hardlink') |
|
281 |
source_stat = os.stat('source/file1') |
|
282 |
second_stat = os.stat('second/file1') |
|
283 |
target_stat = os.stat('target/file1') |
|
284 |
self.assertNotEqual(source_stat, target_stat) |
|
|
5353.2.5
by John Arbash Meinel
We need to assert that the --hardlink makes the files the same, not different. |
285 |
self.assertEqual(second_stat, target_stat) |
|
5353.2.2
by John Arbash Meinel
update the test suite. |
286 |
|
|
3696.2.1
by Daniel Watkins
Added test for 'branch --standalone'. |
287 |
def test_branch_standalone(self): |
288 |
shared_repo = self.make_repository('repo', shared=True) |
|
289 |
self.example_branch('source') |
|
290 |
self.run_bzr('branch --standalone source repo/target') |
|
291 |
b = branch.Branch.open('repo/target') |
|
292 |
expected_repo_path = os.path.abspath('repo/target/.bzr/repository') |
|
|
3696.2.4
by Daniel Watkins
Fixed test to cope with trailing slashes. |
293 |
self.assertEqual(strip_trailing_slash(b.repository.base), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
294 |
strip_trailing_slash(local_path_to_url(expected_repo_path))) |
|
3696.2.1
by Daniel Watkins
Added test for 'branch --standalone'. |
295 |
|
|
3983.1.5
by Daniel Watkins
Added blackbox test. |
296 |
def test_branch_no_tree(self): |
297 |
self.example_branch('source') |
|
298 |
self.run_bzr('branch --no-tree source target') |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
299 |
self.assertPathDoesNotExist('target/hello') |
300 |
self.assertPathDoesNotExist('target/goodbye') |
|
|
3983.1.5
by Daniel Watkins
Added blackbox test. |
301 |
|
|
4479.2.1
by Alexander Belchenko
branch command now has new flag --use-existing-dir to force branching into existing directory if there is no branch yet. |
302 |
def test_branch_into_existing_dir(self): |
303 |
self.example_branch('a') |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
304 |
# existing dir with similar files but no .brz dir
|
|
4479.2.2
by Vincent Ladeuil
Fix typos and add NEWS entry. |
305 |
self.build_tree_contents([('b/',)]) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
306 |
self.build_tree_contents([('b/hello', b'bar')]) # different content |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
307 |
self.build_tree_contents([('b/goodbye', b'baz')]) # same content |
|
4479.2.2
by Vincent Ladeuil
Fix typos and add NEWS entry. |
308 |
# fails without --use-existing-dir
|
|
6809.1.1
by Martin
Apply 2to3 ws_comma fixer |
309 |
out, err = self.run_bzr('branch a b', retcode=3) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
310 |
self.assertEqual('', out) |
311 |
self.assertEqual('brz: ERROR: Target directory "b" already exists.\n', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
312 |
err) |
|
4479.2.1
by Alexander Belchenko
branch command now has new flag --use-existing-dir to force branching into existing directory if there is no branch yet. |
313 |
# force operation
|
314 |
self.run_bzr('branch a b --use-existing-dir') |
|
315 |
# check conflicts
|
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
316 |
self.assertPathExists('b/hello.moved') |
317 |
self.assertPathDoesNotExist('b/godbye.moved') |
|
|
4479.2.1
by Alexander Belchenko
branch command now has new flag --use-existing-dir to force branching into existing directory if there is no branch yet. |
318 |
# we can't branch into branch
|
|
6809.1.1
by Martin
Apply 2to3 ws_comma fixer |
319 |
out, err = self.run_bzr('branch a b --use-existing-dir', retcode=3) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
320 |
self.assertEqual('', out) |
321 |
self.assertEqual('brz: ERROR: Already a branch: "b".\n', err) |
|
|
4479.2.1
by Alexander Belchenko
branch command now has new flag --use-existing-dir to force branching into existing directory if there is no branch yet. |
322 |
|
|
4927.3.1
by Ian Clatworthy
branch --bind option |
323 |
def test_branch_bind(self): |
324 |
self.example_branch('a') |
|
325 |
out, err = self.run_bzr('branch a b --bind') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
326 |
self.assertEndsWith(err, "New branch bound to a\n") |
|
4927.3.1
by Ian Clatworthy
branch --bind option |
327 |
b = branch.Branch.open('b') |
328 |
self.assertEndsWith(b.get_bound_location(), '/a/') |
|
329 |
||
|
5107.3.6
by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts. |
330 |
def test_branch_with_post_branch_init_hook(self): |
331 |
calls = [] |
|
332 |
branch.Branch.hooks.install_named_hook('post_branch_init', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
333 |
calls.append, None) |
|
5107.3.6
by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts. |
334 |
self.assertLength(0, calls) |
335 |
self.example_branch('a') |
|
336 |
self.assertLength(1, calls) |
|
337 |
self.run_bzr('branch a b') |
|
338 |
self.assertLength(2, calls) |
|
339 |
||
340 |
def test_checkout_with_post_branch_init_hook(self): |
|
341 |
calls = [] |
|
342 |
branch.Branch.hooks.install_named_hook('post_branch_init', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
343 |
calls.append, None) |
|
5107.3.6
by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts. |
344 |
self.assertLength(0, calls) |
345 |
self.example_branch('a') |
|
346 |
self.assertLength(1, calls) |
|
347 |
self.run_bzr('checkout a b') |
|
348 |
self.assertLength(2, calls) |
|
349 |
||
350 |
def test_lightweight_checkout_with_post_branch_init_hook(self): |
|
351 |
calls = [] |
|
352 |
branch.Branch.hooks.install_named_hook('post_branch_init', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
353 |
calls.append, None) |
|
5107.3.6
by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts. |
354 |
self.assertLength(0, calls) |
355 |
self.example_branch('a') |
|
356 |
self.assertLength(1, calls) |
|
357 |
self.run_bzr('checkout --lightweight a b') |
|
358 |
self.assertLength(2, calls) |
|
359 |
||
|
5535.3.1
by Andrew Bennetts
Initial hack to make 'bzr branch' (and BzrDir.sprout) fetch all tags, not just branch tip. |
360 |
def test_branch_fetches_all_tags(self): |
361 |
builder = self.make_branch_builder('source') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
362 |
source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev( |
363 |
builder) |
|
|
6747.3.2
by Jelmer Vernooij
Avoid more uses of revision_id. |
364 |
source.tags.set_tag('tag-a', rev2) |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
365 |
source.get_config_stack().set('branch.fetch_tags', True) |
|
5535.3.1
by Andrew Bennetts
Initial hack to make 'bzr branch' (and BzrDir.sprout) fetch all tags, not just branch tip. |
366 |
# Now source has a tag not in its ancestry. Make a branch from it.
|
367 |
self.run_bzr('branch source new-branch') |
|
368 |
new_branch = branch.Branch.open('new-branch') |
|
369 |
# The tag is present, and so is its revision.
|
|
|
6747.3.2
by Jelmer Vernooij
Avoid more uses of revision_id. |
370 |
self.assertEqual(rev2, new_branch.tags.lookup_tag('tag-a')) |
371 |
new_branch.repository.get_revision(rev2) |
|
|
5535.3.1
by Andrew Bennetts
Initial hack to make 'bzr branch' (and BzrDir.sprout) fetch all tags, not just branch tip. |
372 |
|
|
7404.5.1
by Jelmer Vernooij
Support checking out nested trees, including for git repositories. |
373 |
def test_branch_with_nested_trees(self): |
374 |
orig = self.make_branch_and_tree('source', format='development-subtree') |
|
375 |
subtree = self.make_branch_and_tree('source/subtree') |
|
376 |
self.build_tree(['source/subtree/a']) |
|
377 |
subtree.add(['a']) |
|
378 |
subtree.commit('add subtree contents') |
|
379 |
orig.add_reference(subtree) |
|
|
7447.4.2
by Jelmer Vernooij
Merge tree reference fixes. |
380 |
orig.set_reference_info('subtree', subtree.branch.user_url) |
|
7404.5.1
by Jelmer Vernooij
Support checking out nested trees, including for git repositories. |
381 |
orig.commit('add subtree') |
382 |
||
383 |
self.run_bzr('branch source target') |
|
384 |
||
385 |
target = WorkingTree.open('target') |
|
386 |
target_subtree = WorkingTree.open('target/subtree') |
|
387 |
self.assertTreesEqual(orig, target) |
|
388 |
self.assertTreesEqual(subtree, target_subtree) |
|
389 |
||
|
7447.3.1
by Jelmer Vernooij
Move tree reference info functions to workingtree. |
390 |
def test_branch_with_nested_trees_reference_unset(self): |
391 |
orig = self.make_branch_and_tree('source', format='development-subtree') |
|
392 |
subtree = self.make_branch_and_tree('source/subtree') |
|
393 |
self.build_tree(['source/subtree/a']) |
|
394 |
subtree.add(['a']) |
|
395 |
subtree.commit('add subtree contents') |
|
396 |
orig.add_reference(subtree) |
|
397 |
orig.commit('add subtree') |
|
398 |
||
399 |
self.run_bzr('branch source target') |
|
400 |
||
401 |
target = WorkingTree.open('target') |
|
402 |
self.assertRaises(errors.NotBranchError, WorkingTree.open, 'target/subtree') |
|
403 |
||
|
7404.5.1
by Jelmer Vernooij
Support checking out nested trees, including for git repositories. |
404 |
def test_branch_with_nested_trees_no_recurse(self): |
405 |
orig = self.make_branch_and_tree('source', format='development-subtree') |
|
406 |
subtree = self.make_branch_and_tree('source/subtree') |
|
407 |
self.build_tree(['source/subtree/a']) |
|
408 |
subtree.add(['a']) |
|
409 |
subtree.commit('add subtree contents') |
|
410 |
orig.add_reference(subtree) |
|
411 |
orig.commit('add subtree') |
|
412 |
||
413 |
self.run_bzr('branch --no-recurse-nested source target') |
|
414 |
||
415 |
target = WorkingTree.open('target') |
|
416 |
self.addCleanup(subtree.lock_read().unlock) |
|
417 |
basis = subtree.basis_tree() |
|
418 |
self.addCleanup(basis.lock_read().unlock) |
|
419 |
self.assertRaises(errors.NotBranchError, WorkingTree.open, 'target/subtree') |
|
420 |
||
|
3665.2.5
by John Arbash Meinel
Test that we alert the user to the upgrade. |
421 |
|
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
422 |
class TestBranchStacked(tests.TestCaseWithTransport): |
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
423 |
"""Tests for branch --stacked""" |
424 |
||
|
3517.4.11
by Martin Pool
Improved blackbox tests for stacked branches |
425 |
def assertRevisionInRepository(self, repo_path, revid): |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
426 |
"""Check that a revision is in a repo, disregarding stacking.""" |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
427 |
repo = controldir.ControlDir.open(repo_path).open_repository() |
|
3517.4.11
by Martin Pool
Improved blackbox tests for stacked branches |
428 |
self.assertTrue(repo.has_revision(revid)) |
429 |
||
430 |
def assertRevisionNotInRepository(self, repo_path, revid): |
|
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
431 |
"""Check that a revision is not in a repo, disregarding stacking.""" |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
432 |
repo = controldir.ControlDir.open(repo_path).open_repository() |
|
3517.4.11
by Martin Pool
Improved blackbox tests for stacked branches |
433 |
self.assertFalse(repo.has_revision(revid)) |
|
3221.11.19
by Robert Collins
Branching a shallow branch gets a shallow branch. |
434 |
|
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
435 |
def assertRevisionsInBranchRepository(self, revid_list, branch_path): |
436 |
repo = branch.Branch.open(branch_path).repository |
|
437 |
self.assertEqual(set(revid_list), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
438 |
repo.has_revisions(revid_list)) |
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
439 |
|
440 |
def test_branch_stacked_branch_not_stacked(self): |
|
441 |
"""Branching a stacked branch is not stacked by default""" |
|
|
3221.11.19
by Robert Collins
Branching a shallow branch gets a shallow branch. |
442 |
# We have a mainline
|
443 |
trunk_tree = self.make_branch_and_tree('target', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
444 |
format='1.9') |
|
3221.11.19
by Robert Collins
Branching a shallow branch gets a shallow branch. |
445 |
trunk_tree.commit('mainline') |
|
3221.20.3
by Ian Clatworthy
shallow -> stacked |
446 |
# and a branch from it which is stacked
|
|
3221.11.19
by Robert Collins
Branching a shallow branch gets a shallow branch. |
447 |
branch_tree = self.make_branch_and_tree('branch', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
448 |
format='1.9') |
|
3537.3.3
by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url |
449 |
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base) |
|
3221.11.19
by Robert Collins
Branching a shallow branch gets a shallow branch. |
450 |
# with some work on it
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
451 |
work_tree = trunk_tree.branch.controldir.sprout( |
452 |
'local').open_workingtree() |
|
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
453 |
work_tree.commit('moar work plz') |
454 |
work_tree.branch.push(branch_tree.branch) |
|
|
3221.11.19
by Robert Collins
Branching a shallow branch gets a shallow branch. |
455 |
# branching our local branch gives us a new stacked branch pointing at
|
456 |
# mainline.
|
|
457 |
out, err = self.run_bzr(['branch', 'branch', 'newbranch']) |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
458 |
self.assertEqual('', out) |
459 |
self.assertEqual('Branched 2 revisions.\n', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
460 |
err) |
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
461 |
# it should have preserved the branch format, and so it should be
|
462 |
# capable of supporting stacking, but not actually have a stacked_on
|
|
463 |
# branch configured
|
|
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
464 |
self.assertRaises(errors.NotStacked, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
465 |
controldir.ControlDir.open('newbranch').open_branch().get_stacked_on_url) |
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
466 |
|
467 |
def test_branch_stacked_branch_stacked(self): |
|
468 |
"""Asking to stack on a stacked branch does work""" |
|
469 |
# We have a mainline
|
|
470 |
trunk_tree = self.make_branch_and_tree('target', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
471 |
format='1.9') |
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
472 |
trunk_revid = trunk_tree.commit('mainline') |
473 |
# and a branch from it which is stacked
|
|
474 |
branch_tree = self.make_branch_and_tree('branch', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
475 |
format='1.9') |
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
476 |
branch_tree.branch.set_stacked_on_url(trunk_tree.branch.base) |
477 |
# with some work on it
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
478 |
work_tree = trunk_tree.branch.controldir.sprout( |
479 |
'local').open_workingtree() |
|
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
480 |
branch_revid = work_tree.commit('moar work plz') |
481 |
work_tree.branch.push(branch_tree.branch) |
|
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
482 |
# you can chain branches on from there
|
483 |
out, err = self.run_bzr(['branch', 'branch', '--stacked', 'branch2']) |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
484 |
self.assertEqual('', out) |
485 |
self.assertEqual('Created new stacked branch referring to %s.\n' % |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
486 |
branch_tree.branch.base, err) |
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
487 |
self.assertEqual(branch_tree.branch.base, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
488 |
branch.Branch.open('branch2').get_stacked_on_url()) |
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
489 |
branch2_tree = WorkingTree.open('branch2') |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
490 |
branch2_revid = work_tree.commit('work on second stacked branch') |
491 |
work_tree.branch.push(branch2_tree.branch) |
|
|
3549.1.4
by Martin Pool
Branching a stacked branch should not automatically turn on stacking |
492 |
self.assertRevisionInRepository('branch2', branch2_revid) |
493 |
self.assertRevisionsInBranchRepository( |
|
494 |
[trunk_revid, branch_revid, branch2_revid], |
|
495 |
'branch2') |
|
|
3221.11.19
by Robert Collins
Branching a shallow branch gets a shallow branch. |
496 |
|
|
3221.20.3
by Ian Clatworthy
shallow -> stacked |
497 |
def test_branch_stacked(self): |
|
3221.11.20
by Robert Collins
Support --shallow on branch. |
498 |
# We have a mainline
|
499 |
trunk_tree = self.make_branch_and_tree('mainline', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
500 |
format='1.9') |
|
3517.4.11
by Martin Pool
Improved blackbox tests for stacked branches |
501 |
original_revid = trunk_tree.commit('mainline') |
502 |
self.assertRevisionInRepository('mainline', original_revid) |
|
|
3221.20.3
by Ian Clatworthy
shallow -> stacked |
503 |
# and a branch from it which is stacked
|
504 |
out, err = self.run_bzr(['branch', '--stacked', 'mainline', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
505 |
'newbranch']) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
506 |
self.assertEqual('', out) |
507 |
self.assertEqual('Created new stacked branch referring to %s.\n' % |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
508 |
trunk_tree.branch.base, err) |
|
3517.4.11
by Martin Pool
Improved blackbox tests for stacked branches |
509 |
self.assertRevisionNotInRepository('newbranch', original_revid) |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
510 |
new_branch = branch.Branch.open('newbranch') |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
511 |
self.assertEqual(trunk_tree.branch.base, |
512 |
new_branch.get_stacked_on_url()) |
|
|
3221.11.20
by Robert Collins
Support --shallow on branch. |
513 |
|
|
3221.15.10
by Robert Collins
Add test that we can stack on a smart server from Jonathan Lange. |
514 |
def test_branch_stacked_from_smart_server(self): |
515 |
# We can branch stacking on a smart server
|
|
|
5017.3.40
by Vincent Ladeuil
-s bb.test_branch passing |
516 |
self.transport_server = test_server.SmartTCPServer_for_testing |
|
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) |
517 |
trunk = self.make_branch('mainline', format='1.9') |
|
3221.15.10
by Robert Collins
Add test that we can stack on a smart server from Jonathan Lange. |
518 |
out, err = self.run_bzr( |
519 |
['branch', '--stacked', self.get_url('mainline'), 'shallow']) |
|
520 |
||
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
521 |
def test_branch_stacked_from_non_stacked_format(self): |
522 |
"""The origin format doesn't support stacking""" |
|
523 |
trunk = self.make_branch('trunk', format='pack-0.92') |
|
524 |
out, err = self.run_bzr( |
|
525 |
['branch', '--stacked', 'trunk', 'shallow']) |
|
|
3665.2.5
by John Arbash Meinel
Test that we alert the user to the upgrade. |
526 |
# We should notify the user that we upgraded their format
|
|
3665.2.6
by John Arbash Meinel
Change the text a bit, and point to the explicit --1.6 or --1.6.1-rich-root bzrdir format. |
527 |
self.assertEqualDiff( |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
528 |
'Source repository format does not support stacking, using format:\n' |
529 |
' Packs 5 (adds stacking support, requires bzr 1.6)\n' |
|
530 |
'Source branch format does not support stacking, using format:\n' |
|
531 |
' Branch format 7\n' |
|
532 |
'Doing on-the-fly conversion from RepositoryFormatKnitPack1() to RepositoryFormatKnitPack5().\n' |
|
533 |
'This may take some time. Upgrade the repositories to the same format for better performance.\n' |
|
534 |
'Created new stacked branch referring to %s.\n' % |
|
535 |
(trunk.base,), |
|
|
3665.2.6
by John Arbash Meinel
Change the text a bit, and point to the explicit --1.6 or --1.6.1-rich-root bzrdir format. |
536 |
err) |
537 |
||
538 |
def test_branch_stacked_from_rich_root_non_stackable(self): |
|
539 |
trunk = self.make_branch('trunk', format='rich-root-pack') |
|
540 |
out, err = self.run_bzr( |
|
541 |
['branch', '--stacked', 'trunk', 'shallow']) |
|
542 |
# We should notify the user that we upgraded their format
|
|
543 |
self.assertEqualDiff( |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
544 |
'Source repository format does not support stacking, using format:\n' |
545 |
' Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)\n' |
|
546 |
'Source branch format does not support stacking, using format:\n' |
|
547 |
' Branch format 7\n' |
|
548 |
'Doing on-the-fly conversion from RepositoryFormatKnitPack4() to RepositoryFormatKnitPack5RichRoot().\n' |
|
549 |
'This may take some time. Upgrade the repositories to the same format for better performance.\n' |
|
550 |
'Created new stacked branch referring to %s.\n' % (trunk.base,), |
|
|
3665.2.6
by John Arbash Meinel
Change the text a bit, and point to the explicit --1.6 or --1.6.1-rich-root bzrdir format. |
551 |
err) |
552 |
||
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
553 |
|
|
2485.8.59
by Vincent Ladeuil
Update from review comments. |
554 |
class TestRemoteBranch(TestCaseWithSFTPServer): |
555 |
||
556 |
def setUp(self): |
|
557 |
super(TestRemoteBranch, self).setUp() |
|
558 |
tree = self.make_branch_and_tree('branch') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
559 |
self.build_tree_contents([('branch/file', b'file content\n')]) |
|
2485.8.59
by Vincent Ladeuil
Update from review comments. |
560 |
tree.add('file') |
561 |
tree.commit('file created') |
|
562 |
||
563 |
def test_branch_local_remote(self): |
|
564 |
self.run_bzr(['branch', 'branch', self.get_url('remote')]) |
|
565 |
t = self.get_transport() |
|
|
2485.8.62
by Vincent Ladeuil
From review comments, fix typos and deprecate some functions. |
566 |
# Ensure that no working tree what created remotely
|
|
2485.8.59
by Vincent Ladeuil
Update from review comments. |
567 |
self.assertFalse(t.has('remote/file')) |
568 |
||
569 |
def test_branch_remote_remote(self): |
|
570 |
# Light cheat: we access the branch remotely
|
|
571 |
self.run_bzr(['branch', self.get_url('branch'), |
|
572 |
self.get_url('remote')]) |
|
573 |
t = self.get_transport() |
|
|
2485.8.62
by Vincent Ladeuil
From review comments, fix typos and deprecate some functions. |
574 |
# Ensure that no working tree what created remotely
|
|
2485.8.59
by Vincent Ladeuil
Update from review comments. |
575 |
self.assertFalse(t.has('remote/file')) |
576 |
||
|
5741.3.3
by Martin Pool
Add a blackbox test for deprecation of commands |
577 |
|
|
5816.7.1
by Vincent Ladeuil
Remove duplication and simplify. |
578 |
class TestBranchParentLocation(test_switch.TestSwitchParentLocationBase): |
579 |
||
580 |
def _checkout_and_branch(self, option=''): |
|
581 |
self.script_runner.run_script(self, ''' |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
582 |
$ brz checkout %(option)s repo/trunk checkout |
|
5816.7.1
by Vincent Ladeuil
Remove duplication and simplify. |
583 |
$ cd checkout
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
584 |
$ brz branch --switch ../repo/trunk ../repo/branched
|
|
6143.1.4
by Jonathan Riddell
update tests |
585 |
2>Branched 0 revisions.
|
|
5816.6.8
by A. S. Budden
Refactored to use common generation code for lightweight and heavyweight. |
586 |
2>Tree is up to date at revision 0.
|
|
5816.7.1
by Vincent Ladeuil
Remove duplication and simplify. |
587 |
2>Switched to branch:...branched...
|
|
5816.6.11
by A. S. Budden
Refactored assertParentCorrect to check the full path. |
588 |
$ cd ..
|
|
5816.6.10
by A. S. Budden
Use locals() instead of kwargs for more explicit parameters. |
589 |
''' % locals()) |
|
5816.7.1
by Vincent Ladeuil
Remove duplication and simplify. |
590 |
bound_branch = branch.Branch.open_containing('checkout')[0] |
591 |
master_branch = branch.Branch.open_containing('repo/branched')[0] |
|
|
5816.6.12
by A. S. Budden
Check parent branch of both the checkout (light or heavy) and the branch to which it is connected. |
592 |
return (bound_branch, master_branch) |
|
5816.6.8
by A. S. Budden
Refactored to use common generation code for lightweight and heavyweight. |
593 |
|
|
5816.6.7
by A. S. Budden
Moved test harnesses into test_switch and test_branch as these are the commands that are being tested. |
594 |
def test_branch_switch_parent_lightweight(self): |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
595 |
"""Lightweight checkout using brz branch --switch.""" |
|
5816.7.1
by Vincent Ladeuil
Remove duplication and simplify. |
596 |
bb, mb = self._checkout_and_branch(option='--lightweight') |
597 |
self.assertParent('repo/trunk', bb) |
|
598 |
self.assertParent('repo/trunk', mb) |
|
|
5816.6.7
by A. S. Budden
Moved test harnesses into test_switch and test_branch as these are the commands that are being tested. |
599 |
|
600 |
def test_branch_switch_parent_heavyweight(self): |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
601 |
"""Heavyweight checkout using brz branch --switch.""" |
|
5816.7.1
by Vincent Ladeuil
Remove duplication and simplify. |
602 |
bb, mb = self._checkout_and_branch() |
603 |
self.assertParent('repo/trunk', bb) |
|
604 |
self.assertParent('repo/trunk', mb) |