/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: John Arbash Meinel
  • Date: 2008-07-08 14:55:19 UTC
  • mfrom: (3530 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3532.
  • Revision ID: john@arbash-meinel.com-20080708145519-paqg4kjwbpgs2xmq
Merge bzr.dev 3530

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 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
40
40
                           )
41
41
from bzrlib.osutils import getcwd
42
42
import bzrlib.revision
 
43
from bzrlib.symbol_versioning import deprecated_in
43
44
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
44
45
from bzrlib.tests.branch_implementations import TestCaseWithBranch
45
46
from bzrlib.tests.http_server import HttpServer
48
49
from bzrlib.transport.memory import MemoryServer
49
50
from bzrlib.upgrade import upgrade
50
51
from bzrlib.workingtree import WorkingTree
51
 
from bzrlib.symbol_versioning import (
52
 
    zero_ninetyone,
53
 
    )
54
52
 
55
53
 
56
54
class TestBranch(TestCaseWithBranch):
57
55
 
58
56
    def test_create_tree_with_merge(self):
59
57
        tree = self.create_tree_with_merge()
60
 
        ancestry_graph = tree.branch.repository.get_revision_graph('rev-3')
61
 
        self.assertEqual({'rev-1':(),
 
58
        tree.lock_read()
 
59
        self.addCleanup(tree.unlock)
 
60
        graph = tree.branch.repository.get_graph()
 
61
        ancestry_graph = graph.get_parent_map(
 
62
            tree.branch.repository.all_revision_ids())
 
63
        self.assertEqual({'rev-1':('null:',),
62
64
                          'rev-2':('rev-1', ),
63
65
                          'rev-1.1.1':('rev-1', ),
64
66
                          'rev-3':('rev-2', 'rev-1.1.1', ),
164
166
        wt_a.add(['one'])
165
167
        wt_a.commit('commit one', rev_id='1')
166
168
 
167
 
        branch_b = wt_a.bzrdir.sprout('b', revision_id='1').open_branch()
 
169
        branch_b = wt_a.branch.bzrdir.sprout('b', revision_id='1').open_branch()
168
170
        self.assertEqual(wt_a.branch.base, branch_b.get_parent())
169
171
        return branch_b
170
172
 
280
282
                branch.repository.commit_write_group()
281
283
        finally:
282
284
            branch.unlock()
 
285
        # A signature without a revision should not be accessible.
283
286
        self.assertRaises(errors.NoSuchRevision,
284
287
                          branch.repository.has_signature_for_revision_id,
285
288
                          'A')
304
307
        self.assertEqual(repo.get_signature_text('A'),
305
308
                         d2.open_repository().get_signature_text('A'))
306
309
 
 
310
    def test_missing_revisions(self):
 
311
        t1 = self.make_branch_and_tree('b1')
 
312
        rev1 = t1.commit('one')
 
313
        t2 = t1.bzrdir.sprout('b2').open_workingtree()
 
314
        rev2 = t1.commit('two')
 
315
        rev3 = t1.commit('three')
 
316
 
 
317
        self.assertEqual([rev2, rev3],
 
318
            self.applyDeprecated(deprecated_in((1, 6, 0)),
 
319
            t2.branch.missing_revisions, t1.branch))
 
320
 
 
321
        self.assertEqual([],
 
322
            self.applyDeprecated(deprecated_in((1, 6, 0)),
 
323
            t2.branch.missing_revisions, t1.branch, stop_revision=1))
 
324
        self.assertEqual([rev2],
 
325
            self.applyDeprecated(deprecated_in((1, 6, 0)),
 
326
            t2.branch.missing_revisions, t1.branch, stop_revision=2))
 
327
        self.assertEqual([rev2, rev3],
 
328
            self.applyDeprecated(deprecated_in((1, 6, 0)),
 
329
            t2.branch.missing_revisions, t1.branch, stop_revision=3))
 
330
 
 
331
        self.assertRaises(errors.NoSuchRevision,
 
332
            self.applyDeprecated, deprecated_in((1, 6, 0)),
 
333
            t2.branch.missing_revisions, t1.branch, stop_revision=4)
 
334
 
 
335
        rev4 = t2.commit('four')
 
336
        self.assertRaises(errors.DivergedBranches,
 
337
            self.applyDeprecated, deprecated_in((1, 6, 0)),
 
338
            t2.branch.missing_revisions, t1.branch)
 
339
 
307
340
    def test_nicks(self):
308
341
        """Test explicit and implicit branch nicknames.
309
342
        
323
356
        # Set the branch nick explicitly.  This will ensure there's a branch
324
357
        # config file in the branch.
325
358
        branch.nick = "Aaron's branch"
326
 
        branch.nick = "Aaron's branch"
327
359
        if not isinstance(branch, remote.RemoteBranch):
328
 
            controlfilename = branch.control_files.controlfilename
329
 
            self.failUnless(t.has(t.relpath(controlfilename("branch.conf"))))
 
360
            self.failUnless(branch._transport.has("branch.conf"))
330
361
        # Because the nick has been set explicitly, the nick is now always
331
362
        # "Aaron's branch", regardless of directory name.
332
363
        self.assertEqual(branch.nick, "Aaron's branch")
370
401
        text = tree.branch._format.get_format_description()
371
402
        self.failUnless(len(text))
372
403
 
373
 
    def test_check_branch_report_results(self):
374
 
        """Checking a branch produces results which can be printed"""
375
 
        branch = self.make_branch('.')
376
 
        result = branch.check()
377
 
        # reports results through logging
378
 
        result.report_results(verbose=True)
379
 
        result.report_results(verbose=False)
380
 
 
381
404
    def test_get_commit_builder(self):
382
405
        branch = self.make_branch(".")
383
406
        branch.lock_write()