/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/test_branchbuilder.py

  • Committer: John Arbash Meinel
  • Date: 2008-10-08 21:56:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3773.
  • Revision ID: john@arbash-meinel.com-20081008215612-y9v94tqxreqoangx
Simplify the --raw mode.

I didn't realize, but the only node that is special cased is the 'root' node,
and to read it, you actually have to parse it directly, because the
compressed bytes start immediately after the end of the header, rather than
having any padding before the zlib bytes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009 Canonical Ltd
 
1
# Copyright (C) 2007 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Tests for the BranchBuilder class."""
18
18
 
26
26
 
27
27
 
28
28
class TestBranchBuilder(tests.TestCaseWithMemoryTransport):
29
 
 
 
29
    
30
30
    def test_create(self):
31
31
        """Test the constructor api."""
32
32
        builder = BranchBuilder(self.get_transport().clone('foo'))
59
59
            'commit 1',
60
60
            branch.repository.get_revision(branch.last_revision()).message)
61
61
 
62
 
    def test_build_commit_timestamp(self):
63
 
        """You can set a date when committing."""
64
 
        builder = self.make_branch_builder('foo')
65
 
        rev_id = builder.build_commit(timestamp=1236043340)
66
 
        branch = builder.get_branch()
67
 
        self.assertEqual((1, rev_id), branch.last_revision_info())
68
 
        rev = branch.repository.get_revision(branch.last_revision())
69
 
        self.assertEqual(
70
 
            'commit 1',
71
 
            rev.message)
72
 
        self.assertEqual(
73
 
            1236043340,
74
 
            int(rev.timestamp))
75
 
 
76
62
    def test_build_two_commits(self):
77
63
        """The second commit has the right parents and message."""
78
64
        builder = BranchBuilder(self.get_transport().clone('foo'))
144
130
                              (u'b', 'b-id', 'directory'),
145
131
                             ], rev_tree)
146
132
 
147
 
    def test_commit_timestamp(self):
148
 
        builder = self.make_branch_builder('foo')
149
 
        rev_id = builder.build_snapshot(None, None,
150
 
            [('add', (u'', None, 'directory', None))],
151
 
            timestamp=1234567890)
152
 
        rev = builder.get_branch().repository.get_revision(rev_id)
153
 
        self.assertEqual(
154
 
            1234567890,
155
 
            int(rev.timestamp))
156
 
 
157
133
    def test_commit_message_default(self):
158
134
        builder = BranchBuilder(self.get_transport().clone('foo'))
159
135
        rev_id = builder.build_snapshot(None, None,
171
147
        rev = branch.repository.get_revision(rev_id)
172
148
        self.assertEqual(u'Foo', rev.message)
173
149
 
174
 
    def test_commit_message_callback(self):
175
 
        builder = BranchBuilder(self.get_transport().clone('foo'))
176
 
        rev_id = builder.build_snapshot(None, None,
177
 
            [('add', (u'', None, 'directory', None))],
178
 
            message_callback=lambda x:u'Foo')
179
 
        branch = builder.get_branch()
180
 
        rev = branch.repository.get_revision(rev_id)
181
 
        self.assertEqual(u'Foo', rev.message)
182
 
 
183
150
    def test_modify_file(self):
184
151
        builder = self.build_a_rev()
185
152
        rev_id2 = builder.build_snapshot('B-id', None,
254
221
        self.addCleanup(builder.finish_series)
255
222
        builder.build_snapshot('B-id', ['A-id'],
256
223
            [('modify', ('a-id', 'new\ncontent\n'))])
257
 
        builder.build_snapshot('C-id', ['A-id'],
 
224
        builder.build_snapshot('C-id', ['A-id'], 
258
225
            [('add', ('c', 'c-id', 'file', 'alt\ncontent\n'))])
259
226
        # We should now have a graph:
260
227
        #   A
335
302
            builder.finish_series()
336
303
        self.assertIs(None, builder._tree)
337
304
        self.assertFalse(builder._branch.is_locked())
338
 
 
339
 
    def test_ghost_mainline_history(self):
340
 
        builder = BranchBuilder(self.get_transport().clone('foo'))
341
 
        builder.start_series()
342
 
        try:
343
 
            builder.build_snapshot('tip', ['ghost'],
344
 
                [('add', ('', 'ROOT_ID', 'directory', ''))],
345
 
                allow_leftmost_as_ghost=True)
346
 
        finally:
347
 
            builder.finish_series()
348
 
        b = builder.get_branch()
349
 
        b.lock_read()
350
 
        self.addCleanup(b.unlock)
351
 
        self.assertEqual(('ghost',),
352
 
            b.repository.get_graph().get_parent_map(['tip'])['tip'])