~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branchbuilder.py

  • Committer: Mark Hammond
  • Date: 2009-01-12 01:55:34 UTC
  • mto: (3995.8.2 prepare-1.12)
  • mto: This revision was merged to the branch mainline in revision 4007.
  • Revision ID: mhammond@skippinet.com.au-20090112015534-yfxg50p7mpds9j4v
Include all .html files from the tortoise doc directory.

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,
245
221
        self.addCleanup(builder.finish_series)
246
222
        builder.build_snapshot('B-id', ['A-id'],
247
223
            [('modify', ('a-id', 'new\ncontent\n'))])
248
 
        builder.build_snapshot('C-id', ['A-id'],
 
224
        builder.build_snapshot('C-id', ['A-id'], 
249
225
            [('add', ('c', 'c-id', 'file', 'alt\ncontent\n'))])
250
226
        # We should now have a graph:
251
227
        #   A
326
302
            builder.finish_series()
327
303
        self.assertIs(None, builder._tree)
328
304
        self.assertFalse(builder._branch.is_locked())
329
 
 
330
 
    def test_ghost_mainline_history(self):
331
 
        builder = BranchBuilder(self.get_transport().clone('foo'))
332
 
        builder.start_series()
333
 
        try:
334
 
            builder.build_snapshot('tip', ['ghost'],
335
 
                [('add', ('', 'ROOT_ID', 'directory', ''))],
336
 
                allow_leftmost_as_ghost=True)
337
 
        finally:
338
 
            builder.finish_series()
339
 
        b = builder.get_branch()
340
 
        b.lock_read()
341
 
        self.addCleanup(b.unlock)
342
 
        self.assertEqual(('ghost',),
343
 
            b.repository.get_graph().get_parent_map(['tip'])['tip'])