~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008 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
19
19
 
20
20
import bzrlib
21
21
from bzrlib import (
 
22
    bzrdir,
22
23
    errors,
23
24
    lockdir,
24
25
    osutils,
30
31
from bzrlib.config import BranchConfig
31
32
from bzrlib.errors import (PointlessCommit, BzrError, SigningFailed, 
32
33
                           LockContention)
33
 
from bzrlib.tests import TestCaseWithTransport
 
34
from bzrlib.tests import SymlinkFeature, TestCaseWithTransport
34
35
from bzrlib.workingtree import WorkingTree
35
36
 
36
37
 
95
96
        eq(rev.message, 'add hello')
96
97
 
97
98
        tree1 = b.repository.revision_tree(rh[0])
 
99
        tree1.lock_read()
98
100
        text = tree1.get_file_text(file_id)
99
 
        eq(text, 'hello world')
 
101
        tree1.unlock()
 
102
        self.assertEqual('hello world', text)
100
103
 
101
104
        tree2 = b.repository.revision_tree(rh[1])
102
 
        eq(tree2.get_file_text(file_id), 'version 2')
 
105
        tree2.lock_read()
 
106
        text = tree2.get_file_text(file_id)
 
107
        tree2.unlock()
 
108
        self.assertEqual('version 2', text)
103
109
 
104
110
    def test_delete_commit(self):
105
111
        """Test a commit with a deleted file"""
168
174
        eq(b.revno(), 3)
169
175
 
170
176
        tree2 = b.repository.revision_tree('test@rev-2')
 
177
        tree2.lock_read()
 
178
        self.addCleanup(tree2.unlock)
171
179
        self.assertTrue(tree2.has_filename('hello'))
172
180
        self.assertEquals(tree2.get_file_text('hello-id'), 'hello')
173
181
        self.assertEquals(tree2.get_file_text('buongia-id'), 'new text')
174
182
        
175
183
        tree3 = b.repository.revision_tree('test@rev-3')
 
184
        tree3.lock_read()
 
185
        self.addCleanup(tree3.unlock)
176
186
        self.assertFalse(tree3.has_filename('hello'))
177
187
        self.assertEquals(tree3.get_file_text('buongia-id'), 'new text')
178
188
 
189
199
 
190
200
        eq = self.assertEquals
191
201
        tree1 = b.repository.revision_tree('test@rev-1')
 
202
        tree1.lock_read()
 
203
        self.addCleanup(tree1.unlock)
192
204
        eq(tree1.id2path('hello-id'), 'hello')
193
205
        eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
194
206
        self.assertFalse(tree1.has_filename('fruity'))
197
209
        eq(ie.revision, 'test@rev-1')
198
210
 
199
211
        tree2 = b.repository.revision_tree('test@rev-2')
 
212
        tree2.lock_read()
 
213
        self.addCleanup(tree2.unlock)
200
214
        eq(tree2.id2path('hello-id'), 'fruity')
201
215
        eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
202
216
        self.check_inventory_shape(tree2.inventory, ['fruity'])
430
444
        bound = master.sprout('bound')
431
445
        wt = bound.open_workingtree()
432
446
        wt.branch.set_bound_location(os.path.realpath('master'))
433
 
 
434
 
        orig_default = lockdir._DEFAULT_TIMEOUT_SECONDS
435
447
        master_branch.lock_write()
436
448
        try:
437
 
            lockdir._DEFAULT_TIMEOUT_SECONDS = 1
438
449
            self.assertRaises(LockContention, wt.commit, 'silly')
439
450
        finally:
440
 
            lockdir._DEFAULT_TIMEOUT_SECONDS = orig_default
441
451
            master_branch.unlock()
442
452
 
443
453
    def test_commit_bound_merge(self):
584
594
            basis.unlock()
585
595
 
586
596
    def test_commit_kind_changes(self):
587
 
        if not osutils.has_symlinks():
588
 
            raise tests.TestSkipped('Test requires symlink support')
 
597
        self.requireFeature(SymlinkFeature)
589
598
        tree = self.make_branch_and_tree('.')
590
599
        os.symlink('target', 'name')
591
600
        tree.add('name', 'a-file-id')
728
737
        rev = tree.branch.repository.get_revision(rev_id)
729
738
        self.assertEqual('John Doe <jdoe@example.com>',
730
739
                         rev.properties['author'])
 
740
 
 
741
    def test_commit_with_checkout_and_branch_sharing_repo(self):
 
742
        repo = self.make_repository('repo', shared=True)
 
743
        # make_branch_and_tree ignores shared repos
 
744
        branch = bzrdir.BzrDir.create_branch_convenience('repo/branch')
 
745
        tree2 = branch.create_checkout('repo/tree2')
 
746
        tree2.commit('message', rev_id='rev1')
 
747
        self.assertTrue(tree2.branch.repository.has_revision('rev1'))