1185.1.41
by Robert Collins
massive patch from Alexander Belchenko - many PEP8 fixes, removes unused function uuid |
1 |
import os |
1551.2.23
by Aaron Bentley
Got merge_inner's ignore_zero parameter working |
2 |
from StringIO import StringIO |
1185.1.41
by Robert Collins
massive patch from Alexander Belchenko - many PEP8 fixes, removes unused function uuid |
3 |
|
974.1.56
by aaron.bentley at utoronto
Added merge test |
4 |
from bzrlib.branch import Branch |
1534.4.28
by Robert Collins
first cut at merge from integration. |
5 |
from bzrlib.builtins import merge |
974.1.56
by aaron.bentley at utoronto
Added merge test |
6 |
from bzrlib.commit import commit |
1185.24.3
by Aaron Bentley
Integrated reprocessing into the rest of the merge stuff |
7 |
from bzrlib.errors import UnrelatedBranches, NoCommits, BzrCommandError |
1551.2.23
by Aaron Bentley
Got merge_inner's ignore_zero parameter working |
8 |
from bzrlib.merge import transform_tree, merge_inner |
1185.31.32
by John Arbash Meinel
Updated the bzr sourcecode to use bzrlib.osutils.pathjoin rather than os.path.join to enforce internal use of / instead of \ |
9 |
from bzrlib.osutils import pathjoin |
1534.4.28
by Robert Collins
first cut at merge from integration. |
10 |
from bzrlib.revision import common_ancestor |
11 |
from bzrlib.tests import TestCaseWithTransport |
|
1551.2.23
by Aaron Bentley
Got merge_inner's ignore_zero parameter working |
12 |
from bzrlib.trace import (enable_test_log, disable_test_log) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
13 |
from bzrlib.workingtree import WorkingTree |
14 |
||
15 |
||
16 |
class TestMerge(TestCaseWithTransport): |
|
974.1.56
by aaron.bentley at utoronto
Added merge test |
17 |
"""Test appending more than one revision"""
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
18 |
|
974.1.56
by aaron.bentley at utoronto
Added merge test |
19 |
def test_pending(self): |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
20 |
wt = self.make_branch_and_tree('.') |
21 |
wt.commit("lala!") |
|
22 |
self.assertEquals(len(wt.pending_merges()), 0) |
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
23 |
merge([u'.', -1], [None, None]) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
24 |
self.assertEquals(len(wt.pending_merges()), 0) |
974.1.80
by Aaron Bentley
Improved merge error handling and testing |
25 |
|
1558.4.11
by Aaron Bentley
Allow merge against self, make fetching self a noop |
26 |
def test_undo(self): |
27 |
wt = self.make_branch_and_tree('.') |
|
28 |
wt.commit("lala!") |
|
29 |
wt.commit("haha!") |
|
30 |
wt.commit("blabla!") |
|
31 |
merge([u'.', 2], [u'.', 1]) |
|
32 |
||
974.1.80
by Aaron Bentley
Improved merge error handling and testing |
33 |
def test_nocommits(self): |
34 |
self.test_pending() |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
35 |
wt2 = self.make_branch_and_tree('branch2') |
974.1.80
by Aaron Bentley
Improved merge error handling and testing |
36 |
self.assertRaises(NoCommits, merge, ['branch2', -1], |
37 |
[None, None]) |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
38 |
return wt2 |
974.1.80
by Aaron Bentley
Improved merge error handling and testing |
39 |
|
40 |
def test_unrelated(self): |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
41 |
wt2 = self.test_nocommits() |
42 |
wt2.commit("blah") |
|
974.1.80
by Aaron Bentley
Improved merge error handling and testing |
43 |
self.assertRaises(UnrelatedBranches, merge, ['branch2', -1], |
44 |
[None, None]) |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
45 |
return wt2 |
974.1.80
by Aaron Bentley
Improved merge error handling and testing |
46 |
|
1645.1.1
by Aaron Bentley
Implement single-file merge |
47 |
def test_merge_one(self): |
48 |
wt1 = self.make_branch_and_tree('branch1') |
|
49 |
wt1.commit('empty commit') |
|
50 |
wt2 = self.make_branch_and_tree('branch2') |
|
51 |
wt2.pull(wt1.branch) |
|
52 |
file('branch1/foo', 'wb').write('foo') |
|
53 |
file('branch1/bar', 'wb').write('bar') |
|
54 |
wt1.add('foo') |
|
55 |
wt1.add('bar') |
|
56 |
wt1.commit('add foobar') |
|
57 |
os.chdir('branch2') |
|
58 |
self.run_bzr('merge', '../branch1/baz', retcode=3) |
|
59 |
self.run_bzr('merge', '../branch1/foo') |
|
60 |
self.failUnlessExists('foo') |
|
61 |
self.failIfExists('bar') |
|
62 |
wt2 = WorkingTree.open_containing('branch2')[0] |
|
63 |
self.assertEqual(wt2.pending_merges(), []) |
|
64 |
||
974.1.88
by Aaron Bentley
Set a pending_merge if the merge base is forced to revno 0 |
65 |
def test_pending_with_null(self): |
66 |
"""When base is forced to revno 0, pending_merges is set"""
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
67 |
wt2 = self.test_unrelated() |
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
68 |
wt1 = WorkingTree.open('.') |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
69 |
br1 = wt1.branch |
1534.1.31
by Robert Collins
Deprecated fetch.fetch and fetch.greedy_fetch for branch.fetch, and move the Repository.fetch internals to InterRepo and InterWeaveRepo. |
70 |
br1.fetch(wt2.branch) |
1390
by Robert Collins
pair programming worx... merge integration and weave |
71 |
# merge all of branch 2 into branch 1 even though they
|
72 |
# are not related.
|
|
1185.24.3
by Aaron Bentley
Integrated reprocessing into the rest of the merge stuff |
73 |
self.assertRaises(BzrCommandError, merge, ['branch2', -1], |
74 |
['branch2', 0], reprocess=True, show_base=True) |
|
75 |
merge(['branch2', -1], ['branch2', 0], reprocess=True) |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
76 |
self.assertEquals(len(wt1.pending_merges()), 1) |
77 |
return (wt1, wt2.branch) |
|
974.1.89
by Aaron Bentley
Fixed merging with multiple roots, by using null as graph root. |
78 |
|
79 |
def test_two_roots(self): |
|
80 |
"""Merge base is sane when two unrelated branches are merged"""
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
81 |
wt1, br2 = self.test_pending_with_null() |
82 |
wt1.commit("blah") |
|
83 |
last = wt1.branch.last_revision() |
|
1534.4.28
by Robert Collins
first cut at merge from integration. |
84 |
self.assertEquals(common_ancestor(last, last, wt1.branch.repository), last) |
1185.46.1
by Aaron Bentley
Test case when file to be renamed is also deleted |
85 |
|
86 |
def test_create_rename(self): |
|
87 |
"""Rename an inventory entry while creating the file"""
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
88 |
tree =self.make_branch_and_tree('.') |
1185.46.1
by Aaron Bentley
Test case when file to be renamed is also deleted |
89 |
file('name1', 'wb').write('Hello') |
90 |
tree.add('name1') |
|
91 |
tree.commit(message="hello") |
|
92 |
tree.rename_one('name1', 'name2') |
|
93 |
os.unlink('name2') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
94 |
transform_tree(tree, tree.branch.basis_tree()) |
1185.46.2
by Aaron Bentley
Added test for renaming both parent and child |
95 |
|
96 |
def test_layered_rename(self): |
|
97 |
"""Rename both child and parent at same time"""
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
98 |
tree =self.make_branch_and_tree('.') |
1185.46.2
by Aaron Bentley
Added test for renaming both parent and child |
99 |
os.mkdir('dirname1') |
100 |
tree.add('dirname1') |
|
1185.31.32
by John Arbash Meinel
Updated the bzr sourcecode to use bzrlib.osutils.pathjoin rather than os.path.join to enforce internal use of / instead of \ |
101 |
filename = pathjoin('dirname1', 'name1') |
1185.46.2
by Aaron Bentley
Added test for renaming both parent and child |
102 |
file(filename, 'wb').write('Hello') |
103 |
tree.add(filename) |
|
104 |
tree.commit(message="hello") |
|
1185.31.32
by John Arbash Meinel
Updated the bzr sourcecode to use bzrlib.osutils.pathjoin rather than os.path.join to enforce internal use of / instead of \ |
105 |
filename2 = pathjoin('dirname1', 'name2') |
1185.46.2
by Aaron Bentley
Added test for renaming both parent and child |
106 |
tree.rename_one(filename, filename2) |
107 |
tree.rename_one('dirname1', 'dirname2') |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
108 |
transform_tree(tree, tree.branch.basis_tree()) |
1551.2.23
by Aaron Bentley
Got merge_inner's ignore_zero parameter working |
109 |
|
110 |
def test_ignore_zero_merge_inner(self): |
|
111 |
# Test that merge_inner's ignore zero paramter is effective
|
|
112 |
tree_a =self.make_branch_and_tree('a') |
|
113 |
tree_a.commit(message="hello") |
|
114 |
dir_b = tree_a.bzrdir.sprout('b') |
|
115 |
tree_b = dir_b.open_workingtree() |
|
116 |
tree_a.commit(message="hello again") |
|
117 |
log = StringIO() |
|
118 |
merge_inner(tree_b.branch, tree_a, tree_b.basis_tree(), |
|
119 |
this_tree=tree_b, ignore_zero=True) |
|
1551.4.1
by Aaron Bentley
Workaround for silly _get_log behaviour in test |
120 |
log = self._get_log() |
121 |
self.failUnless('All changes applied successfully.\n' not in log) |
|
1551.2.23
by Aaron Bentley
Got merge_inner's ignore_zero parameter working |
122 |
tree_b.revert([]) |
123 |
merge_inner(tree_b.branch, tree_a, tree_b.basis_tree(), |
|
124 |
this_tree=tree_b, ignore_zero=False) |
|
1551.4.1
by Aaron Bentley
Workaround for silly _get_log behaviour in test |
125 |
log = self._get_log() |
126 |
self.failUnless('All changes applied successfully.\n' in log) |