~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit_merge.py

  • Committer: wang
  • Date: 2006-10-29 13:41:32 UTC
  • mto: (2104.4.1 wang_65714)
  • mto: This revision was merged to the branch mainline in revision 2109.
  • Revision ID: wang@ubuntu-20061029134132-3d7f4216f20c4aef
Replace python's difflib by patiencediff because the worst case 
performance is cubic for difflib and people commiting large data 
files are often hurt by this. The worst case performance of patience is 
quadratic. Fix bug 65714.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006 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
34
34
    def test_merge_commit_empty(self):
35
35
        """Simple commit of two-way merge of empty trees."""
36
36
        wtx = self.make_branch_and_tree('x')
 
37
        base_rev = wtx.commit('common parent')
37
38
        bx = wtx.branch
38
 
        wty = self.make_branch_and_tree('y')
 
39
        wty = wtx.bzrdir.sprout('y').open_workingtree()
39
40
        by = wty.branch
40
 
 
 
41
        
41
42
        wtx.commit('commit one', rev_id='x@u-0-1', allow_pointless=True)
42
43
        wty.commit('commit two', rev_id='y@u-0-1', allow_pointless=True)
43
44
 
47
48
                          wty.commit,
48
49
                          'no changes yet', rev_id='y@u-0-2',
49
50
                          allow_pointless=False)
50
 
        wty.add_pending_merge('x@u-0-1')
 
51
        wty.merge_from_branch(bx)
51
52
        wty.commit('merge from x', rev_id='y@u-0-2', allow_pointless=False)
52
53
 
53
 
        self.assertEquals(by.revno(), 2)
 
54
        self.assertEquals(by.revno(), 3)
54
55
        self.assertEquals(list(by.revision_history()),
55
 
                          ['y@u-0-1', 'y@u-0-2'])
 
56
                          [base_rev, 'y@u-0-1', 'y@u-0-2'])
56
57
        rev = by.repository.get_revision('y@u-0-2')
57
58
        self.assertEquals(rev.parent_ids,
58
59
                          ['y@u-0-1', 'x@u-0-1'])
60
61
    def test_merge_new_file(self):
61
62
        """Commit merge of two trees with no overlapping files."""
62
63
        wtx = self.make_branch_and_tree('x')
 
64
        base_rev = wtx.commit('common parent')
63
65
        bx = wtx.branch
64
 
        wty = self.make_branch_and_tree('y')
 
66
        wtx.commit('establish root id')
 
67
        wty = wtx.bzrdir.sprout('y').open_workingtree()
 
68
        self.assertEqual(wtx.get_root_id(), wty.get_root_id())
65
69
        by = wty.branch
66
70
 
67
71
        self.build_tree(['x/ecks', 'y/why'])
72
76
        wtx.commit('commit one', rev_id='x@u-0-1', allow_pointless=True)
73
77
        wty.commit('commit two', rev_id='y@u-0-1', allow_pointless=True)
74
78
 
75
 
        by.fetch(bx)
76
 
        # we haven't merged the texts, but let's fake it
77
 
        shutil.copyfile('x/ecks', 'y/ecks')
78
 
        wty.add(['ecks'], ['ecks-id'])
79
 
        wty.add_pending_merge('x@u-0-1')
 
79
        wty.merge_from_branch(bx)
80
80
 
81
81
        # partial commit of merges is currently not allowed, because
82
82
        # it would give different merge graphs for each file which