~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-19 21:32:28 UTC
  • mto: This revision was merged to the branch mainline in revision 4522.
  • Revision ID: john@arbash-meinel.com-20090619213228-x8xnqb51x12asa0z
Use BranchBuilder for duplicate_lines_tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
        return builder
239
239
 
240
240
    def create_duplicate_lines_tree(self):
241
 
        tree1 = self.make_branch_and_tree('tree1')
 
241
        builder = self.make_branch_builder('branch')
 
242
        builder.start_series()
 
243
        self.addCleanup(builder.finish_series)
242
244
        base_text = ''.join(l for r, l in duplicate_base)
243
245
        a_text = ''.join(l for r, l in duplicate_A)
244
246
        b_text = ''.join(l for r, l in duplicate_B)
245
247
        c_text = ''.join(l for r, l in duplicate_C)
246
248
        d_text = ''.join(l for r, l in duplicate_D)
247
249
        e_text = ''.join(l for r, l in duplicate_E)
248
 
        self.build_tree_contents([('tree1/file', base_text)])
249
 
        tree1.add(['file'], ['file-id'])
250
 
        tree1.commit('base', rev_id='rev-base')
251
 
        tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
252
 
 
253
 
        self.build_tree_contents([('tree1/file', a_text),
254
 
                                  ('tree2/file', b_text)])
255
 
        tree1.commit('A', rev_id='rev-A')
256
 
        tree2.commit('B', rev_id='rev-B')
257
 
 
258
 
        tree2.merge_from_branch(tree1.branch)
259
 
        conflicts.resolve(tree2, None) # Resolve the conflicts
260
 
        self.build_tree_contents([('tree2/file', d_text)])
261
 
        tree2.commit('D', rev_id='rev-D')
262
 
 
263
 
        self.build_tree_contents([('tree1/file', c_text)])
264
 
        tree1.commit('C', rev_id='rev-C')
265
 
 
266
 
        tree1.merge_from_branch(tree2.branch)
267
 
        conflicts.resolve(tree1, None) # Resolve the conflicts
268
 
        self.build_tree_contents([('tree1/file', e_text)])
269
 
        tree1.commit('E', rev_id='rev-E')
270
 
        return tree1
 
250
        builder.build_snapshot('rev-base', None, [
 
251
            ('add', ('', 'root-id', 'directory', None)),
 
252
            ('add', ('file', 'file-id', 'file', base_text)),
 
253
            ])
 
254
        builder.build_snapshot('rev-A', ['rev-base'], [
 
255
            ('modify', ('file-id', a_text))])
 
256
        builder.build_snapshot('rev-B', ['rev-base'], [
 
257
            ('modify', ('file-id', b_text))])
 
258
        builder.build_snapshot('rev-C', ['rev-A'], [
 
259
            ('modify', ('file-id', c_text))])
 
260
        builder.build_snapshot('rev-D', ['rev-B', 'rev-A'], [
 
261
            ('modify', ('file-id', d_text))])
 
262
        builder.build_snapshot('rev-E', ['rev-C', 'rev-D'], [
 
263
            ('modify', ('file-id', e_text))])
 
264
        return builder
271
265
 
272
266
    def assertRepoAnnotate(self, expected, repo, file_id, revision_id):
273
267
        """Assert that the revision is properly annotated."""
280
274
 
281
275
    def test_annotate_duplicate_lines(self):
282
276
        # XXX: Should this be a per_repository test?
283
 
        tree1 = self.create_duplicate_lines_tree()
284
 
        repo = tree1.branch.repository
 
277
        builder = self.create_duplicate_lines_tree()
 
278
        repo = builder.get_branch().repository
285
279
        repo.lock_read()
286
280
        self.addCleanup(repo.unlock)
287
281
        self.assertRepoAnnotate(duplicate_base, repo, 'file-id', 'rev-base')