~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testbranch.py

[merge] much integrated work from robert and john

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        b2 = Branch.initialize('b2')
52
52
        file(os.sep.join(['b1', 'foo']), 'w').write('hello')
53
53
        b1.add(['foo'], ['foo-id'])
54
 
        b1.commit('lala!', rev_id='revision-1', allow_pointless=False)
 
54
        b1.working_tree().commit('lala!', rev_id='revision-1', allow_pointless=False)
55
55
 
56
56
        mutter('start fetch')
57
57
        f = Fetcher(from_branch=b1, to_branch=b2)
65
65
 
66
66
    def test_revision_tree(self):
67
67
        b1 = Branch.initialize('.')
68
 
        b1.commit('lala!', rev_id='revision-1', allow_pointless=True)
 
68
        b1.working_tree().commit('lala!', rev_id='revision-1', allow_pointless=True)
69
69
        tree = b1.revision_tree('revision-1')
70
70
        tree = b1.revision_tree(None)
71
71
        self.assertEqual(len(tree.list_files()), 0)
117
117
        self.build_tree(['a/', 'a/one'])
118
118
        br_a = Branch.initialize('a')
119
119
        br_a.add(['one'])
120
 
        br_a.commit('commit one', rev_id='u@d-1')
 
120
        br_a.working_tree().commit('commit one', rev_id='u@d-1')
121
121
        self.build_tree(['a/two'])
122
122
        br_a.add(['two'])
123
 
        br_a.commit('commit two', rev_id='u@d-2')
 
123
        br_a.working_tree().commit('commit two', rev_id='u@d-2')
124
124
        br_b = copy_branch(br_a, 'b', revision='u@d-1')
125
125
        self.assertEqual(br_b.last_revision(), 'u@d-1')
126
126
        self.assertTrue(os.path.exists('b/one'))
129
129
    def test_record_initial_ghost_merge(self):
130
130
        """A pending merge with no revision present is still a merge."""
131
131
        branch = Branch.initialize('.')
132
 
        branch.add_pending_merge('non:existent@rev--ision--0--2')
133
 
        branch.commit('pretend to merge nonexistent-revision', rev_id='first')
 
132
        branch.working_tree().add_pending_merge('non:existent@rev--ision--0--2')
 
133
        branch.working_tree().commit('pretend to merge nonexistent-revision', rev_id='first')
134
134
        rev = branch.get_revision(branch.last_revision())
135
135
        self.assertEqual(len(rev.parent_ids), 1)
136
136
        # parent_sha1s is not populated now, WTF. rbc 20051003
149
149
    def test_pending_merges(self):
150
150
        """Tracking pending-merged revisions."""
151
151
        b = Branch.initialize('.')
152
 
 
153
 
        self.assertEquals(b.pending_merges(), [])
154
 
        b.add_pending_merge('foo@azkhazan-123123-abcabc')
155
 
        self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
156
 
        b.add_pending_merge('foo@azkhazan-123123-abcabc')
157
 
        self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
158
 
        b.add_pending_merge('wibble@fofof--20050401--1928390812')
159
 
        self.assertEquals(b.pending_merges(),
 
152
        wt = b.working_tree()
 
153
        self.assertEquals(wt.pending_merges(), [])
 
154
        wt.add_pending_merge('foo@azkhazan-123123-abcabc')
 
155
        self.assertEquals(wt.pending_merges(), ['foo@azkhazan-123123-abcabc'])
 
156
        wt.add_pending_merge('foo@azkhazan-123123-abcabc')
 
157
        self.assertEquals(wt.pending_merges(), ['foo@azkhazan-123123-abcabc'])
 
158
        wt.add_pending_merge('wibble@fofof--20050401--1928390812')
 
159
        self.assertEquals(wt.pending_merges(),
160
160
                          ['foo@azkhazan-123123-abcabc',
161
161
                           'wibble@fofof--20050401--1928390812'])
162
 
        b.commit("commit from base with two merges")
 
162
        b.working_tree().commit("commit from base with two merges")
163
163
        rev = b.get_revision(b.revision_history()[0])
164
164
        self.assertEquals(len(rev.parent_ids), 2)
165
165
        self.assertEquals(rev.parent_ids[0],
167
167
        self.assertEquals(rev.parent_ids[1],
168
168
                           'wibble@fofof--20050401--1928390812')
169
169
        # list should be cleared when we do a commit
170
 
        self.assertEquals(b.pending_merges(), [])
 
170
        self.assertEquals(wt.pending_merges(), [])
171
171
 
172
172
    def test_sign_existing_revision(self):
173
173
        branch = Branch.initialize('.')
174
 
        branch.commit("base", allow_pointless=True, rev_id='A')
 
174
        branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
175
175
        from bzrlib.testament import Testament
176
176
        branch.sign_revision('A', bzrlib.gpg.LoopbackGPGStrategy(None))
177
177
        self.assertEqual(Testament.from_revision(branch, 'A').as_short_text(),
214
214
        os.mkdir('bzr.dev')
215
215
        branch = Branch.initialize('bzr.dev')
216
216
        branch.nick = "My happy branch"
217
 
        branch.commit('My commit respect da nick.')
 
217
        branch.working_tree().commit('My commit respect da nick.')
218
218
        committed = branch.get_revision(branch.last_revision())
219
219
        self.assertEqual(committed.properties["branch-nick"], 
220
220
                         "My happy branch")