~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_mirror.py

  • Committer: Benoît Pierre
  • Date: 2008-11-16 17:50:52 UTC
  • mto: This revision was merged to the branch mainline in revision 683.
  • Revision ID: benoit.pierre@gmail.com-20081116175052-8ldrpprvpfq3wscm
Check if STDOUT is a TTY in has_ansi_colors: return False if not.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from bzrlib import revision, transform
2
 
from bzrlib.tests import TestCaseWithTransport
3
 
 
4
 
from bzrlib.plugins.bzrtools.mirror import create_mirror
5
 
 
6
 
class TestMirror(TestCaseWithTransport):
7
 
 
8
 
    def commit_transform(self, branch, tt):
9
 
        base_revno, base_revision = branch.last_revision_info()
10
 
        if base_revision == revision.NULL_REVISION:
11
 
            parents = []
12
 
        else:
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)
18
 
        try:
19
 
            list(builder.record_iter_changes(preview, base_revision, changes))
20
 
            builder.finish_inventory()
21
 
            revision_id = builder.commit('message')
22
 
        except:
23
 
            builder.abort()
24
 
            raise
25
 
        branch.set_last_revision_info(base_revno + 1, revision_id)
26
 
 
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')
32
 
        tt._new_root = root
33
 
        return tt
34
 
 
35
 
    def test_create_mirror(self):
36
 
        source = self.make_branch('source')
37
 
        source.lock_write()
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(
50
 
                         'child_submit_to'))
51
 
 
52
 
    def test_nonexplict_nick(self):
53
 
        source = self.make_branch('source')
54
 
        mirror = create_mirror(source, 'target', [])
55
 
        self.assertEqual('target', mirror.nick)