/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_branch.py

  • Committer: Jelmer Vernooij
  • Date: 2011-10-13 14:14:10 UTC
  • mfrom: (6212 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6213.
  • Revision ID: jelmer@samba.org-20111013141410-wuujr2ne9otq7v7r
MergeĀ lp:bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
254
254
                          self.get_branch().repository.get_revision,
255
255
                          None)
256
256
 
257
 
# TODO 20051003 RBC:
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.
261
 
 
262
 
    def test_sign_existing_revision(self):
263
 
        wt = self.make_branch_and_tree('.')
264
 
        branch = wt.branch
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'))
278
 
 
279
 
    def test_store_signature(self):
280
 
        wt = self.make_branch_and_tree('.')
281
 
        branch = wt.branch
282
 
        branch.lock_write()
283
 
        try:
284
 
            branch.repository.start_write_group()
285
 
            try:
286
 
                branch.repository.store_revision_signature(
287
 
                    gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
288
 
            except:
289
 
                branch.repository.abort_write_group()
290
 
                raise
291
 
            else:
292
 
                branch.repository.commit_write_group()
293
 
        finally:
294
 
            branch.unlock()
295
 
        # A signature without a revision should not be accessible.
296
 
        self.assertRaises(errors.NoSuchRevision,
297
 
                          branch.repository.has_signature_for_revision_id,
298
 
                          'A')
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'))
303
 
 
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
308
 
        repo.lock_write()
309
 
        repo.start_write_group()
310
 
        repo.sign_revision('A', gpg.LoopbackGPGStrategy(None))
311
 
        repo.commit_write_group()
312
 
        repo.unlock()
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'))
319
 
 
320
257
    def test_nicks_bzr(self):
321
258
        """Test the behaviour of branch nicks specific to bzr branches.
322
259
 
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)