37
41
puller = puller_tree.branch
38
42
merger_tree = self.make_branch_and_tree('merger')
39
43
merger = merger_tree.branch
40
self.assertEqual(find_unmerged(original, puller), ([], []))
44
self.assertUnmerged(([], []), original, puller)
41
45
original_tree.commit('a', rev_id='a')
42
self.assertEqual(find_unmerged(original, puller), ([(1, u'a')], []))
46
self.assertUnmerged(([(1, 'a')], []), original, puller)
43
47
puller_tree.pull(original)
44
self.assertEqual(find_unmerged(original, puller), ([], []))
48
self.assertUnmerged(([], []), original, puller)
45
49
merger_tree.pull(original)
46
50
original_tree.commit('b', rev_id='b')
47
51
original_tree.commit('c', rev_id='c')
48
self.assertEqual(find_unmerged(original, puller), ([(2, u'b'),
52
self.assertUnmerged(([(2, 'b'), (3, 'c')], []),
51
55
puller_tree.pull(original)
52
self.assertEqual(find_unmerged(original, puller), ([], []))
53
self.assertEqual(find_unmerged(original, merger), ([(2, u'b'),
55
merge(['original', -1], [None, None], this_dir='merger')
56
self.assertEqual(find_unmerged(original, merger), ([(2, u'b'),
56
self.assertUnmerged(([], []), original, puller)
57
self.assertUnmerged(([(2, 'b'), (3, 'c')], []),
59
merger_tree.merge_from_branch(original)
60
self.assertUnmerged(([(2, 'b'), (3, 'c')], []),
58
62
merger_tree.commit('d', rev_id='d')
59
self.assertEqual(find_unmerged(original, merger), ([], [(2, 'd')]))
61
def test_iter_log_data(self):
62
base_tree = self.make_branch_and_tree('base')
63
self.build_tree(['base/a'])
64
base_tree.add(['a'], ['a-id'])
65
base_tree.commit('add a', rev_id='b-1')
67
child_tree = base_tree.bzrdir.sprout('child').open_workingtree()
69
self.build_tree(['child/b'])
70
child_tree.add(['b'], ['b-id'])
71
child_tree.commit('adding b', rev_id='c-2')
73
child_tree.remove(['a'])
74
child_tree.commit('removing a', rev_id='c-3')
76
self.build_tree_contents([('child/b', 'new contents for b\n')])
77
child_tree.commit('modifying b', rev_id='c-4')
79
child_tree.rename_one('b', 'c')
80
child_tree.commit('rename b=>c', rev_id='c-5')
82
base_extra, child_extra = find_unmerged(base_tree.branch,
84
results = list(self.applyDeprecated(zero_seventeen, iter_log_data,
86
base_tree.branch.repository,
88
self.assertEqual([], results)
90
results = list(self.applyDeprecated(zero_seventeen, iter_log_data,
92
child_tree.branch.repository,
94
self.assertEqual(4, len(results))
98
self.assertEqual((2, 'c-2'), (r0[0], r0[1].revision_id))
99
self.assertEqual((3, 'c-3'), (r1[0], r1[1].revision_id))
100
self.assertEqual((4, 'c-4'), (r2[0], r2[1].revision_id))
101
self.assertEqual((5, 'c-5'), (r3[0], r3[1].revision_id))
104
self.assertNotEqual(None, delta0)
105
self.assertEqual([('b', 'b-id', 'file')], delta0.added)
106
self.assertEqual([], delta0.removed)
107
self.assertEqual([], delta0.renamed)
108
self.assertEqual([], delta0.modified)
111
self.assertNotEqual(None, delta1)
112
self.assertEqual([], delta1.added)
113
self.assertEqual([('a', 'a-id', 'file')], delta1.removed)
114
self.assertEqual([], delta1.renamed)
115
self.assertEqual([], delta1.modified)
118
self.assertNotEqual(None, delta2)
119
self.assertEqual([], delta2.added)
120
self.assertEqual([], delta2.removed)
121
self.assertEqual([], delta2.renamed)
122
self.assertEqual([('b', 'b-id', 'file', True, False)], delta2.modified)
125
self.assertNotEqual(None, delta3)
126
self.assertEqual([], delta3.added)
127
self.assertEqual([], delta3.removed)
128
self.assertEqual([('b', 'c', 'b-id', 'file', False, False)],
130
self.assertEqual([], delta3.modified)
63
self.assertUnmerged(([], [(2, 'd')]), original, merger)
132
65
def test_iter_log_revisions(self):
133
66
base_tree = self.make_branch_and_tree('base')
197
130
self.assertEqual([('b', 'c', 'b-id', 'file', False, False)],
199
132
self.assertEqual([], delta3.modified)
135
class TestFindUnmerged(tests.TestCaseWithTransport):
137
def assertUnmerged(self, local, remote, local_branch, remote_branch,
139
"""Check the output of find_unmerged_mainline_revisions"""
140
local_extra, remote_extra = missing.find_unmerged(
141
local_branch, remote_branch, restrict)
142
self.assertEqual(local, local_extra)
143
self.assertEqual(remote, remote_extra)
145
def test_same_branch(self):
146
tree = self.make_branch_and_tree('tree')
147
rev1 = tree.commit('one')
149
self.addCleanup(tree.unlock)
150
self.assertUnmerged([], [], tree.branch, tree.branch, 'all')
152
def test_one_ahead(self):
153
tree = self.make_branch_and_tree('tree')
154
rev1 = tree.commit('one')
155
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
156
rev2 = tree2.commit('two')
158
self.addCleanup(tree.unlock)
160
self.addCleanup(tree2.unlock)
161
self.assertUnmerged([], [(2, rev2)], tree.branch, tree2.branch, 'all')
162
self.assertUnmerged([(2, rev2)], [], tree2.branch, tree.branch, 'all')
164
def test_restrict(self):
165
tree = self.make_branch_and_tree('tree')
166
rev1 = tree.commit('one')
167
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
168
rev2 = tree2.commit('two')
170
self.addCleanup(tree.unlock)
172
self.addCleanup(tree2.unlock)
173
self.assertUnmerged([], [(2, rev2)], tree.branch, tree2.branch, 'all')
174
self.assertUnmerged([], None, tree.branch, tree2.branch, 'local')
175
self.assertUnmerged(None, [(2, rev2)], tree.branch, tree2.branch,
178
def test_merged(self):
179
tree = self.make_branch_and_tree('tree')
180
rev1 = tree.commit('one')
181
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
182
rev2 = tree2.commit('two')
183
rev3 = tree2.commit('three')
184
tree.merge_from_branch(tree2.branch)
185
rev4 = tree.commit('four')
188
self.addCleanup(tree.unlock)
190
self.addCleanup(tree2.unlock)
192
self.assertUnmerged([(2, rev4)], [], tree.branch, tree2.branch, 'all')