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