4763.2.4
by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry. |
1 |
# Copyright (C) 2006-2010 Canonical Ltd
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
2 |
#
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
7 |
#
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
12 |
#
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
16 |
#
|
17 |
# Author: Aaron Bentley <aaron.bentley@utoronto.ca>
|
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
18 |
|
19 |
"""Black-box tests for bzr merge.
|
|
20 |
"""
|
|
21 |
||
22 |
import os |
|
23 |
||
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
24 |
from bzrlib import ( |
25 |
branch, |
|
26 |
bzrdir, |
|
27 |
conflicts, |
|
28 |
merge_directive, |
|
29 |
osutils, |
|
30 |
tests, |
|
31 |
urlutils, |
|
32 |
workingtree, |
|
33 |
)
|
|
34 |
||
35 |
||
36 |
class TestMerge(tests.TestCaseWithTransport): |
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
37 |
|
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
38 |
def example_branch(self, path='.'): |
39 |
tree = self.make_branch_and_tree(path) |
|
40 |
self.build_tree_contents([ |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
41 |
(osutils.pathjoin(path, 'hello'), 'foo'), |
42 |
(osutils.pathjoin(path, 'goodbye'), 'baz')]) |
|
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
43 |
tree.add('hello') |
44 |
tree.commit(message='setup') |
|
45 |
tree.add('goodbye') |
|
46 |
tree.commit(message='setup') |
|
47 |
return tree |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
48 |
|
3744.2.1
by John Arbash Meinel
Change 'bzr merge' so that it uses --reprocess as long as --show-base is not given. |
49 |
def create_conflicting_branches(self): |
50 |
"""Create two branches which have overlapping modifications.
|
|
51 |
||
52 |
:return: (tree, other_branch) Where merging other_branch causes a file
|
|
53 |
conflict.
|
|
54 |
"""
|
|
55 |
builder = self.make_branch_builder('branch') |
|
56 |
builder.build_snapshot('rev1', None, |
|
57 |
[('add', ('', 'root-id', 'directory', None)), |
|
58 |
('add', ('fname', 'f-id', 'file', 'a\nb\nc\n'))]) |
|
59 |
builder.build_snapshot('rev2other', ['rev1'], |
|
60 |
[('modify', ('f-id', 'a\nB\nD\n'))]) |
|
61 |
other = builder.get_branch().bzrdir.sprout('other').open_branch() |
|
62 |
builder.build_snapshot('rev2this', ['rev1'], |
|
63 |
[('modify', ('f-id', 'a\nB\nC\n'))]) |
|
64 |
tree = builder.get_branch().create_checkout('tree', lightweight=True) |
|
65 |
return tree, other |
|
66 |
||
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
67 |
def test_merge_reprocess(self): |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
68 |
d = bzrdir.BzrDir.create_standalone_workingtree('.') |
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
69 |
d.commit('h') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
70 |
self.run_bzr('merge . --reprocess --merge-type weave') |
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
71 |
|
72 |
def test_merge(self): |
|
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
73 |
a_tree = self.example_branch('a') |
2738.3.2
by Daniel Watkins
Modified as per abentley's comments. |
74 |
ancestor = a_tree.branch.revno() |
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
75 |
b_tree = a_tree.bzrdir.sprout('b').open_workingtree() |
76 |
self.build_tree_contents([('b/goodbye', 'quux')]) |
|
77 |
b_tree.commit(message="more u's are always good") |
|
78 |
||
79 |
self.build_tree_contents([('a/hello', 'quuux')]) |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
80 |
# We can't merge when there are in-tree changes
|
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
81 |
os.chdir('a') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
82 |
self.run_bzr('merge ../b', retcode=3) |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
83 |
a = workingtree.WorkingTree.open('.') |
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
84 |
a_tip = a.commit("Like an epidemic of u's") |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
85 |
self.run_bzr('merge ../b -r last:1..last:1 --merge-type blooof', |
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
86 |
retcode=3) |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
87 |
self.run_bzr('merge ../b -r last:1..last:1 --merge-type merge3') |
2796.1.4
by Aaron Bentley
Fix up various test cases |
88 |
a_tree.revert(backups=False) |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
89 |
self.run_bzr('merge ../b -r last:1..last:1 --merge-type weave') |
2796.1.4
by Aaron Bentley
Fix up various test cases |
90 |
a_tree.revert(backups=False) |
3144.3.1
by Aaron Bentley
Implement LCA merge, with problematic conflict markers |
91 |
self.run_bzr('merge ../b -r last:1..last:1 --merge-type lca') |
92 |
a_tree.revert(backups=False) |
|
2665.2.1
by Michael Hudson
test and fix for a NameError in merge --weave --show-base |
93 |
self.run_bzr_error(['Show-base is not supported for this merge type'], |
94 |
'merge ../b -r last:1..last:1 --merge-type weave'
|
|
95 |
' --show-base') |
|
2796.1.4
by Aaron Bentley
Fix up various test cases |
96 |
a_tree.revert(backups=False) |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
97 |
self.run_bzr('merge ../b -r last:1..last:1 --reprocess') |
2796.1.4
by Aaron Bentley
Fix up various test cases |
98 |
a_tree.revert(backups=False) |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
99 |
self.run_bzr('merge ../b -r last:1') |
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
100 |
self.check_file_contents('goodbye', 'quux') |
101 |
# Merging a branch pulls its revision into the tree
|
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
102 |
b = branch.Branch.open('../b') |
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
103 |
b_tip = b.last_revision() |
104 |
self.failUnless(a.branch.repository.has_revision(b_tip)) |
|
105 |
self.assertEqual([a_tip, b_tip], a.get_parent_ids()) |
|
2796.1.4
by Aaron Bentley
Fix up various test cases |
106 |
a_tree.revert(backups=False) |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
107 |
out, err = self.run_bzr('merge -r revno:1:./hello', retcode=3) |
1907.4.13
by Matthieu Moy
Better testcase for revno:N:branch/path error. |
108 |
self.assertTrue("Not a branch" in err) |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
109 |
self.run_bzr('merge -r revno:%d:./..revno:%d:../b' |
1907.4.12
by Matthieu Moy
Made merge work with two revisions in different branches. |
110 |
%(ancestor,b.revno())) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
111 |
self.assertEquals(a.get_parent_ids(), |
1551.8.25
by Aaron Bentley
Fix deprecated use of pending_merges |
112 |
[a.branch.last_revision(), b.last_revision()]) |
1907.4.12
by Matthieu Moy
Made merge work with two revisions in different branches. |
113 |
self.check_file_contents('goodbye', 'quux') |
2796.1.4
by Aaron Bentley
Fix up various test cases |
114 |
a_tree.revert(backups=False) |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
115 |
self.run_bzr('merge -r revno:%d:../b'%b.revno()) |
1551.8.25
by Aaron Bentley
Fix deprecated use of pending_merges |
116 |
self.assertEquals(a.get_parent_ids(), |
117 |
[a.branch.last_revision(), b.last_revision()]) |
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
118 |
a_tip = a.commit('merged') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
119 |
self.run_bzr('merge ../b -r last:1') |
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
120 |
self.assertEqual([a_tip], a.get_parent_ids()) |
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
121 |
|
3744.2.1
by John Arbash Meinel
Change 'bzr merge' so that it uses --reprocess as long as --show-base is not given. |
122 |
def test_merge_defaults_to_reprocess(self): |
123 |
tree, other = self.create_conflicting_branches() |
|
124 |
# The default merge algorithm should enable 'reprocess' because
|
|
125 |
# 'show-base' is not set
|
|
3744.2.2
by John Arbash Meinel
Merge returns code 1 to indicate there were conflicts. |
126 |
self.run_bzr('merge ../other', working_dir='tree', |
127 |
retcode=1) |
|
3744.2.1
by John Arbash Meinel
Change 'bzr merge' so that it uses --reprocess as long as --show-base is not given. |
128 |
self.assertEqualDiff('a\n' |
129 |
'B\n' |
|
130 |
'<<<<<<< TREE\n' |
|
131 |
'C\n' |
|
132 |
'=======\n' |
|
133 |
'D\n' |
|
134 |
'>>>>>>> MERGE-SOURCE\n', |
|
135 |
tree.get_file_text('f-id')) |
|
136 |
||
137 |
def test_merge_explicit_reprocess_show_base(self): |
|
138 |
tree, other = self.create_conflicting_branches() |
|
139 |
# Explicitly setting --reprocess, and --show-base is an error
|
|
140 |
self.run_bzr_error(['Cannot do conflict reduction and show base'], |
|
141 |
'merge ../other --reprocess --show-base', |
|
142 |
working_dir='tree') |
|
143 |
||
144 |
def test_merge_override_reprocess(self): |
|
145 |
tree, other = self.create_conflicting_branches() |
|
146 |
# Explicitly disable reprocess
|
|
3744.2.2
by John Arbash Meinel
Merge returns code 1 to indicate there were conflicts. |
147 |
self.run_bzr('merge ../other --no-reprocess', working_dir='tree', |
148 |
retcode=1) |
|
3744.2.1
by John Arbash Meinel
Change 'bzr merge' so that it uses --reprocess as long as --show-base is not given. |
149 |
self.assertEqualDiff('a\n' |
150 |
'<<<<<<< TREE\n' |
|
151 |
'B\n' |
|
152 |
'C\n' |
|
153 |
'=======\n' |
|
154 |
'B\n' |
|
155 |
'D\n' |
|
156 |
'>>>>>>> MERGE-SOURCE\n', |
|
157 |
tree.get_file_text('f-id')) |
|
158 |
||
159 |
def test_merge_override_show_base(self): |
|
160 |
tree, other = self.create_conflicting_branches() |
|
161 |
# Setting '--show-base' will auto-disable '--reprocess'
|
|
3744.2.2
by John Arbash Meinel
Merge returns code 1 to indicate there were conflicts. |
162 |
self.run_bzr('merge ../other --show-base', working_dir='tree', |
163 |
retcode=1) |
|
3744.2.1
by John Arbash Meinel
Change 'bzr merge' so that it uses --reprocess as long as --show-base is not given. |
164 |
self.assertEqualDiff('a\n' |
165 |
'<<<<<<< TREE\n' |
|
166 |
'B\n' |
|
167 |
'C\n' |
|
168 |
'||||||| BASE-REVISION\n' |
|
169 |
'b\n' |
|
170 |
'c\n' |
|
171 |
'=======\n' |
|
172 |
'B\n' |
|
173 |
'D\n' |
|
174 |
'>>>>>>> MERGE-SOURCE\n', |
|
175 |
tree.get_file_text('f-id')) |
|
176 |
||
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
177 |
def test_merge_with_missing_file(self): |
178 |
"""Merge handles missing file conflicts"""
|
|
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
179 |
self.build_tree_contents([ |
2738.3.4
by Daniel Watkins
Fixed tuple spacing. |
180 |
('a/',), |
181 |
('a/sub/',), |
|
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
182 |
('a/sub/a.txt', 'hello\n'), |
2738.3.3
by Daniel Watkins
Minor reformatting per abentley's mailing list comments. |
183 |
('a/b.txt', 'hello\n'), |
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
184 |
('a/sub/c.txt', 'hello\n')]) |
185 |
a_tree = self.make_branch_and_tree('a') |
|
186 |
a_tree.add(['sub', 'b.txt', 'sub/c.txt', 'sub/a.txt']) |
|
187 |
a_tree.commit(message='added a') |
|
188 |
b_tree = a_tree.bzrdir.sprout('b').open_workingtree() |
|
189 |
self.build_tree_contents([ |
|
190 |
('a/sub/a.txt', 'hello\nthere\n'), |
|
2738.3.3
by Daniel Watkins
Minor reformatting per abentley's mailing list comments. |
191 |
('a/b.txt', 'hello\nthere\n'), |
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
192 |
('a/sub/c.txt', 'hello\nthere\n')]) |
193 |
a_tree.commit(message='Added there') |
|
194 |
os.remove('a/sub/a.txt') |
|
195 |
os.remove('a/sub/c.txt') |
|
196 |
os.rmdir('a/sub') |
|
197 |
os.remove('a/b.txt') |
|
198 |
a_tree.commit(message='Removed a.txt') |
|
199 |
self.build_tree_contents([ |
|
200 |
('b/sub/a.txt', 'hello\nsomething\n'), |
|
2738.3.3
by Daniel Watkins
Minor reformatting per abentley's mailing list comments. |
201 |
('b/b.txt', 'hello\nsomething\n'), |
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
202 |
('b/sub/c.txt', 'hello\nsomething\n')]) |
203 |
b_tree.commit(message='Modified a.txt') |
|
204 |
os.chdir('b') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
205 |
self.run_bzr('merge ../a/', retcode=1) |
2738.3.2
by Daniel Watkins
Modified as per abentley's comments. |
206 |
self.failUnlessExists('sub/a.txt.THIS') |
207 |
self.failUnlessExists('sub/a.txt.BASE') |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
208 |
os.chdir('../a') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
209 |
self.run_bzr('merge ../b/', retcode=1) |
2738.3.2
by Daniel Watkins
Modified as per abentley's comments. |
210 |
self.failUnlessExists('sub/a.txt.OTHER') |
211 |
self.failUnlessExists('sub/a.txt.BASE') |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
212 |
|
4634.101.10
by John Arbash Meinel
Add a fairly trivial test case, that shows that we drop .BASE, .THIS, and .OTHER |
213 |
def test_conflict_leaves_base_this_other_files(self): |
214 |
tree, other = self.create_conflicting_branches() |
|
215 |
self.run_bzr('merge ../other', working_dir='tree', |
|
216 |
retcode=1) |
|
217 |
self.assertFileEqual('a\nb\nc\n', 'tree/fname.BASE') |
|
218 |
self.assertFileEqual('a\nB\nD\n', 'tree/fname.OTHER') |
|
219 |
self.assertFileEqual('a\nB\nC\n', 'tree/fname.THIS') |
|
220 |
||
221 |
def test_weave_conflict_leaves_base_this_other_files(self): |
|
222 |
tree, other = self.create_conflicting_branches() |
|
223 |
self.run_bzr('merge ../other --weave', working_dir='tree', |
|
224 |
retcode=1) |
|
225 |
self.assertFileEqual('a\nb\nc\n', 'tree/fname.BASE') |
|
226 |
self.assertFileEqual('a\nB\nD\n', 'tree/fname.OTHER') |
|
227 |
self.assertFileEqual('a\nB\nC\n', 'tree/fname.THIS') |
|
228 |
||
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
229 |
def test_merge_remember(self): |
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
230 |
"""Merge changes from one branch to another, test submit location."""
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
231 |
tree_a = self.make_branch_and_tree('branch_a') |
232 |
branch_a = tree_a.branch |
|
233 |
self.build_tree(['branch_a/a']) |
|
234 |
tree_a.add('a') |
|
235 |
tree_a.commit('commit a') |
|
236 |
branch_b = branch_a.bzrdir.sprout('branch_b').open_branch() |
|
237 |
tree_b = branch_b.bzrdir.open_workingtree() |
|
238 |
branch_c = branch_a.bzrdir.sprout('branch_c').open_branch() |
|
239 |
tree_c = branch_c.bzrdir.open_workingtree() |
|
240 |
self.build_tree(['branch_a/b']) |
|
241 |
tree_a.add('b') |
|
242 |
tree_a.commit('commit b') |
|
243 |
self.build_tree(['branch_c/c']) |
|
244 |
tree_c.add('c') |
|
245 |
tree_c.commit('commit c') |
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
246 |
# reset parent
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
247 |
parent = branch_b.get_parent() |
248 |
branch_b.set_parent(None) |
|
249 |
self.assertEqual(None, branch_b.get_parent()) |
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
250 |
# test merge for failure without parent set
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
251 |
os.chdir('branch_b') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
252 |
out = self.run_bzr('merge', retcode=3) |
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
253 |
self.assertEquals(out, |
1685.1.59
by Martin Pool
[broken] Fix up & refactor display of remembered urls to unescape properly |
254 |
('','bzr: ERROR: No location specified or remembered\n')) |
4037.2.5
by Roberto Aguilar
Updating tests for uncommitted changes. |
255 |
|
256 |
# test uncommitted changes
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
257 |
self.build_tree(['d']) |
258 |
tree_b.add('d') |
|
2796.2.14
by Aaron Bentley
Updates from review |
259 |
self.run_bzr_error(['Working tree ".*" has uncommitted changes'], |
4037.2.5
by Roberto Aguilar
Updating tests for uncommitted changes. |
260 |
'merge') |
261 |
||
262 |
# merge should now pass and implicitly remember merge location
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
263 |
tree_b.commit('commit d') |
4037.2.5
by Roberto Aguilar
Updating tests for uncommitted changes. |
264 |
out, err = self.run_bzr('merge ../branch_a') |
265 |
||
266 |
base = urlutils.local_path_from_url(branch_a.base) |
|
267 |
self.assertEndsWith(err, '+N b\nAll changes applied successfully.\n') |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
268 |
self.assertEquals(osutils.abspath(branch_b.get_submit_branch()), |
269 |
osutils.abspath(parent)) |
|
4037.2.5
by Roberto Aguilar
Updating tests for uncommitted changes. |
270 |
# test implicit --remember when committing new file
|
271 |
self.build_tree(['e']) |
|
272 |
tree_b.add('e') |
|
273 |
tree_b.commit('commit e') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
274 |
out, err = self.run_bzr('merge') |
3249.2.2
by Ian Clatworthy
Fix merge redirection when remembered location used - tweak tests |
275 |
self.assertStartsWith(err, |
3596.3.1
by James Westby
Give the user a bit more information about which saved location is being used. |
276 |
'Merging from remembered submit location %s\n' % (base,)) |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
277 |
# re-open tree as external run_bzr modified it
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
278 |
tree_b = branch_b.bzrdir.open_workingtree() |
279 |
tree_b.commit('merge branch_a') |
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
280 |
# test explicit --remember
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
281 |
out, err = self.run_bzr('merge ../branch_c --remember') |
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
282 |
self.assertEquals(out, '') |
1551.11.11
by Aaron Bentley
Get tests passing |
283 |
self.assertEquals(err, '+N c\nAll changes applied successfully.\n') |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
284 |
self.assertEquals(osutils.abspath(branch_b.get_submit_branch()), |
285 |
osutils.abspath(branch_c.bzrdir.root_transport.base)) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
286 |
# re-open tree as external run_bzr modified it
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
287 |
tree_b = branch_b.bzrdir.open_workingtree() |
288 |
tree_b.commit('merge branch_c') |
|
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
289 |
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
290 |
def test_merge_bundle(self): |
1185.82.33
by Aaron Bentley
Strengthen tests |
291 |
from bzrlib.testament import Testament |
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
292 |
tree_a = self.make_branch_and_tree('branch_a') |
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
293 |
self.build_tree_contents([('branch_a/a', 'hello')]) |
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
294 |
tree_a.add('a') |
295 |
tree_a.commit('message') |
|
296 |
||
297 |
tree_b = tree_a.bzrdir.sprout('branch_b').open_workingtree() |
|
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
298 |
self.build_tree_contents([('branch_a/a', 'hey there')]) |
1185.82.23
by Aaron Bentley
Switch the fetcher |
299 |
tree_a.commit('message') |
300 |
||
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
301 |
self.build_tree_contents([('branch_b/a', 'goodbye')]) |
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
302 |
tree_b.commit('message') |
303 |
os.chdir('branch_b') |
|
2654.3.1
by Aaron Bentley
Rename submit to send, make -o required, support -o- for stdout |
304 |
self.run_bzr('bundle ../branch_a -o ../bundle') |
1185.82.26
by Aaron Bentley
Get changeset merges closer to working |
305 |
os.chdir('../branch_a') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
306 |
self.run_bzr('merge ../bundle', retcode=1) |
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
307 |
testament_a = Testament.from_revision(tree_a.branch.repository, |
308 |
tree_b.get_parent_ids()[0]) |
|
1185.82.33
by Aaron Bentley
Strengthen tests |
309 |
testament_b = Testament.from_revision(tree_b.branch.repository, |
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
310 |
tree_b.get_parent_ids()[0]) |
1185.82.33
by Aaron Bentley
Strengthen tests |
311 |
self.assertEqualDiff(testament_a.as_text(), |
312 |
testament_b.as_text()) |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
313 |
tree_a.set_conflicts(conflicts.ConflictList()) |
1185.82.141
by Aaron Bentley
Ensure bzr works when you merge an already-merged bundle |
314 |
tree_a.commit('message') |
315 |
# it is legal to attempt to merge an already-merged bundle
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
316 |
output = self.run_bzr('merge ../bundle')[1] |
1185.82.141
by Aaron Bentley
Ensure bzr works when you merge an already-merged bundle |
317 |
# but it does nothing
|
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
318 |
self.assertFalse(tree_a.changes_from(tree_a.basis_tree()).has_changed()) |
1185.82.142
by Aaron Bentley
Update for review comments |
319 |
self.assertEqual('Nothing to do.\n', output) |
1910.1.1
by Aaron Bentley
Merge takes --uncommitted parameter |
320 |
|
321 |
def test_merge_uncommitted(self): |
|
322 |
"""Check that merge --uncommitted behaves properly"""
|
|
323 |
tree_a = self.make_branch_and_tree('a') |
|
324 |
self.build_tree(['a/file_1', 'a/file_2']) |
|
325 |
tree_a.add(['file_1', 'file_2']) |
|
326 |
tree_a.commit('commit 1') |
|
327 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
|
328 |
self.failUnlessExists('b/file_1') |
|
329 |
tree_a.rename_one('file_1', 'file_i') |
|
330 |
tree_a.commit('commit 2') |
|
331 |
tree_a.rename_one('file_2', 'file_ii') |
|
2279.3.1
by mbp at sourcefrog
Add a -d option to push, pull, merge (ported from tags branch) |
332 |
## os.chdir('b')
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
333 |
self.run_bzr('merge a --uncommitted -d b') |
2279.3.1
by mbp at sourcefrog
Add a -d option to push, pull, merge (ported from tags branch) |
334 |
self.failUnlessExists('b/file_1') |
335 |
self.failUnlessExists('b/file_ii') |
|
2748.3.2
by Aaron Bentley
Fix revert, remove-tree, and various tests to use None for 'no files specified' |
336 |
tree_b.revert() |
2279.3.1
by mbp at sourcefrog
Add a -d option to push, pull, merge (ported from tags branch) |
337 |
self.run_bzr_error(('Cannot use --uncommitted and --revision',), |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
338 |
'merge /a --uncommitted -r1 -d b') |
2149.2.1
by Jan Hudec
Option --pull for merge command. |
339 |
|
3017.3.1
by Aaron Bentley
merge --uncommit can now specify single files (#136890) |
340 |
def test_merge_uncommitted_file(self): |
341 |
"""It should be possible to merge changes from a single file."""
|
|
342 |
tree_a = self.make_branch_and_tree('tree_a') |
|
343 |
tree_a.commit('initial commit') |
|
344 |
tree_a.bzrdir.sprout('tree_b') |
|
345 |
self.build_tree(['tree_a/file1', 'tree_a/file2']) |
|
346 |
tree_a.add(['file1', 'file2']) |
|
347 |
os.chdir('tree_b') |
|
348 |
self.run_bzr(['merge', '--uncommitted', '../tree_a/file1']) |
|
349 |
self.failUnlessExists('file1') |
|
350 |
self.failIfExists('file2') |
|
351 |
||
2149.2.1
by Jan Hudec
Option --pull for merge command. |
352 |
def pullable_branch(self): |
353 |
tree_a = self.make_branch_and_tree('a') |
|
354 |
self.build_tree(['a/file']) |
|
355 |
tree_a.add(['file']) |
|
356 |
self.id1 = tree_a.commit('commit 1') |
|
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
357 |
|
2149.2.1
by Jan Hudec
Option --pull for merge command. |
358 |
tree_b = self.make_branch_and_tree('b') |
359 |
tree_b.pull(tree_a.branch) |
|
360 |
file('b/file', 'wb').write('foo') |
|
361 |
self.id2 = tree_b.commit('commit 2') |
|
362 |
||
363 |
def test_merge_pull(self): |
|
364 |
self.pullable_branch() |
|
365 |
os.chdir('a') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
366 |
(out, err) = self.run_bzr('merge --pull ../b') |
1551.15.67
by Aaron Bentley
Stop using _merge_helper for merging |
367 |
self.assertContainsRe(out, 'Now on revision 2\\.') |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
368 |
tree_a = workingtree.WorkingTree.open('.') |
2149.2.1
by Jan Hudec
Option --pull for merge command. |
369 |
self.assertEqual([self.id2], tree_a.get_parent_ids()) |
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
370 |
|
371 |
def test_merge_kind_change(self): |
|
372 |
tree_a = self.make_branch_and_tree('tree_a') |
|
373 |
self.build_tree_contents([('tree_a/file', 'content_1')]) |
|
374 |
tree_a.add('file', 'file-id') |
|
375 |
tree_a.commit('added file') |
|
376 |
tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree() |
|
377 |
os.unlink('tree_a/file') |
|
378 |
self.build_tree(['tree_a/file/']) |
|
379 |
tree_a.commit('changed file to directory') |
|
380 |
os.chdir('tree_b') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
381 |
self.run_bzr('merge ../tree_a') |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
382 |
self.assertEqual('directory', osutils.file_kind('file')) |
2748.3.2
by Aaron Bentley
Fix revert, remove-tree, and various tests to use None for 'no files specified' |
383 |
tree_b.revert() |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
384 |
self.assertEqual('file', osutils.file_kind('file')) |
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
385 |
self.build_tree_contents([('file', 'content_2')]) |
386 |
tree_b.commit('content change') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
387 |
self.run_bzr('merge ../tree_a', retcode=1) |
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
388 |
self.assertEqual(tree_b.conflicts(), |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
389 |
[conflicts.ContentsConflict('file', |
390 |
file_id='file-id')]) |
|
2520.4.109
by Aaron Bentley
start work on directive cherry-picking |
391 |
|
392 |
def test_directive_cherrypick(self): |
|
393 |
source = self.make_branch_and_tree('source') |
|
4593.1.1
by Martin Pool
Merge directive tests must use trees with the same root id. |
394 |
source.commit("nothing") |
5243.1.2
by Martin
Point launchpad links in comments at production server rather than edge |
395 |
# see https://bugs.launchpad.net/bzr/+bug/409688 - trying to
|
4593.1.1
by Martin Pool
Merge directive tests must use trees with the same root id. |
396 |
# cherrypick from one branch into another unrelated branch with a
|
397 |
# different root id will give shape conflicts. as a workaround we
|
|
398 |
# make sure they share the same root id.
|
|
399 |
target = source.bzrdir.sprout('target').open_workingtree() |
|
2520.4.109
by Aaron Bentley
start work on directive cherry-picking |
400 |
self.build_tree(['source/a']) |
401 |
source.add('a') |
|
402 |
source.commit('Added a', rev_id='rev1') |
|
403 |
self.build_tree(['source/b']) |
|
404 |
source.add('b') |
|
405 |
source.commit('Added b', rev_id='rev2') |
|
406 |
target.commit('empty commit') |
|
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
407 |
self.write_directive('directive', source.branch, 'target', 'rev2', |
408 |
'rev1') |
|
1551.19.22
by Aaron Bentley
Add warning when merge directives cause cherrypicks |
409 |
out, err = self.run_bzr('merge -d target directive') |
2520.4.110
by Aaron Bentley
Implement cherrypick support for merge directives |
410 |
self.failIfExists('target/a') |
411 |
self.failUnlessExists('target/b') |
|
1551.19.22
by Aaron Bentley
Add warning when merge directives cause cherrypicks |
412 |
self.assertContainsRe(err, 'Performing cherrypick') |
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
413 |
|
414 |
def write_directive(self, filename, source, target, revision_id, |
|
415 |
base_revision_id=None, mangle_patch=False): |
|
416 |
md = merge_directive.MergeDirective2.from_objects( |
|
2520.4.112
by Aaron Bentley
Make cherry-pick merge directives possible |
417 |
source.repository, revision_id, 0, 0, target, |
418 |
base_revision_id=base_revision_id) |
|
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
419 |
if mangle_patch: |
420 |
md.patch = 'asdf\n' |
|
421 |
self.build_tree_contents([(filename, ''.join(md.to_lines()))]) |
|
422 |
||
423 |
def test_directive_verify_warning(self): |
|
424 |
source = self.make_branch_and_tree('source') |
|
425 |
self.build_tree(['source/a']) |
|
426 |
source.add('a') |
|
427 |
source.commit('Added a', rev_id='rev1') |
|
428 |
target = self.make_branch_and_tree('target') |
|
429 |
target.commit('empty commit') |
|
430 |
self.write_directive('directive', source.branch, 'target', 'rev1') |
|
431 |
err = self.run_bzr('merge -d target directive')[1] |
|
432 |
self.assertNotContainsRe(err, 'Preview patch does not match changes') |
|
2748.3.2
by Aaron Bentley
Fix revert, remove-tree, and various tests to use None for 'no files specified' |
433 |
target.revert() |
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
434 |
self.write_directive('directive', source.branch, 'target', 'rev1', |
435 |
mangle_patch=True) |
|
436 |
err = self.run_bzr('merge -d target directive')[1] |
|
2520.7.1
by Aaron Bentley
Reactivate patch verification |
437 |
self.assertContainsRe(err, 'Preview patch does not match changes') |
1551.15.66
by Aaron Bentley
Improve behavior with revision ids |
438 |
|
439 |
def test_merge_arbitrary(self): |
|
440 |
target = self.make_branch_and_tree('target') |
|
441 |
target.commit('empty') |
|
442 |
# We need a revision that has no integer revno
|
|
443 |
branch_a = target.bzrdir.sprout('branch_a').open_workingtree() |
|
444 |
self.build_tree(['branch_a/file1']) |
|
445 |
branch_a.add('file1') |
|
446 |
branch_a.commit('added file1', rev_id='rev2a') |
|
447 |
branch_b = target.bzrdir.sprout('branch_b').open_workingtree() |
|
448 |
self.build_tree(['branch_b/file2']) |
|
449 |
branch_b.add('file2') |
|
450 |
branch_b.commit('added file2', rev_id='rev2b') |
|
451 |
branch_b.merge_from_branch(branch_a.branch) |
|
452 |
self.failUnlessExists('branch_b/file1') |
|
453 |
branch_b.commit('merged branch_a', rev_id='rev3b') |
|
454 |
||
455 |
# It works if the revid has an interger revno
|
|
456 |
self.run_bzr('merge -d target -r revid:rev2a branch_a') |
|
457 |
self.failUnlessExists('target/file1') |
|
458 |
self.failIfExists('target/file2') |
|
2748.3.2
by Aaron Bentley
Fix revert, remove-tree, and various tests to use None for 'no files specified' |
459 |
target.revert() |
1551.15.66
by Aaron Bentley
Improve behavior with revision ids |
460 |
|
461 |
# It should work if the revid has no integer revno
|
|
462 |
self.run_bzr('merge -d target -r revid:rev2a branch_b') |
|
463 |
self.failUnlessExists('target/file1') |
|
464 |
self.failIfExists('target/file2') |
|
2839.5.1
by Alexander Belchenko
add -c option to merge command |
465 |
|
466 |
def assertDirectoryContent(self, directory, entries, message=''): |
|
2839.5.2
by Alexander Belchenko
tweaks suggested by Ian |
467 |
"""Assert whether entries (file or directories) exist in a directory.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
468 |
|
2839.5.2
by Alexander Belchenko
tweaks suggested by Ian |
469 |
It also checks that there are no extra entries.
|
2839.5.1
by Alexander Belchenko
add -c option to merge command |
470 |
"""
|
2839.5.2
by Alexander Belchenko
tweaks suggested by Ian |
471 |
ondisk = os.listdir(directory) |
2839.5.1
by Alexander Belchenko
add -c option to merge command |
472 |
if set(ondisk) == set(entries): |
473 |
return
|
|
474 |
if message: |
|
475 |
message += '\n' |
|
476 |
raise AssertionError( |
|
477 |
'%s"%s" directory content is different:\na = %s\nb = %s\n' |
|
2839.5.2
by Alexander Belchenko
tweaks suggested by Ian |
478 |
% (message, directory, sorted(entries), sorted(ondisk))) |
2839.5.1
by Alexander Belchenko
add -c option to merge command |
479 |
|
480 |
def test_cherrypicking_merge(self): |
|
481 |
# make source branch
|
|
482 |
source = self.make_branch_and_tree('source') |
|
483 |
for f in ('a', 'b', 'c', 'd'): |
|
484 |
self.build_tree(['source/'+f]) |
|
485 |
source.add(f) |
|
486 |
source.commit('added '+f, rev_id='rev_'+f) |
|
487 |
# target branch
|
|
488 |
target = source.bzrdir.sprout('target', 'rev_a').open_workingtree() |
|
489 |
self.assertDirectoryContent('target', ['.bzr', 'a']) |
|
490 |
# pick 1 revision
|
|
491 |
self.run_bzr('merge -d target -r revid:rev_b..revid:rev_c source') |
|
492 |
self.assertDirectoryContent('target', ['.bzr', 'a', 'c']) |
|
493 |
target.revert() |
|
494 |
# pick 2 revisions
|
|
495 |
self.run_bzr('merge -d target -r revid:rev_b..revid:rev_d source') |
|
496 |
self.assertDirectoryContent('target', ['.bzr', 'a', 'c', 'd']) |
|
497 |
target.revert() |
|
498 |
# pick 1 revision with option --changes
|
|
499 |
self.run_bzr('merge -d target -c revid:rev_d source') |
|
500 |
self.assertDirectoryContent('target', ['.bzr', 'a', 'd']) |
|
1551.19.10
by Aaron Bentley
Merge now warns when it encounters a criss-cross |
501 |
|
502 |
def test_merge_criss_cross(self): |
|
503 |
tree_a = self.make_branch_and_tree('a') |
|
504 |
tree_a.commit('', rev_id='rev1') |
|
505 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
|
506 |
tree_a.commit('', rev_id='rev2a') |
|
507 |
tree_b.commit('', rev_id='rev2b') |
|
508 |
tree_a.merge_from_branch(tree_b.branch) |
|
509 |
tree_b.merge_from_branch(tree_a.branch) |
|
510 |
tree_a.commit('', rev_id='rev3a') |
|
511 |
tree_b.commit('', rev_id='rev3b') |
|
512 |
graph = tree_a.branch.repository.get_graph(tree_b.branch.repository) |
|
513 |
out, err = self.run_bzr(['merge', '-d', 'a', 'b']) |
|
514 |
self.assertContainsRe(err, 'Warning: criss-cross merge encountered.') |
|
3062.2.5
by Aaron Bentley
Merge bzr.dev |
515 |
|
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
516 |
def test_merge_from_submit(self): |
517 |
tree_a = self.make_branch_and_tree('a') |
|
518 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
|
519 |
tree_c = tree_a.bzrdir.sprout('c').open_workingtree() |
|
520 |
out, err = self.run_bzr(['merge', '-d', 'c']) |
|
3596.3.1
by James Westby
Give the user a bit more information about which saved location is being used. |
521 |
self.assertContainsRe(err, 'Merging from remembered parent location .*a\/') |
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
522 |
tree_c.branch.set_submit_branch(tree_b.bzrdir.root_transport.base) |
523 |
out, err = self.run_bzr(['merge', '-d', 'c']) |
|
3596.3.1
by James Westby
Give the user a bit more information about which saved location is being used. |
524 |
self.assertContainsRe(err, 'Merging from remembered submit location .*b\/') |
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
525 |
|
526 |
def test_remember_sets_submit(self): |
|
527 |
tree_a = self.make_branch_and_tree('a') |
|
528 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
|
529 |
self.assertIs(tree_b.branch.get_submit_branch(), None) |
|
530 |
||
531 |
# Remember should not happen if using default from parent
|
|
532 |
out, err = self.run_bzr(['merge', '-d', 'b']) |
|
533 |
self.assertIs(tree_b.branch.get_submit_branch(), None) |
|
534 |
||
535 |
# Remember should happen if user supplies location
|
|
536 |
out, err = self.run_bzr(['merge', '-d', 'b', 'a']) |
|
537 |
self.assertEqual(tree_b.branch.get_submit_branch(), |
|
538 |
tree_a.bzrdir.root_transport.base) |
|
1551.19.25
by Aaron Bentley
Merge bzr.dev |
539 |
|
3062.2.4
by Aaron Bentley
Start supporting merge-with-base |
540 |
def test_weave_cherrypick(self): |
541 |
this_tree = self.make_branch_and_tree('this') |
|
542 |
self.build_tree_contents([('this/file', "a\n")]) |
|
543 |
this_tree.add('file') |
|
544 |
this_tree.commit('rev1') |
|
545 |
other_tree = this_tree.bzrdir.sprout('other').open_workingtree() |
|
546 |
self.build_tree_contents([('other/file', "a\nb\n")]) |
|
547 |
other_tree.commit('rev2b') |
|
548 |
self.build_tree_contents([('other/file', "c\na\nb\n")]) |
|
549 |
other_tree.commit('rev3b') |
|
3062.2.6
by Aaron Bentley
Get cherrypick-on-weave working |
550 |
self.run_bzr('merge --weave -d this other -r -2..-1') |
3062.2.4
by Aaron Bentley
Start supporting merge-with-base |
551 |
self.assertFileEqual('c\na\n', 'this/file') |
3008.1.24
by Aaron Bentley
Add merge --preview to show diff |
552 |
|
3144.3.1
by Aaron Bentley
Implement LCA merge, with problematic conflict markers |
553 |
def test_lca_merge_criss_cross(self): |
554 |
tree_a = self.make_branch_and_tree('a') |
|
555 |
self.build_tree_contents([('a/file', 'base-contents\n')]) |
|
556 |
tree_a.add('file') |
|
557 |
tree_a.commit('', rev_id='rev1') |
|
558 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
|
559 |
self.build_tree_contents([('a/file', |
|
560 |
'base-contents\nthis-contents\n')]) |
|
561 |
tree_a.commit('', rev_id='rev2a') |
|
562 |
self.build_tree_contents([('b/file', |
|
563 |
'base-contents\nother-contents\n')]) |
|
564 |
tree_b.commit('', rev_id='rev2b') |
|
565 |
tree_a.merge_from_branch(tree_b.branch) |
|
566 |
self.build_tree_contents([('a/file', |
|
567 |
'base-contents\nthis-contents\n')]) |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
568 |
tree_a.set_conflicts(conflicts.ConflictList()) |
3144.3.1
by Aaron Bentley
Implement LCA merge, with problematic conflict markers |
569 |
tree_b.merge_from_branch(tree_a.branch) |
570 |
self.build_tree_contents([('b/file', |
|
571 |
'base-contents\nother-contents\n')]) |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
572 |
tree_b.set_conflicts(conflicts.ConflictList()) |
3144.3.1
by Aaron Bentley
Implement LCA merge, with problematic conflict markers |
573 |
tree_a.commit('', rev_id='rev3a') |
574 |
tree_b.commit('', rev_id='rev3b') |
|
575 |
out, err = self.run_bzr(['merge', '-d', 'a', 'b', '--lca'], retcode=1) |
|
576 |
self.assertFileEqual('base-contents\n<<<<<<< TREE\nthis-contents\n' |
|
3144.3.2
by Aaron Bentley
Get conflict handling working |
577 |
'=======\nother-contents\n>>>>>>> MERGE-SOURCE\n', |
3144.3.1
by Aaron Bentley
Implement LCA merge, with problematic conflict markers |
578 |
'a/file') |
3008.1.27
by Aaron Bentley
Merge bzr.dev |
579 |
|
3008.1.24
by Aaron Bentley
Add merge --preview to show diff |
580 |
def test_merge_preview(self): |
581 |
this_tree = self.make_branch_and_tree('this') |
|
582 |
this_tree.commit('rev1') |
|
583 |
other_tree = this_tree.bzrdir.sprout('other').open_workingtree() |
|
584 |
self.build_tree_contents([('other/file', 'new line')]) |
|
585 |
other_tree.add('file') |
|
586 |
other_tree.commit('rev2a') |
|
587 |
this_tree.commit('rev2b') |
|
588 |
out, err = self.run_bzr(['merge', '-d', 'this', 'other', '--preview']) |
|
589 |
self.assertContainsRe(out, '\+new line') |
|
590 |
self.assertNotContainsRe(err, '\+N file\n') |
|
591 |
this_tree.lock_read() |
|
592 |
self.addCleanup(this_tree.unlock) |
|
593 |
self.assertEqual([], |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
594 |
list(this_tree.iter_changes(this_tree.basis_tree()))) |
4435.1.1
by Aaron Bentley
Correctly fall back to basis when no second revision specified. |
595 |
|
596 |
def test_merge_missing_second_revision_spec(self): |
|
4435.1.4
by Aaron Bentley
Fix tabs. |
597 |
"""Merge uses branch basis when the second revision is unspecified."""
|
598 |
this = self.make_branch_and_tree('this') |
|
599 |
this.commit('rev1') |
|
600 |
other = self.make_branch_and_tree('other') |
|
601 |
self.build_tree(['other/other_file']) |
|
602 |
other.add('other_file') |
|
603 |
other.commit('rev1b') |
|
604 |
self.run_bzr('merge -d this other -r0..') |
|
605 |
self.failUnlessExists('this/other_file') |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
606 |
|
4832.2.1
by Aaron Bentley
Ensure merge -i doesn't leave branch write_locked. |
607 |
def test_merge_interactive_unlocks_branch(self): |
608 |
this = self.make_branch_and_tree('this') |
|
609 |
other = self.make_branch_and_tree('other') |
|
610 |
other.commit('empty commit') |
|
611 |
self.run_bzr('merge -i -d this other') |
|
612 |
this.lock_write() |
|
613 |
this.unlock() |
|
614 |
||
4792.7.1
by Martin
Ensure files that are opened as potential bundles but turn out not to be get closed |
615 |
def test_merge_reversed_revision_range(self): |
616 |
tree = self.make_branch_and_tree(".") |
|
617 |
for f in ("a", "b"): |
|
618 |
self.build_tree([f]) |
|
619 |
tree.add(f) |
|
620 |
tree.commit("added "+f) |
|
621 |
for context in (".", "", "a"): |
|
622 |
self.run_bzr("merge -r 1..0 " + context) |
|
623 |
self.failIfExists("a") |
|
624 |
tree.revert() |
|
625 |
self.failUnlessExists("a") |
|
626 |
||
5535.3.30
by Andrew Bennetts
Fetch tags during merge too. |
627 |
def test_merge_fetches_tags(self): |
628 |
"""Tags are updated by merge, and revisions named in those tags are
|
|
629 |
fetched.
|
|
630 |
"""
|
|
631 |
# Make a source, sprout a target off it
|
|
632 |
builder = self.make_branch_builder('source') |
|
633 |
builder.build_commit(message="Rev 1", rev_id='rev-1') |
|
634 |
source = builder.get_branch() |
|
635 |
target_bzrdir = source.bzrdir.sprout('target') |
|
636 |
# Add a non-ancestry tag to source
|
|
637 |
builder.build_commit(message="Rev 2a", rev_id='rev-2a') |
|
638 |
source.tags.set_tag('tag-a', 'rev-2a') |
|
639 |
source.set_last_revision_info(1, 'rev-1') |
|
640 |
builder.build_commit(message="Rev 2b", rev_id='rev-2b') |
|
641 |
# Merge from source
|
|
642 |
self.run_bzr('merge -d target source') |
|
643 |
target = target_bzrdir.open_branch() |
|
644 |
# The tag is present, and so is its revision.
|
|
645 |
self.assertEqual('rev-2a', target.tags.lookup_tag('tag-a')) |
|
646 |
target.repository.get_revision('rev-2a') |
|
647 |
||
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
648 |
|
4672.3.2
by Vincent Ladeuil
Don't allow merge on top of pending merges without --force. |
649 |
class TestMergeForce(tests.TestCaseWithTransport): |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
650 |
|
4672.3.2
by Vincent Ladeuil
Don't allow merge on top of pending merges without --force. |
651 |
def setUp(self): |
652 |
super(TestMergeForce, self).setUp() |
|
653 |
self.tree_a = self.make_branch_and_tree('a') |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
654 |
self.build_tree(['a/foo']) |
4672.3.2
by Vincent Ladeuil
Don't allow merge on top of pending merges without --force. |
655 |
self.tree_a.add(['foo']) |
656 |
self.tree_a.commit('add file') |
|
657 |
self.tree_b = self.tree_a.bzrdir.sprout('b').open_workingtree() |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
658 |
self.build_tree_contents([('a/foo', 'change 1')]) |
4672.3.2
by Vincent Ladeuil
Don't allow merge on top of pending merges without --force. |
659 |
self.tree_a.commit('change file') |
660 |
self.tree_b.merge_from_branch(self.tree_a.branch) |
|
661 |
||
662 |
def test_merge_force(self): |
|
663 |
self.tree_a.commit('empty change to allow merge to run') |
|
4721.3.2
by Vincent Ladeuil
Simplify mutable_tree.has_changes() and update call sites. |
664 |
# Second merge on top of the uncommitted one
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
665 |
self.run_bzr(['merge', '../a', '--force'], working_dir='b') |
666 |
||
667 |
||
4672.3.2
by Vincent Ladeuil
Don't allow merge on top of pending merges without --force. |
668 |
def test_merge_with_uncommitted_changes(self): |
669 |
self.run_bzr_error(['Working tree .* has uncommitted changes'], |
|
670 |
['merge', '../a'], working_dir='b') |
|
671 |
||
672 |
def test_merge_with_pending_merges(self): |
|
673 |
# Revert the changes keeping the pending merge
|
|
674 |
self.run_bzr(['revert', 'b']) |
|
675 |
self.run_bzr_error(['Working tree .* has uncommitted changes'], |
|
676 |
['merge', '../a'], working_dir='b') |