1
from bzrlib import revision, transform
2
from bzrlib.tests import TestCaseWithTransport
4
from bzrlib.plugins.bzrtools.mirror import create_mirror
6
class TestMirror(TestCaseWithTransport):
8
def commit_transform(self, branch, tt):
9
base_revno, base_revision = branch.last_revision_info()
10
if base_revision == revision.NULL_REVISION:
13
parents = [base_revision]
14
preview = tt.get_preview_tree()
15
preview.set_parent_ids(parents)
16
changes = tt.iter_changes()
17
builder = branch.get_commit_builder(parents)
19
list(builder.record_iter_changes(preview, base_revision, changes))
20
builder.finish_inventory()
21
revision_id = builder.commit('message')
25
branch.set_last_revision_info(base_revno + 1, revision_id)
27
def make_transform(self, branch):
28
base = branch.basis_tree()
29
tt = transform.TransformPreview(base)
30
self.addCleanup(tt.finalize)
31
root = tt.new_directory('', transform.ROOT_PARENT, 'root-id')
35
def test_create_mirror(self):
36
source = self.make_branch('source')
38
self.addCleanup(source.unlock)
39
source.nick = 'my special nick'
40
source.set_submit_branch(':submit:')
41
source.get_config().set_user_option('child_submit_to', 'a@b.com')
42
self.commit_transform(source, self.make_transform(source))
43
mirror = create_mirror(source, 'target', [])
44
self.assertEqual(source.last_revision(), mirror.last_revision())
45
self.assertEqual(source.base, mirror.get_public_branch())
46
self.assertEqual(source.base, mirror.get_parent())
47
self.assertEqual('my special nick', mirror.nick)
48
self.assertEqual(':submit:', mirror.get_submit_branch())
49
self.assertEqual('a@b.com', mirror.get_config().get_user_option(
52
def test_nonexplict_nick(self):
53
source = self.make_branch('source')
54
mirror = create_mirror(source, 'target', [])
55
self.assertEqual('target', mirror.nick)