~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branchbuilder.py

  • Committer: Vincent Ladeuil
  • Date: 2010-02-10 15:46:03 UTC
  • mfrom: (4985.3.21 update)
  • mto: This revision was merged to the branch mainline in revision 5021.
  • Revision ID: v.ladeuil+lp@free.fr-20100210154603-k4no1gvfuqpzrw7p
Update performs two merges in a more logical order but stop on conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007, 2009 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
 
62
76
    def test_build_two_commits(self):
63
77
        """The second commit has the right parents and message."""
64
78
        builder = BranchBuilder(self.get_transport().clone('foo'))
130
144
                              (u'b', 'b-id', 'directory'),
131
145
                             ], rev_tree)
132
146
 
 
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
 
133
157
    def test_commit_message_default(self):
134
158
        builder = BranchBuilder(self.get_transport().clone('foo'))
135
159
        rev_id = builder.build_snapshot(None, None,
221
245
        self.addCleanup(builder.finish_series)
222
246
        builder.build_snapshot('B-id', ['A-id'],
223
247
            [('modify', ('a-id', 'new\ncontent\n'))])
224
 
        builder.build_snapshot('C-id', ['A-id'], 
 
248
        builder.build_snapshot('C-id', ['A-id'],
225
249
            [('add', ('c', 'c-id', 'file', 'alt\ncontent\n'))])
226
250
        # We should now have a graph:
227
251
        #   A
302
326
            builder.finish_series()
303
327
        self.assertIs(None, builder._tree)
304
328
        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'])