43
36
puller = puller_tree.branch
44
37
merger_tree = self.make_branch_and_tree('merger')
45
38
merger = merger_tree.branch
46
self.assertUnmerged(([], []), original, puller)
39
self.assertEqual(find_unmerged(original, puller), ([], []))
47
40
original_tree.commit('a', rev_id='a')
48
self.assertUnmerged(([('1', 'a')], []), original, puller)
41
self.assertEqual(find_unmerged(original, puller), ([(1, u'a')], []))
49
42
puller_tree.pull(original)
50
self.assertUnmerged(([], []), original, puller)
43
self.assertEqual(find_unmerged(original, puller), ([], []))
51
44
merger_tree.pull(original)
52
45
original_tree.commit('b', rev_id='b')
53
46
original_tree.commit('c', rev_id='c')
54
self.assertUnmerged(([('2', 'b'), ('3', 'c')], []),
56
self.assertUnmerged(([('3', 'c'), ('2', 'b')], []),
57
original, puller, backward=True)
47
self.assertEqual(find_unmerged(original, puller), ([(2, u'b'),
59
50
puller_tree.pull(original)
60
self.assertUnmerged(([], []), original, puller)
61
self.assertUnmerged(([('2', 'b'), ('3', 'c')], []),
51
self.assertEqual(find_unmerged(original, puller), ([], []))
52
self.assertEqual(find_unmerged(original, merger), ([(2, u'b'),
63
54
merger_tree.merge_from_branch(original)
64
self.assertUnmerged(([('2', 'b'), ('3', 'c')], []),
55
self.assertEqual(find_unmerged(original, merger), ([(2, u'b'),
66
57
merger_tree.commit('d', rev_id='d')
67
self.assertUnmerged(([], [('2', 'd')]), original, merger)
58
self.assertEqual(find_unmerged(original, merger), ([], [(2, 'd')]))
60
def test_iter_log_data(self):
61
base_tree = self.make_branch_and_tree('base')
62
self.build_tree(['base/a'])
63
base_tree.add(['a'], ['a-id'])
64
base_tree.commit('add a', rev_id='b-1')
66
child_tree = base_tree.bzrdir.sprout('child').open_workingtree()
68
self.build_tree(['child/b'])
69
child_tree.add(['b'], ['b-id'])
70
child_tree.commit('adding b', rev_id='c-2')
72
child_tree.remove(['a'])
73
child_tree.commit('removing a', rev_id='c-3')
75
self.build_tree_contents([('child/b', 'new contents for b\n')])
76
child_tree.commit('modifying b', rev_id='c-4')
78
child_tree.rename_one('b', 'c')
79
child_tree.commit('rename b=>c', rev_id='c-5')
81
base_extra, child_extra = find_unmerged(base_tree.branch,
83
results = list(self.applyDeprecated(zero_seventeen, iter_log_data,
85
base_tree.branch.repository,
87
self.assertEqual([], results)
89
results = list(self.applyDeprecated(zero_seventeen, iter_log_data,
91
child_tree.branch.repository,
93
self.assertEqual(4, len(results))
97
self.assertEqual((2, 'c-2'), (r0[0], r0[1].revision_id))
98
self.assertEqual((3, 'c-3'), (r1[0], r1[1].revision_id))
99
self.assertEqual((4, 'c-4'), (r2[0], r2[1].revision_id))
100
self.assertEqual((5, 'c-5'), (r3[0], r3[1].revision_id))
103
self.assertNotEqual(None, delta0)
104
self.assertEqual([('b', 'b-id', 'file')], delta0.added)
105
self.assertEqual([], delta0.removed)
106
self.assertEqual([], delta0.renamed)
107
self.assertEqual([], delta0.modified)
110
self.assertNotEqual(None, delta1)
111
self.assertEqual([], delta1.added)
112
self.assertEqual([('a', 'a-id', 'file')], delta1.removed)
113
self.assertEqual([], delta1.renamed)
114
self.assertEqual([], delta1.modified)
117
self.assertNotEqual(None, delta2)
118
self.assertEqual([], delta2.added)
119
self.assertEqual([], delta2.removed)
120
self.assertEqual([], delta2.renamed)
121
self.assertEqual([('b', 'b-id', 'file', True, False)], delta2.modified)
124
self.assertNotEqual(None, delta3)
125
self.assertEqual([], delta3.added)
126
self.assertEqual([], delta3.removed)
127
self.assertEqual([('b', 'c', 'b-id', 'file', False, False)],
129
self.assertEqual([], delta3.modified)
69
131
def test_iter_log_revisions(self):
70
132
base_tree = self.make_branch_and_tree('base')
133
196
self.assertEqual([('b', 'c', 'b-id', 'file', False, False)],
135
198
self.assertEqual([], delta3.modified)
138
class TestFindUnmerged(tests.TestCaseWithTransport):
140
def assertUnmerged(self, local, remote, local_branch, remote_branch,
141
restrict, include_merges=False,
143
"""Check the output of find_unmerged_mainline_revisions"""
144
local_extra, remote_extra = missing.find_unmerged(
145
local_branch, remote_branch, restrict,
146
include_merges=include_merges,
148
self.assertEqual(local, local_extra)
149
self.assertEqual(remote, remote_extra)
151
def test_same_branch(self):
152
tree = self.make_branch_and_tree('tree')
153
rev1 = tree.commit('one')
155
self.addCleanup(tree.unlock)
156
self.assertUnmerged([], [], tree.branch, tree.branch, 'all')
158
def test_one_ahead(self):
159
tree = self.make_branch_and_tree('tree')
160
rev1 = tree.commit('one')
161
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
162
rev2 = tree2.commit('two')
163
self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
164
self.assertUnmerged([('2', rev2)], [], tree2.branch, tree.branch, 'all')
166
def test_restrict(self):
167
tree = self.make_branch_and_tree('tree')
168
rev1 = tree.commit('one')
169
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
170
rev2 = tree2.commit('two')
171
self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
172
self.assertUnmerged([], None, tree.branch, tree2.branch, 'local')
173
self.assertUnmerged(None, [('2', rev2)], tree.branch, tree2.branch,
176
def test_merged(self):
177
tree = self.make_branch_and_tree('tree')
178
rev1 = tree.commit('one')
179
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
180
rev2 = tree2.commit('two')
181
rev3 = tree2.commit('three')
182
tree.merge_from_branch(tree2.branch)
183
rev4 = tree.commit('four')
185
self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch, 'all')
187
def test_include_merges(self):
188
tree = self.make_branch_and_tree('tree')
189
rev1 = tree.commit('one', rev_id='rev1')
191
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
192
rev2 = tree2.commit('two', rev_id='rev2')
193
rev3 = tree2.commit('three', rev_id='rev3')
195
tree3 = tree2.bzrdir.sprout('tree3').open_workingtree()
196
rev4 = tree3.commit('four', rev_id='rev4')
197
rev5 = tree3.commit('five', rev_id='rev5')
199
tree2.merge_from_branch(tree3.branch)
200
rev6 = tree2.commit('six', rev_id='rev6')
202
self.assertUnmerged([], [('2', 'rev2', 0), ('3', 'rev3',0 ),
204
('3.1.1', 'rev4', 1), ('3.1.2', 'rev5', 1),
206
tree.branch, tree2.branch, 'all',
209
self.assertUnmerged([], [('4', 'rev6', 0),
210
('3.1.2', 'rev5', 1), ('3.1.1', 'rev4', 1),
211
('3', 'rev3',0 ), ('2', 'rev2', 0),
213
tree.branch, tree2.branch, 'all',