96
92
self.build_tree(['source/file1'])
97
93
source.add('file1')
98
94
source.commit('added file')
99
out, err = self.run_bzr(['branch', 'source', 'target', '--hardlink'])
95
self.run_bzr(['branch', 'source', 'target', '--hardlink'])
100
96
source_stat = os.stat('source/file1')
101
97
target_stat = os.stat('target/file1')
102
same_file = (source_stat == target_stat)
106
# https://bugs.edge.launchpad.net/bzr/+bug/408193
107
self.assertContainsRe(err, "hardlinking working copy files is "
108
"not currently supported")
109
raise KnownFailure("--hardlink doesn't work in formats "
110
"that support content filtering (#408193)")
112
def test_branch_standalone(self):
113
shared_repo = self.make_repository('repo', shared=True)
114
self.example_branch('source')
115
self.run_bzr('branch --standalone source repo/target')
116
b = branch.Branch.open('repo/target')
117
expected_repo_path = os.path.abspath('repo/target/.bzr/repository')
118
self.assertEqual(strip_trailing_slash(b.repository.base),
119
strip_trailing_slash(local_path_to_url(expected_repo_path)))
121
def test_branch_no_tree(self):
122
self.example_branch('source')
123
self.run_bzr('branch --no-tree source target')
124
self.failIfExists('target/hello')
125
self.failIfExists('target/goodbye')
127
def test_branch_into_existing_dir(self):
128
self.example_branch('a')
129
# existing dir with similar files but no .bzr dir
130
self.build_tree_contents([('b/',)])
131
self.build_tree_contents([('b/hello', 'bar')]) # different content
132
self.build_tree_contents([('b/goodbye', 'baz')])# same content
133
# fails without --use-existing-dir
134
out,err = self.run_bzr('branch a b', retcode=3)
135
self.assertEqual('', out)
136
self.assertEqual('bzr: ERROR: Target directory "b" already exists.\n',
139
self.run_bzr('branch a b --use-existing-dir')
141
self.failUnlessExists('b/hello.moved')
142
self.failIfExists('b/godbye.moved')
143
# we can't branch into branch
144
out,err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
145
self.assertEqual('', out)
146
self.assertEqual('bzr: ERROR: Already a branch: "b".\n', err)
98
self.assertEqual(source_stat, target_stat)
149
100
class TestBranchStacked(ExternalBase):
150
101
"""Tests for branch --stacked"""
152
103
def check_shallow_branch(self, branch_revid, stacked_on):
153
104
"""Assert that the branch 'newbranch' has been published correctly.
155
106
:param stacked_on: url of a branch this one is stacked upon.
156
:param branch_revid: a revision id that should be the only
107
:param branch_revid: a revision id that should be the only
157
108
revision present in the stacked branch, and it should not be in
158
109
the reference branch.
267
218
trunk = self.make_branch('trunk', format='pack-0.92')
268
219
out, err = self.run_bzr(
269
220
['branch', '--stacked', 'trunk', 'shallow'])
270
# We should notify the user that we upgraded their format
271
self.assertEqualDiff(
272
'Source repository format does not support stacking, using format:\n'
273
' Packs 5 (adds stacking support, requires bzr 1.6)\n'
274
'Source branch format does not support stacking, using format:\n'
276
'Created new stacked branch referring to %s.\n' % (trunk.base,),
279
def test_branch_stacked_from_rich_root_non_stackable(self):
280
trunk = self.make_branch('trunk', format='rich-root-pack')
281
out, err = self.run_bzr(
282
['branch', '--stacked', 'trunk', 'shallow'])
283
# We should notify the user that we upgraded their format
284
self.assertEqualDiff(
285
'Source repository format does not support stacking, using format:\n'
286
' Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)\n'
287
'Source branch format does not support stacking, using format:\n'
289
'Created new stacked branch referring to %s.\n' % (trunk.base,),
293
class TestSmartServerBranching(ExternalBase):
295
def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
296
self.setup_smart_server_with_call_log()
297
t = self.make_branch_and_tree('from')
298
for count in range(9):
299
t.commit(message='commit %d' % count)
300
self.reset_smart_call_log()
301
out, err = self.run_bzr(['branch', self.get_url('from'),
302
self.get_url('target')])
303
# This figure represent the amount of work to perform this use case. It
304
# is entirely ok to reduce this number if a test fails due to rpc_count
305
# being too low. If rpc_count increases, more network roundtrips have
306
# become necessary for this use case. Please do not adjust this number
307
# upwards without agreement from bzr's network support maintainers.
308
self.assertLength(38, self.hpss_calls)
310
def test_branch_from_trivial_branch_streaming_acceptance(self):
311
self.setup_smart_server_with_call_log()
312
t = self.make_branch_and_tree('from')
313
for count in range(9):
314
t.commit(message='commit %d' % count)
315
self.reset_smart_call_log()
316
out, err = self.run_bzr(['branch', self.get_url('from'),
318
# This figure represent the amount of work to perform this use case. It
319
# is entirely ok to reduce this number if a test fails due to rpc_count
320
# being too low. If rpc_count increases, more network roundtrips have
321
# become necessary for this use case. Please do not adjust this number
322
# upwards without agreement from bzr's network support maintainers.
323
self.assertLength(10, self.hpss_calls)
325
def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
326
self.setup_smart_server_with_call_log()
327
t = self.make_branch_and_tree('trunk')
328
for count in range(8):
329
t.commit(message='commit %d' % count)
330
tree2 = t.branch.bzrdir.sprout('feature', stacked=True
332
tree2.commit('feature change')
333
self.reset_smart_call_log()
334
out, err = self.run_bzr(['branch', self.get_url('feature'),
336
# This figure represent the amount of work to perform this use case. It
337
# is entirely ok to reduce this number if a test fails due to rpc_count
338
# being too low. If rpc_count increases, more network roundtrips have
339
# become necessary for this use case. Please do not adjust this number
340
# upwards without agreement from bzr's network support maintainers.
341
self.assertLength(15, self.hpss_calls)
344
223
class TestRemoteBranch(TestCaseWithSFTPServer):