~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

  • Committer: Vincent Ladeuil
  • Date: 2011-06-15 11:36:05 UTC
  • mto: This revision was merged to the branch mainline in revision 5975.
  • Revision ID: v.ladeuil+lp@free.fr-20110615113605-p7zyyfry9wy1hquc
Make ContentConflict resolution more robust

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.bzrdir import BzrDirMetaFormat1
27
27
from bzrlib.commit import Commit, NullCommitReporter
28
28
from bzrlib.config import BranchConfig
29
 
from bzrlib.errors import (
30
 
    PointlessCommit,
31
 
    BzrError,
32
 
    SigningFailed,
33
 
    LockContention,
34
 
    )
 
29
from bzrlib.errors import (PointlessCommit, BzrError, SigningFailed,
 
30
                           LockContention)
35
31
from bzrlib.tests import (
 
32
    SymlinkFeature,
36
33
    TestCaseWithTransport,
37
34
    test_foreign,
38
35
    )
39
 
from bzrlib.tests.features import (
40
 
    SymlinkFeature,
41
 
    )
42
 
from bzrlib.tests.matchers import MatchesAncestry
43
36
 
44
37
 
45
38
# TODO: Test commit with some added, and added-but-missing files
90
83
        b = wt.branch
91
84
        file('hello', 'w').write('hello world')
92
85
        wt.add('hello')
93
 
        rev1 = wt.commit(message='add hello')
 
86
        wt.commit(message='add hello')
94
87
        file_id = wt.path2id('hello')
95
88
 
96
89
        file('hello', 'w').write('version 2')
97
 
        rev2 = wt.commit(message='commit 2')
 
90
        wt.commit(message='commit 2')
98
91
 
99
92
        eq = self.assertEquals
100
93
        eq(b.revno(), 2)
101
 
        rev = b.repository.get_revision(rev1)
 
94
        rh = b.revision_history()
 
95
        rev = b.repository.get_revision(rh[0])
102
96
        eq(rev.message, 'add hello')
103
97
 
104
 
        tree1 = b.repository.revision_tree(rev1)
 
98
        tree1 = b.repository.revision_tree(rh[0])
105
99
        tree1.lock_read()
106
100
        text = tree1.get_file_text(file_id)
107
101
        tree1.unlock()
108
102
        self.assertEqual('hello world', text)
109
103
 
110
 
        tree2 = b.repository.revision_tree(rev2)
 
104
        tree2 = b.repository.revision_tree(rh[1])
111
105
        tree2.lock_read()
112
106
        text = tree2.get_file_text(file_id)
113
107
        tree2.unlock()
160
154
        wt.commit(message='add hello')
161
155
 
162
156
        os.remove('hello')
163
 
        reporter = CapturingReporter()
164
 
        wt.commit('removed hello', rev_id='rev2', reporter=reporter)
165
 
        self.assertEquals(
166
 
            [('missing', u'hello'), ('deleted', u'hello')],
167
 
            reporter.calls)
 
157
        wt.commit('removed hello', rev_id='rev2')
168
158
 
169
159
        tree = b.repository.revision_tree('rev2')
170
160
        self.assertFalse(tree.has_id('hello-id'))
364
354
            rev_ids.append(rev_id)
365
355
            wt.commit(message='rev %d' % (i+1),
366
356
                     rev_id=rev_id)
 
357
        eq = self.assertEquals
 
358
        eq(b.revision_history(), rev_ids)
367
359
        for i in range(4):
368
 
            self.assertThat(rev_ids[:i+1],
369
 
                MatchesAncestry(b.repository, rev_ids[i]))
 
360
            anc = b.repository.get_ancestry(rev_ids[i])
 
361
            eq(anc, [None] + rev_ids[:i+1])
370
362
 
371
363
    def test_commit_new_subdir_child_selective(self):
372
364
        wt = self.make_branch_and_tree('.')
462
454
                              rev_id='B',
463
455
                              working_tree=wt)
464
456
            branch = Branch.open(self.get_url('.'))
465
 
            self.assertEqual(branch.last_revision(), 'A')
 
457
            self.assertEqual(branch.revision_history(), ['A'])
466
458
            self.assertFalse(branch.repository.has_revision('B'))
467
459
        finally:
468
460
            bzrlib.gpg.GPGStrategy = oldstrategy