~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge_directive.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-03-12 16:46:21 UTC
  • mfrom: (1551.12.52 mergedirective)
  • Revision ID: pqm@pqm.ubuntu.com-20070312164621-d96558dc43d9c1b6
Small tweaks for merge directives

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
booga"""
44
44
 
45
45
 
 
46
INPUT1 = """
 
47
I was thinking today about creating a merge directive.
 
48
 
 
49
So I did.
 
50
 
 
51
Here it is.
 
52
 
 
53
(I've pasted it in the body of this message)
 
54
 
 
55
Aaron
 
56
 
 
57
# Bazaar merge directive format 1\r
 
58
# revision_id: example:
 
59
# target_branch: http://example.com
 
60
# testament_sha1: sha
 
61
# timestamp: 1970-01-01 00:09:33 +0002
 
62
# source_branch: http://example.org
 
63
# message: Hi mom!
 
64
#\x20
 
65
booga""".splitlines(True)
 
66
 
 
67
 
46
68
class TestMergeDirective(tests.TestCase):
47
69
 
48
70
    def test_merge_source(self):
85
107
            patch='booga', patch_type='diff', message="Hi mom!")
86
108
        self.assertEqualDiff(OUTPUT2, ''.join(md.to_lines()))
87
109
 
 
110
    def test_deserialize_junk(self):
 
111
        self.assertRaises(errors.NotAMergeDirective,
 
112
                          merge_directive.MergeDirective.from_lines, 'lala')
 
113
 
 
114
    def test_deserialize_leading_junk(self):
 
115
        md = merge_directive.MergeDirective.from_lines(INPUT1)
 
116
        self.assertEqual('example:', md.revision_id)
 
117
        self.assertEqual('sha', md.testament_sha1)
 
118
        self.assertEqual('http://example.com', md.target_branch)
 
119
        self.assertEqual('http://example.org', md.source_branch)
 
120
        self.assertEqual(501, md.time)
 
121
        self.assertEqual(72, md.timezone)
 
122
        self.assertEqual('booga', md.patch)
 
123
        self.assertEqual('diff', md.patch_type)
 
124
        self.assertEqual('Hi mom!', md.message)
 
125
 
88
126
    def test_roundtrip(self):
89
127
        time = 501
90
128
        timezone = 72
183
221
            tree_a.branch.repository, 'rev2a', 500, 144, tree_b.branch.base,
184
222
            patch_type=None, public_branch=branch_c.base)
185
223
 
 
224
    def test_use_public_submit_branch(self):
 
225
        tree_a, tree_b, branch_c = self.make_trees()
 
226
        branch_c.pull(tree_a.branch)
 
227
        md = merge_directive.MergeDirective.from_objects(
 
228
             tree_a.branch.repository, 'rev2a', 500, 144, tree_b.branch.base,
 
229
             patch_type=None, public_branch=branch_c.base)
 
230
        self.assertEqual(md.target_branch, tree_b.branch.base)
 
231
        tree_b.branch.set_public_branch('http://example.com')
 
232
        md2 = merge_directive.MergeDirective.from_objects(
 
233
              tree_a.branch.repository, 'rev2a', 500, 144, tree_b.branch.base,
 
234
              patch_type=None, public_branch=branch_c.base)
 
235
        self.assertEqual(md2.target_branch, 'http://example.com')
 
236
 
186
237
    def test_message(self):
187
238
        tree_a, tree_b, branch_c = self.make_trees()
188
239
        md3 = merge_directive.MergeDirective.from_objects(