/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/branch_implementations/test_branch.py

  • Committer: Aaron Bentley
  • Date: 2006-06-21 13:37:30 UTC
  • mfrom: (1799 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1802.
  • Revision ID: abentley@panoramicfeedback.com-20060621133730-6f6f965f4d2e3743
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
import os
20
20
import sys
21
21
 
22
 
import bzrlib.branch
23
 
import bzrlib.bzrdir as bzrdir
 
22
from bzrlib import branch, bzrdir, errors, gpg, transactions, repository
24
23
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
25
 
from bzrlib.commit import commit
26
24
from bzrlib.delta import TreeDelta
27
 
import bzrlib.errors as errors
28
25
from bzrlib.errors import (FileExists,
29
26
                           NoSuchRevision,
30
27
                           NoSuchFile,
31
28
                           UninitializableFormat,
32
29
                           NotBranchError,
33
30
                           )
34
 
import bzrlib.gpg
35
31
from bzrlib.osutils import getcwd
36
32
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
37
33
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
38
34
from bzrlib.trace import mutter
39
 
import bzrlib.transactions as transactions
40
35
from bzrlib.transport import get_transport
41
36
from bzrlib.transport.http import HttpServer
42
37
from bzrlib.transport.memory import MemoryServer
244
239
        branch = wt.branch
245
240
        wt.commit("base", allow_pointless=True, rev_id='A')
246
241
        from bzrlib.testament import Testament
247
 
        strategy = bzrlib.gpg.LoopbackGPGStrategy(None)
 
242
        strategy = gpg.LoopbackGPGStrategy(None)
248
243
        branch.repository.sign_revision('A', strategy)
249
244
        self.assertEqual(Testament.from_revision(branch.repository, 
250
245
                         'A').as_short_text(),
254
249
        wt = self.make_branch_and_tree('.')
255
250
        branch = wt.branch
256
251
        branch.repository.store_revision_signature(
257
 
            bzrlib.gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
 
252
            gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
258
253
        self.assertRaises(errors.NoSuchRevision,
259
254
                          branch.repository.has_signature_for_revision_id,
260
255
                          'A')
266
261
        wt = self.make_branch_and_tree('source')
267
262
        wt.commit('A', allow_pointless=True, rev_id='A')
268
263
        wt.branch.repository.sign_revision('A',
269
 
            bzrlib.gpg.LoopbackGPGStrategy(None))
 
264
            gpg.LoopbackGPGStrategy(None))
270
265
        #FIXME: clone should work to urls,
271
266
        # wt.clone should work to disks.
272
267
        self.build_tree(['target/'])
324
319
            return
325
320
        self.assertEqual(repo.bzrdir.root_transport.base,
326
321
                         child_branch.repository.bzrdir.root_transport.base)
327
 
        child_branch = bzrlib.branch.Branch.open(self.get_url('child'))
 
322
        child_branch = branch.Branch.open(self.get_url('child'))
328
323
        self.assertEqual(repo.bzrdir.root_transport.base,
329
324
                         child_branch.repository.bzrdir.root_transport.base)
330
325
 
343
338
 
344
339
    def test_get_commit_builder(self):
345
340
        self.assertIsInstance(self.make_branch(".").get_commit_builder([]), 
346
 
            bzrlib.repository.CommitBuilder)
 
341
            repository.CommitBuilder)
347
342
 
348
343
 
349
344
class ChrootedTests(TestCaseWithBranch):
370
365
        branch, relpath = Branch.open_containing(self.get_readonly_url('g/p/q'))
371
366
        self.assertEqual('g/p/q', relpath)
372
367
        
373
 
# TODO: rewrite this as a regular unittest, without relying on the displayed output        
374
 
#         >>> from bzrlib.commit import commit
375
 
#         >>> bzrlib.trace.silent = True
376
 
#         >>> br1 = ScratchBranch(files=['foo', 'bar'])
377
 
#         >>> br1.working_tree().add('foo')
378
 
#         >>> br1.working_tree().add('bar')
379
 
#         >>> commit(br1, "lala!", rev_id="REVISION-ID-1", verbose=False)
380
 
#         >>> br2 = ScratchBranch()
381
 
#         >>> br2.update_revisions(br1)
382
 
#         Added 2 texts.
383
 
#         Added 1 inventories.
384
 
#         Added 1 revisions.
385
 
#         >>> br2.revision_history()
386
 
#         [u'REVISION-ID-1']
387
 
#         >>> br2.update_revisions(br1)
388
 
#         Added 0 revisions.
389
 
#         >>> br1.text_store.total_size() == br2.text_store.total_size()
390
 
#         True
391
368
 
392
369
class InstrumentedTransaction(object):
393
370
 
544
521
        t = get_transport(self.get_url())
545
522
        readonly_t = get_transport(self.get_readonly_url())
546
523
        made_branch = self.make_branch('.')
547
 
        self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
 
524
        self.failUnless(isinstance(made_branch, branch.Branch))
548
525
 
549
526
        # find it via bzrdir opening:
550
527
        opened_control = bzrdir.BzrDir.open(readonly_t.base)
555
532
                        self.branch_format.__class__))
556
533
 
557
534
        # find it via Branch.open
558
 
        opened_branch = bzrlib.branch.Branch.open(readonly_t.base)
 
535
        opened_branch = branch.Branch.open(readonly_t.base)
559
536
        self.failUnless(isinstance(opened_branch, made_branch.__class__))
560
537
        self.assertEqual(made_branch._format.__class__,
561
538
                         opened_branch._format.__class__)
565
542
        except NotImplementedError:
566
543
            return
567
544
        self.assertEqual(self.branch_format,
568
 
                         bzrlib.branch.BranchFormat.find_format(opened_control))
 
545
                         branch.BranchFormat.find_format(opened_control))