119
119
def test_fetch_revisions(self):
120
120
"""Test fetch-revision operation."""
121
get_transport(self.get_url()).mkdir('b1')
122
get_transport(self.get_url()).mkdir('b2')
123
121
wt = self.make_branch_and_tree('b1')
125
123
b2 = self.make_branch('b2')
126
file('b1/foo', 'w').write('hello')
124
wt.bzrdir.root_transport.put_bytes('foo', 'hello')
127
125
wt.add(['foo'], ['foo-id'])
128
126
wt.commit('lala!', rev_id='revision-1', allow_pointless=False)
137
135
def test_get_revision_delta(self):
138
136
tree_a = self.make_branch_and_tree('a')
139
self.build_tree(['a/foo'])
137
transport = tree_a.bzrdir.root_transport
138
self.build_tree(['foo'], transport=transport)
140
139
tree_a.add('foo', 'file1')
141
140
tree_a.commit('rev1', rev_id='rev1')
142
self.build_tree(['a/vla'])
141
self.build_tree(['vla'], transport=transport)
143
142
tree_a.add('vla', 'file2')
144
143
tree_a.commit('rev2', rev_id='rev2')
337
336
d2.open_repository().get_signature_text('A'))
339
338
def test_nicks(self):
340
"""Branch nicknames"""
339
"""Test explicit and implicit branch nicknames.
341
Nicknames are implicitly the name of the branch's directory, unless an
342
explicit nickname is set. That is, an explicit nickname always
343
overrides the implicit one.
345
# Make a branch in a directory called 'bzr.dev'
341
346
t = get_transport(self.get_url())
342
347
t.mkdir('bzr.dev')
343
348
branch = self.make_branch('bzr.dev')
349
# The nick will be 'bzr.dev', because there is no explicit nick set.
344
350
self.assertEqual(branch.nick, 'bzr.dev')
351
# Move the branch to a different directory, 'bzr.ab'. Now that branch
352
# will report its nick as 'bzr.ab'.
345
353
t.move('bzr.dev', 'bzr.ab')
346
354
branch = Branch.open(self.get_url('bzr.ab'))
347
355
self.assertEqual(branch.nick, 'bzr.ab')
348
branch.nick = "Aaron's branch"
349
branch.nick = "Aaron's branch"
353
branch.control_files.controlfilename("branch.conf")
356
# Set the branch nick explicitly. This will ensure there's a branch
357
# config file in the branch.
358
branch.nick = "Aaron's branch"
359
branch.nick = "Aaron's branch"
361
controlfilename = branch.control_files.controlfilename
362
except AttributeError:
363
# remote branches don't have control_files
367
t.has(t.relpath(controlfilename("branch.conf"))))
368
# Because the nick has been set explicitly, the nick is now always
369
# "Aaron's branch", regardless of directory name.
357
370
self.assertEqual(branch.nick, "Aaron's branch")
358
371
t.move('bzr.ab', 'integration')
359
372
branch = Branch.open(self.get_url('integration'))
377
390
repo = self.make_repository('.', shared=True)
378
391
except errors.IncompatibleFormat:
380
repo.bzrdir.root_transport.mkdir('child')
381
child_dir = self.bzrdir_format.initialize('child')
393
child_transport = repo.bzrdir.root_transport.clone('child')
394
child_transport.mkdir('.')
395
child_dir = self.bzrdir_format.initialize_on_transport(child_transport)
383
397
child_branch = self.branch_format.initialize(child_dir)
384
398
except errors.UninitializableFormat:
448
462
"""A lightweight checkout from a readonly branch should succeed."""
449
463
tree_a = self.make_branch_and_tree('a')
450
464
rev_id = tree_a.commit('put some content in the branch')
451
source_branch = bzrlib.branch.Branch.open(
452
'readonly+' + tree_a.bzrdir.root_transport.base)
465
# open the branch via a readonly transport
466
source_branch = bzrlib.branch.Branch.open(self.get_readonly_url('a'))
453
467
# sanity check that the test will be valid
454
468
self.assertRaises((errors.LockError, errors.TransportNotPossible),
455
469
source_branch.lock_write)
460
474
"""A regular checkout from a readonly branch should succeed."""
461
475
tree_a = self.make_branch_and_tree('a')
462
476
rev_id = tree_a.commit('put some content in the branch')
463
source_branch = bzrlib.branch.Branch.open(
464
'readonly+' + tree_a.branch.bzrdir.root_transport.base)
477
# open the branch via a readonly transport
478
source_branch = bzrlib.branch.Branch.open(self.get_readonly_url('a'))
465
479
# sanity check that the test will be valid
466
480
self.assertRaises((errors.LockError, errors.TransportNotPossible),
467
481
source_branch.lock_write)