254
254
self.get_branch().repository.get_revision,
258
# compare the gpg-to-sign info for a commit with a ghost and
259
# an identical tree without a ghost
260
# fetch missing should rewrite the TOC of weaves to list newly available parents.
262
def test_sign_existing_revision(self):
263
wt = self.make_branch_and_tree('.')
265
wt.commit("base", allow_pointless=True, rev_id='A')
266
from bzrlib.testament import Testament
267
strategy = gpg.LoopbackGPGStrategy(None)
268
branch.repository.lock_write()
269
branch.repository.start_write_group()
270
branch.repository.sign_revision('A', strategy)
271
branch.repository.commit_write_group()
272
branch.repository.unlock()
273
self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n' +
274
Testament.from_revision(branch.repository,
275
'A').as_short_text() +
276
'-----END PSEUDO-SIGNED CONTENT-----\n',
277
branch.repository.get_signature_text('A'))
279
def test_store_signature(self):
280
wt = self.make_branch_and_tree('.')
284
branch.repository.start_write_group()
286
branch.repository.store_revision_signature(
287
gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
289
branch.repository.abort_write_group()
292
branch.repository.commit_write_group()
295
# A signature without a revision should not be accessible.
296
self.assertRaises(errors.NoSuchRevision,
297
branch.repository.has_signature_for_revision_id,
299
wt.commit("base", allow_pointless=True, rev_id='A')
300
self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n'
301
'FOO-----END PSEUDO-SIGNED CONTENT-----\n',
302
branch.repository.get_signature_text('A'))
304
def test_branch_keeps_signatures(self):
305
wt = self.make_branch_and_tree('source')
306
wt.commit('A', allow_pointless=True, rev_id='A')
307
repo = wt.branch.repository
309
repo.start_write_group()
310
repo.sign_revision('A', gpg.LoopbackGPGStrategy(None))
311
repo.commit_write_group()
313
#FIXME: clone should work to urls,
314
# wt.clone should work to disks.
315
self.build_tree(['target/'])
316
d2 = repo.bzrdir.clone(urlutils.local_path_to_url('target'))
317
self.assertEqual(repo.get_signature_text('A'),
318
d2.open_repository().get_signature_text('A'))
320
257
def test_nicks_bzr(self):
321
258
"""Test the behaviour of branch nicks specific to bzr branches.
511
448
tree_a = self.make_branch_and_tree('a')
512
449
rev_id = tree_a.commit('put some content in the branch')
513
450
# open the branch via a readonly transport
514
source_branch = _mod_branch.Branch.open(
515
self.get_readonly_url(
516
osutils.basename(tree_a.branch.base.rstrip('/'))))
451
url = self.get_readonly_url(
452
osutils.basename(tree_a.branch.base.rstrip('/')))
453
t = transport.get_transport_from_url(url)
454
if not tree_a.branch.bzrdir._format.supports_transport(t):
455
raise tests.TestNotApplicable("format does not support transport")
456
source_branch = _mod_branch.Branch.open(url)
517
457
# sanity check that the test will be valid
518
458
self.assertRaises((errors.LockError, errors.TransportNotPossible),
519
459
source_branch.lock_write)
601
541
_mod_branch.Branch.open_containing,
602
542
self.get_readonly_url('g/p/q'))
603
543
branch = self.make_branch('.')
544
if not branch.bzrdir._format.supports_transport(
545
transport.get_transport_from_url(self.get_readonly_url('.'))):
546
raise tests.TestNotApplicable("format does not support transport")
604
547
branch, relpath = _mod_branch.Branch.open_containing(
605
548
self.get_readonly_url(''))
606
549
self.assertEqual('', relpath)