/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: Martin Pool
  • Date: 2006-06-20 03:57:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1798.
  • Revision ID: mbp@sourcefrog.net-20060620035711-400bb6b6bc6ff95b
Add pyflakes makefile target; fix many warnings

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
 
import bzrlib.errors as errors
27
24
from bzrlib.errors import (FileExists,
28
25
                           NoSuchRevision,
29
26
                           NoSuchFile,
30
27
                           UninitializableFormat,
31
28
                           NotBranchError,
32
29
                           )
33
 
import bzrlib.gpg
34
30
from bzrlib.osutils import getcwd
35
31
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
36
32
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
37
33
from bzrlib.trace import mutter
38
 
import bzrlib.transactions as transactions
39
34
from bzrlib.transport import get_transport
40
35
from bzrlib.transport.http import HttpServer
41
36
from bzrlib.transport.memory import MemoryServer
227
222
        branch = wt.branch
228
223
        wt.commit("base", allow_pointless=True, rev_id='A')
229
224
        from bzrlib.testament import Testament
230
 
        strategy = bzrlib.gpg.LoopbackGPGStrategy(None)
 
225
        strategy = gpg.LoopbackGPGStrategy(None)
231
226
        branch.repository.sign_revision('A', strategy)
232
227
        self.assertEqual(Testament.from_revision(branch.repository, 
233
228
                         'A').as_short_text(),
237
232
        wt = self.make_branch_and_tree('.')
238
233
        branch = wt.branch
239
234
        branch.repository.store_revision_signature(
240
 
            bzrlib.gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
 
235
            gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
241
236
        self.assertRaises(errors.NoSuchRevision,
242
237
                          branch.repository.has_signature_for_revision_id,
243
238
                          'A')
249
244
        wt = self.make_branch_and_tree('source')
250
245
        wt.commit('A', allow_pointless=True, rev_id='A')
251
246
        wt.branch.repository.sign_revision('A',
252
 
            bzrlib.gpg.LoopbackGPGStrategy(None))
 
247
            gpg.LoopbackGPGStrategy(None))
253
248
        #FIXME: clone should work to urls,
254
249
        # wt.clone should work to disks.
255
250
        self.build_tree(['target/'])
307
302
            return
308
303
        self.assertEqual(repo.bzrdir.root_transport.base,
309
304
                         child_branch.repository.bzrdir.root_transport.base)
310
 
        child_branch = bzrlib.branch.Branch.open(self.get_url('child'))
 
305
        child_branch = branch.Branch.open(self.get_url('child'))
311
306
        self.assertEqual(repo.bzrdir.root_transport.base,
312
307
                         child_branch.repository.bzrdir.root_transport.base)
313
308
 
326
321
 
327
322
    def test_get_commit_builder(self):
328
323
        self.assertIsInstance(self.make_branch(".").get_commit_builder([]), 
329
 
            bzrlib.repository.CommitBuilder)
 
324
            repository.CommitBuilder)
330
325
 
331
326
 
332
327
class ChrootedTests(TestCaseWithBranch):
353
348
        branch, relpath = Branch.open_containing(self.get_readonly_url('g/p/q'))
354
349
        self.assertEqual('g/p/q', relpath)
355
350
        
356
 
# TODO: rewrite this as a regular unittest, without relying on the displayed output        
357
 
#         >>> from bzrlib.commit import commit
358
 
#         >>> bzrlib.trace.silent = True
359
 
#         >>> br1 = ScratchBranch(files=['foo', 'bar'])
360
 
#         >>> br1.working_tree().add('foo')
361
 
#         >>> br1.working_tree().add('bar')
362
 
#         >>> commit(br1, "lala!", rev_id="REVISION-ID-1", verbose=False)
363
 
#         >>> br2 = ScratchBranch()
364
 
#         >>> br2.update_revisions(br1)
365
 
#         Added 2 texts.
366
 
#         Added 1 inventories.
367
 
#         Added 1 revisions.
368
 
#         >>> br2.revision_history()
369
 
#         [u'REVISION-ID-1']
370
 
#         >>> br2.update_revisions(br1)
371
 
#         Added 0 revisions.
372
 
#         >>> br1.text_store.total_size() == br2.text_store.total_size()
373
 
#         True
374
351
 
375
352
class InstrumentedTransaction(object):
376
353
 
527
504
        t = get_transport(self.get_url())
528
505
        readonly_t = get_transport(self.get_readonly_url())
529
506
        made_branch = self.make_branch('.')
530
 
        self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
 
507
        self.failUnless(isinstance(made_branch, branch.Branch))
531
508
 
532
509
        # find it via bzrdir opening:
533
510
        opened_control = bzrdir.BzrDir.open(readonly_t.base)
538
515
                        self.branch_format.__class__))
539
516
 
540
517
        # find it via Branch.open
541
 
        opened_branch = bzrlib.branch.Branch.open(readonly_t.base)
 
518
        opened_branch = branch.Branch.open(readonly_t.base)
542
519
        self.failUnless(isinstance(opened_branch, made_branch.__class__))
543
520
        self.assertEqual(made_branch._format.__class__,
544
521
                         opened_branch._format.__class__)
548
525
        except NotImplementedError:
549
526
            return
550
527
        self.assertEqual(self.branch_format,
551
 
                         bzrlib.branch.BranchFormat.find_format(opened_control))
 
528
                         branch.BranchFormat.find_format(opened_control))