~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2011-10-14 13:56:45 UTC
  • mfrom: (6215 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6216.
  • Revision ID: jelmer@samba.org-20111014135645-phc3q3y21k2ks0s2
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    errors,
25
25
    gpg,
26
26
    merge,
 
27
    osutils,
27
28
    urlutils,
28
29
    transport,
29
30
    remote,
251
252
                          self.get_branch().repository.get_revision,
252
253
                          None)
253
254
 
254
 
# TODO 20051003 RBC:
255
 
# compare the gpg-to-sign info for a commit with a ghost and
256
 
#     an identical tree without a ghost
257
 
# fetch missing should rewrite the TOC of weaves to list newly available parents.
258
 
 
259
 
    def test_sign_existing_revision(self):
260
 
        wt = self.make_branch_and_tree('.')
261
 
        branch = wt.branch
262
 
        wt.commit("base", allow_pointless=True, rev_id='A')
263
 
        from bzrlib.testament import Testament
264
 
        strategy = gpg.LoopbackGPGStrategy(None)
265
 
        branch.repository.lock_write()
266
 
        branch.repository.start_write_group()
267
 
        branch.repository.sign_revision('A', strategy)
268
 
        branch.repository.commit_write_group()
269
 
        branch.repository.unlock()
270
 
        self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n' +
271
 
                         Testament.from_revision(branch.repository,
272
 
                         'A').as_short_text() +
273
 
                         '-----END PSEUDO-SIGNED CONTENT-----\n',
274
 
                         branch.repository.get_signature_text('A'))
275
 
 
276
 
    def test_store_signature(self):
277
 
        wt = self.make_branch_and_tree('.')
278
 
        branch = wt.branch
279
 
        branch.lock_write()
280
 
        try:
281
 
            branch.repository.start_write_group()
282
 
            try:
283
 
                branch.repository.store_revision_signature(
284
 
                    gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
285
 
            except:
286
 
                branch.repository.abort_write_group()
287
 
                raise
288
 
            else:
289
 
                branch.repository.commit_write_group()
290
 
        finally:
291
 
            branch.unlock()
292
 
        # A signature without a revision should not be accessible.
293
 
        self.assertRaises(errors.NoSuchRevision,
294
 
                          branch.repository.has_signature_for_revision_id,
295
 
                          'A')
296
 
        wt.commit("base", allow_pointless=True, rev_id='A')
297
 
        self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n'
298
 
                         'FOO-----END PSEUDO-SIGNED CONTENT-----\n',
299
 
                         branch.repository.get_signature_text('A'))
300
 
 
301
 
    def test_branch_keeps_signatures(self):
302
 
        wt = self.make_branch_and_tree('source')
303
 
        wt.commit('A', allow_pointless=True, rev_id='A')
304
 
        repo = wt.branch.repository
305
 
        repo.lock_write()
306
 
        repo.start_write_group()
307
 
        repo.sign_revision('A', gpg.LoopbackGPGStrategy(None))
308
 
        repo.commit_write_group()
309
 
        repo.unlock()
310
 
        #FIXME: clone should work to urls,
311
 
        # wt.clone should work to disks.
312
 
        self.build_tree(['target/'])
313
 
        d2 = repo.bzrdir.clone(urlutils.local_path_to_url('target'))
314
 
        self.assertEqual(repo.get_signature_text('A'),
315
 
                         d2.open_repository().get_signature_text('A'))
316
 
 
317
255
    def test_nicks_bzr(self):
318
256
        """Test the behaviour of branch nicks specific to bzr branches.
319
257
 
504
442
        tree_a = self.make_branch_and_tree('a')
505
443
        rev_id = tree_a.commit('put some content in the branch')
506
444
        # open the branch via a readonly transport
507
 
        source_branch = _mod_branch.Branch.open(self.get_readonly_url('a'))
 
445
        source_branch = _mod_branch.Branch.open(self.get_readonly_url(
 
446
            urlutils.basename(tree_a.branch.base)))
508
447
        # sanity check that the test will be valid
509
448
        self.assertRaises((errors.LockError, errors.TransportNotPossible),
510
449
            source_branch.lock_write)
516
455
        tree_a = self.make_branch_and_tree('a')
517
456
        rev_id = tree_a.commit('put some content in the branch')
518
457
        # open the branch via a readonly transport
519
 
        source_branch = _mod_branch.Branch.open(self.get_readonly_url('a'))
 
458
        url = self.get_readonly_url(
 
459
            osutils.basename(tree_a.branch.base.rstrip('/')))
 
460
        t = transport.get_transport_from_url(url)
 
461
        if not tree_a.branch.bzrdir._format.supports_transport(t):
 
462
            raise tests.TestNotApplicable("format does not support transport")
 
463
        source_branch = _mod_branch.Branch.open(url)
520
464
        # sanity check that the test will be valid
521
465
        self.assertRaises((errors.LockError, errors.TransportNotPossible),
522
466
            source_branch.lock_write)
604
548
                          _mod_branch.Branch.open_containing,
605
549
                          self.get_readonly_url('g/p/q'))
606
550
        branch = self.make_branch('.')
 
551
        if not branch.bzrdir._format.supports_transport(
 
552
            transport.get_transport_from_url(self.get_readonly_url('.'))):
 
553
            raise tests.TestNotApplicable("format does not support transport")
607
554
        branch, relpath = _mod_branch.Branch.open_containing(
608
555
            self.get_readonly_url(''))
609
556
        self.assertEqual('', relpath)
931
878
            tree.add_reference(subtree)
932
879
        except errors.UnsupportedOperation:
933
880
            raise tests.TestNotApplicable('Tree cannot hold references.')
934
 
        reference_parent = tree.branch.reference_parent('subtree-id',
935
 
                                                        'subtree')
 
881
        reference_parent = tree.branch.reference_parent(
 
882
            'subtree-id',
 
883
            urlutils.relative_url(tree.branch.user_url, subtree.branch.user_url))
936
884
        self.assertEqual(subtree.branch.base, reference_parent.base)
937
885
 
938
886
    def test_reference_parent_accepts_possible_transports(self):
944
892
        except errors.UnsupportedOperation:
945
893
            raise tests.TestNotApplicable('Tree cannot hold references.')
946
894
        reference_parent = tree.branch.reference_parent('subtree-id',
947
 
            'subtree', possible_transports=[subtree.bzrdir.root_transport])
 
895
            urlutils.relative_url(
 
896
                tree.branch.user_url, subtree.branch.user_url),
 
897
            possible_transports=[subtree.bzrdir.root_transport])
948
898
 
949
899
    def test_get_reference_info(self):
950
900
        branch = self.make_branch('branch')