bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
2466.7.3
by Robert Collins
 Create bzrlib.branchbuilder.  | 
1  | 
# Copyright (C) 2007 Canonical Ltd
 | 
2  | 
#
 | 
|
3  | 
# This program is free software; you can redistribute it and/or modify
 | 
|
4  | 
# it under the terms of the GNU General Public License as published by
 | 
|
5  | 
# the Free Software Foundation; either version 2 of the License, or
 | 
|
6  | 
# (at your option) any later version.
 | 
|
7  | 
#
 | 
|
8  | 
# This program is distributed in the hope that it will be useful,
 | 
|
9  | 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|
10  | 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|
11  | 
# GNU General Public License for more details.
 | 
|
12  | 
#
 | 
|
13  | 
# You should have received a copy of the GNU General Public License
 | 
|
14  | 
# along with this program; if not, write to the Free Software
 | 
|
15  | 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|
16  | 
||
17  | 
"""Tests for the BranchBuilder class."""
 | 
|
18  | 
||
| 
2466.7.4
by Robert Collins
 Add BranchBuilder.get_branch().  | 
19  | 
from bzrlib import (  | 
20  | 
branch as _mod_branch,  | 
|
21  | 
revision as _mod_revision,  | 
|
22  | 
tests,  | 
|
23  | 
    )
 | 
|
| 
2466.7.3
by Robert Collins
 Create bzrlib.branchbuilder.  | 
24  | 
from bzrlib.branchbuilder import BranchBuilder  | 
25  | 
||
26  | 
||
27  | 
class TestBranchBuilder(tests.TestCaseWithMemoryTransport):  | 
|
28  | 
||
29  | 
def test_create(self):  | 
|
30  | 
"""Test the constructor api."""  | 
|
31  | 
builder = BranchBuilder(self.get_transport().clone('foo'))  | 
|
32  | 
        # we dont care if the branch has been built or not at this point.
 | 
|
| 
2466.7.4
by Robert Collins
 Add BranchBuilder.get_branch().  | 
33  | 
|
34  | 
def test_get_branch(self):  | 
|
35  | 
"""get_branch returns the created branch."""  | 
|
36  | 
builder = BranchBuilder(self.get_transport().clone('foo'))  | 
|
37  | 
branch = builder.get_branch()  | 
|
38  | 
self.assertIsInstance(branch, _mod_branch.Branch)  | 
|
39  | 
self.assertEqual(self.get_transport().clone('foo').base,  | 
|
40  | 
branch.base)  | 
|
41  | 
self.assertEqual(  | 
|
42  | 
(0, _mod_revision.NULL_REVISION),  | 
|
43  | 
branch.last_revision_info())  | 
|
| 
2466.7.6
by Robert Collins
 Add BranchBuilder.build_commit.  | 
44  | 
|
| 
2466.7.10
by Robert Collins
 Add a format parameter to BranchBuilder.  | 
45  | 
def test_format(self):  | 
46  | 
"""Making a BranchBuilder with a format option sets the branch type."""  | 
|
47  | 
builder = BranchBuilder(self.get_transport(), format='dirstate-tags')  | 
|
48  | 
branch = builder.get_branch()  | 
|
49  | 
self.assertIsInstance(branch, _mod_branch.BzrBranch6)  | 
|
50  | 
||
| 
2466.7.6
by Robert Collins
 Add BranchBuilder.build_commit.  | 
51  | 
def test_build_one_commit(self):  | 
52  | 
"""doing build_commit causes a commit to happen."""  | 
|
53  | 
builder = BranchBuilder(self.get_transport().clone('foo'))  | 
|
| 
2466.7.9
by Robert Collins
 Return the commited revision id from BranchBuilder.build_commit to save later instrospection.  | 
54  | 
rev_id = builder.build_commit()  | 
| 
2466.7.6
by Robert Collins
 Add BranchBuilder.build_commit.  | 
55  | 
branch = builder.get_branch()  | 
| 
2466.7.9
by Robert Collins
 Return the commited revision id from BranchBuilder.build_commit to save later instrospection.  | 
56  | 
self.assertEqual((1, rev_id), branch.last_revision_info())  | 
| 
2466.7.6
by Robert Collins
 Add BranchBuilder.build_commit.  | 
57  | 
self.assertEqual(  | 
58  | 
'commit 1',  | 
|
59  | 
branch.repository.get_revision(branch.last_revision()).message)  | 
|
60  | 
||
61  | 
def test_build_two_commits(self):  | 
|
62  | 
"""The second commit has the right parents and message."""  | 
|
63  | 
builder = BranchBuilder(self.get_transport().clone('foo'))  | 
|
| 
2466.7.9
by Robert Collins
 Return the commited revision id from BranchBuilder.build_commit to save later instrospection.  | 
64  | 
rev_id1 = builder.build_commit()  | 
65  | 
rev_id2 = builder.build_commit()  | 
|
| 
2466.7.6
by Robert Collins
 Add BranchBuilder.build_commit.  | 
66  | 
branch = builder.get_branch()  | 
| 
2466.7.9
by Robert Collins
 Return the commited revision id from BranchBuilder.build_commit to save later instrospection.  | 
67  | 
self.assertEqual((2, rev_id2), branch.last_revision_info())  | 
| 
2466.7.6
by Robert Collins
 Add BranchBuilder.build_commit.  | 
68  | 
self.assertEqual(  | 
69  | 
'commit 2',  | 
|
70  | 
branch.repository.get_revision(branch.last_revision()).message)  | 
|
71  | 
self.assertEqual(  | 
|
| 
2466.7.9
by Robert Collins
 Return the commited revision id from BranchBuilder.build_commit to save later instrospection.  | 
72  | 
[rev_id1],  | 
| 
2466.7.6
by Robert Collins
 Add BranchBuilder.build_commit.  | 
73  | 
branch.repository.get_revision(branch.last_revision()).parent_ids)  |