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 |
conflicts, |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
30 |
controldir, |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
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): |
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
78 |
d = controldir.ControlDir.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') |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
281 |
# re-open branch as external run_bzr modified it
|
282 |
branch_b = branch_b.bzrdir.open_branch() |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
283 |
self.assertEquals(osutils.abspath(branch_b.get_submit_branch()), |
284 |
osutils.abspath(parent)) |
|
4037.2.5
by Roberto Aguilar
Updating tests for uncommitted changes. |
285 |
# 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. |
286 |
self.build_tree(['branch_b/e']) |
4037.2.5
by Roberto Aguilar
Updating tests for uncommitted changes. |
287 |
tree_b.add('e') |
288 |
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. |
289 |
out, err = self.run_bzr('merge', working_dir='branch_b') |
290 |
self.assertStartsWith( |
|
291 |
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 |
292 |
# re-open tree as external run_bzr modified it
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
293 |
tree_b = branch_b.bzrdir.open_workingtree() |
294 |
tree_b.commit('merge branch_a') |
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
295 |
# 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. |
296 |
out, err = self.run_bzr('merge ../branch_c --remember', |
297 |
working_dir='branch_b') |
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
298 |
self.assertEquals(out, '') |
1551.11.11
by Aaron Bentley
Get tests passing |
299 |
self.assertEquals(err, '+N c\nAll changes applied successfully.\n') |
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
300 |
# re-open branch as external run_bzr modified it
|
301 |
branch_b = branch_b.bzrdir.open_branch() |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
302 |
self.assertEquals(osutils.abspath(branch_b.get_submit_branch()), |
303 |
osutils.abspath(branch_c.bzrdir.root_transport.base)) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
304 |
# re-open tree as external run_bzr modified it
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
305 |
tree_b = branch_b.bzrdir.open_workingtree() |
306 |
tree_b.commit('merge branch_c') |
|
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
307 |
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
308 |
def test_merge_bundle(self): |
1185.82.33
by Aaron Bentley
Strengthen tests |
309 |
from bzrlib.testament import Testament |
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
310 |
tree_a = self.make_branch_and_tree('branch_a') |
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
311 |
self.build_tree_contents([('branch_a/a', 'hello')]) |
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
312 |
tree_a.add('a') |
313 |
tree_a.commit('message') |
|
314 |
||
315 |
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. |
316 |
self.build_tree_contents([('branch_a/a', 'hey there')]) |
1185.82.23
by Aaron Bentley
Switch the fetcher |
317 |
tree_a.commit('message') |
318 |
||
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
319 |
self.build_tree_contents([('branch_b/a', 'goodbye')]) |
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
320 |
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. |
321 |
self.run_bzr('bundle ../branch_a -o ../bundle', working_dir='branch_b') |
322 |
self.run_bzr('merge ../bundle', retcode=1, working_dir='branch_a') |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
323 |
testament_a = Testament.from_revision(tree_a.branch.repository, |
324 |
tree_b.get_parent_ids()[0]) |
|
1185.82.33
by Aaron Bentley
Strengthen tests |
325 |
testament_b = Testament.from_revision(tree_b.branch.repository, |
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
326 |
tree_b.get_parent_ids()[0]) |
1185.82.33
by Aaron Bentley
Strengthen tests |
327 |
self.assertEqualDiff(testament_a.as_text(), |
328 |
testament_b.as_text()) |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
329 |
tree_a.set_conflicts(conflicts.ConflictList()) |
1185.82.141
by Aaron Bentley
Ensure bzr works when you merge an already-merged bundle |
330 |
tree_a.commit('message') |
331 |
# 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. |
332 |
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 |
333 |
# but it does nothing
|
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
334 |
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. |
335 |
self.assertEqual('Nothing to do.\n', err) |
1910.1.1
by Aaron Bentley
Merge takes --uncommitted parameter |
336 |
|
337 |
def test_merge_uncommitted(self): |
|
338 |
"""Check that merge --uncommitted behaves properly"""
|
|
339 |
tree_a = self.make_branch_and_tree('a') |
|
340 |
self.build_tree(['a/file_1', 'a/file_2']) |
|
341 |
tree_a.add(['file_1', 'file_2']) |
|
342 |
tree_a.commit('commit 1') |
|
343 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
344 |
self.assertPathExists('b/file_1') |
1910.1.1
by Aaron Bentley
Merge takes --uncommitted parameter |
345 |
tree_a.rename_one('file_1', 'file_i') |
346 |
tree_a.commit('commit 2') |
|
347 |
tree_a.rename_one('file_2', 'file_ii') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
348 |
self.run_bzr('merge a --uncommitted -d b') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
349 |
self.assertPathExists('b/file_1') |
350 |
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' |
351 |
tree_b.revert() |
2279.3.1
by mbp at sourcefrog
Add a -d option to push, pull, merge (ported from tags branch) |
352 |
self.run_bzr_error(('Cannot use --uncommitted and --revision',), |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
353 |
'merge /a --uncommitted -r1 -d b') |
2149.2.1
by Jan Hudec
Option --pull for merge command. |
354 |
|
3017.3.1
by Aaron Bentley
merge --uncommit can now specify single files (#136890) |
355 |
def test_merge_uncommitted_file(self): |
356 |
"""It should be possible to merge changes from a single file."""
|
|
357 |
tree_a = self.make_branch_and_tree('tree_a') |
|
358 |
tree_a.commit('initial commit') |
|
359 |
tree_a.bzrdir.sprout('tree_b') |
|
360 |
self.build_tree(['tree_a/file1', 'tree_a/file2']) |
|
361 |
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. |
362 |
self.run_bzr(['merge', '--uncommitted', '../tree_a/file1'], |
363 |
working_dir='tree_b') |
|
364 |
self.assertPathExists('tree_b/file1') |
|
365 |
self.assertPathDoesNotExist('tree_b/file2') |
|
3017.3.1
by Aaron Bentley
merge --uncommit can now specify single files (#136890) |
366 |
|
5887.2.1
by Jonathan Riddell
give an error when trying to merge a non existent file |
367 |
def test_merge_nonexistent_file(self): |
368 |
"""It should not be possible to merge changes from a file which
|
|
369 |
does not exist."""
|
|
370 |
tree_a = self.make_branch_and_tree('tree_a') |
|
5887.2.7
by Jonathan Riddell
fix test for no empty branches |
371 |
self.build_tree_contents([('tree_a/file', 'bar\n')]) |
372 |
tree_a.add(['file']) |
|
373 |
tree_a.commit('commit 1') |
|
5887.3.1
by Vincent Ladeuil
Simplify code and fix the test. |
374 |
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. |
375 |
['merge', 'non/existing'], working_dir='tree_a') |
5887.2.1
by Jonathan Riddell
give an error when trying to merge a non existent file |
376 |
|
2149.2.1
by Jan Hudec
Option --pull for merge command. |
377 |
def pullable_branch(self): |
378 |
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' |
379 |
self.build_tree_contents([('a/file', 'bar\n')]) |
2149.2.1
by Jan Hudec
Option --pull for merge command. |
380 |
tree_a.add(['file']) |
381 |
self.id1 = tree_a.commit('commit 1') |
|
2664.12.1
by Daniel Watkins
tests.blackbox.test_merge now uses internals where appropriate. |
382 |
|
2149.2.1
by Jan Hudec
Option --pull for merge command. |
383 |
tree_b = self.make_branch_and_tree('b') |
384 |
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' |
385 |
self.build_tree_contents([('b/file', 'foo\n')]) |
2149.2.1
by Jan Hudec
Option --pull for merge command. |
386 |
self.id2 = tree_b.commit('commit 2') |
387 |
||
388 |
def test_merge_pull(self): |
|
389 |
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. |
390 |
(out, err) = self.run_bzr('merge --pull ../b', working_dir='a') |
1551.15.67
by Aaron Bentley
Stop using _merge_helper for merging |
391 |
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. |
392 |
tree_a = workingtree.WorkingTree.open('a') |
2149.2.1
by Jan Hudec
Option --pull for merge command. |
393 |
self.assertEqual([self.id2], tree_a.get_parent_ids()) |
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
394 |
|
4797.86.1
by John Arbash Meinel
Fix bug #760152, 'bzr merge --pull --preview' should just be 'bzr merge --preview' |
395 |
def test_merge_pull_preview(self): |
396 |
self.pullable_branch() |
|
397 |
(out, err) = self.run_bzr('merge --pull --preview -d a b') |
|
398 |
self.assertThat(out, matchers.DocTestMatches( |
|
399 |
"""=== modified file 'file'
|
|
400 |
--- file\t...
|
|
401 |
+++ file\t...
|
|
402 |
@@ -1,1 +1,1 @@
|
|
403 |
-bar
|
|
404 |
+foo
|
|
405 |
||
406 |
""", doctest.ELLIPSIS | doctest.REPORT_UDIFF)) |
|
407 |
tree_a = workingtree.WorkingTree.open('a') |
|
408 |
self.assertEqual([self.id1], tree_a.get_parent_ids()) |
|
409 |
||
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
410 |
def test_merge_kind_change(self): |
411 |
tree_a = self.make_branch_and_tree('tree_a') |
|
412 |
self.build_tree_contents([('tree_a/file', 'content_1')]) |
|
413 |
tree_a.add('file', 'file-id') |
|
414 |
tree_a.commit('added file') |
|
415 |
tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree() |
|
416 |
os.unlink('tree_a/file') |
|
417 |
self.build_tree(['tree_a/file/']) |
|
418 |
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. |
419 |
self.run_bzr('merge ../tree_a', working_dir='tree_b') |
420 |
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' |
421 |
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. |
422 |
self.assertEqual('file', osutils.file_kind('tree_b/file')) |
423 |
self.build_tree_contents([('tree_b/file', 'content_2')]) |
|
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
424 |
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. |
425 |
self.run_bzr('merge ../tree_a', retcode=1, working_dir='tree_b') |
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
426 |
self.assertEqual(tree_b.conflicts(), |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
427 |
[conflicts.ContentsConflict('file', |
428 |
file_id='file-id')]) |
|
2520.4.109
by Aaron Bentley
start work on directive cherry-picking |
429 |
|
430 |
def test_directive_cherrypick(self): |
|
431 |
source = self.make_branch_and_tree('source') |
|
4593.1.1
by Martin Pool
Merge directive tests must use trees with the same root id. |
432 |
source.commit("nothing") |
5243.1.2
by Martin
Point launchpad links in comments at production server rather than edge |
433 |
# 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. |
434 |
# cherrypick from one branch into another unrelated branch with a
|
435 |
# different root id will give shape conflicts. as a workaround we
|
|
436 |
# make sure they share the same root id.
|
|
437 |
target = source.bzrdir.sprout('target').open_workingtree() |
|
2520.4.109
by Aaron Bentley
start work on directive cherry-picking |
438 |
self.build_tree(['source/a']) |
439 |
source.add('a') |
|
440 |
source.commit('Added a', rev_id='rev1') |
|
441 |
self.build_tree(['source/b']) |
|
442 |
source.add('b') |
|
443 |
source.commit('Added b', rev_id='rev2') |
|
444 |
target.commit('empty commit') |
|
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
445 |
self.write_directive('directive', source.branch, 'target', 'rev2', |
446 |
'rev1') |
|
1551.19.22
by Aaron Bentley
Add warning when merge directives cause cherrypicks |
447 |
out, err = self.run_bzr('merge -d target directive') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
448 |
self.assertPathDoesNotExist('target/a') |
449 |
self.assertPathExists('target/b') |
|
1551.19.22
by Aaron Bentley
Add warning when merge directives cause cherrypicks |
450 |
self.assertContainsRe(err, 'Performing cherrypick') |
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
451 |
|
452 |
def write_directive(self, filename, source, target, revision_id, |
|
453 |
base_revision_id=None, mangle_patch=False): |
|
454 |
md = merge_directive.MergeDirective2.from_objects( |
|
2520.4.112
by Aaron Bentley
Make cherry-pick merge directives possible |
455 |
source.repository, revision_id, 0, 0, target, |
456 |
base_revision_id=base_revision_id) |
|
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
457 |
if mangle_patch: |
458 |
md.patch = 'asdf\n' |
|
459 |
self.build_tree_contents([(filename, ''.join(md.to_lines()))]) |
|
460 |
||
461 |
def test_directive_verify_warning(self): |
|
462 |
source = self.make_branch_and_tree('source') |
|
463 |
self.build_tree(['source/a']) |
|
464 |
source.add('a') |
|
465 |
source.commit('Added a', rev_id='rev1') |
|
466 |
target = self.make_branch_and_tree('target') |
|
467 |
target.commit('empty commit') |
|
468 |
self.write_directive('directive', source.branch, 'target', 'rev1') |
|
469 |
err = self.run_bzr('merge -d target directive')[1] |
|
470 |
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' |
471 |
target.revert() |
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
472 |
self.write_directive('directive', source.branch, 'target', 'rev1', |
473 |
mangle_patch=True) |
|
474 |
err = self.run_bzr('merge -d target directive')[1] |
|
2520.7.1
by Aaron Bentley
Reactivate patch verification |
475 |
self.assertContainsRe(err, 'Preview patch does not match changes') |
1551.15.66
by Aaron Bentley
Improve behavior with revision ids |
476 |
|
477 |
def test_merge_arbitrary(self): |
|
478 |
target = self.make_branch_and_tree('target') |
|
479 |
target.commit('empty') |
|
480 |
# We need a revision that has no integer revno
|
|
481 |
branch_a = target.bzrdir.sprout('branch_a').open_workingtree() |
|
482 |
self.build_tree(['branch_a/file1']) |
|
483 |
branch_a.add('file1') |
|
484 |
branch_a.commit('added file1', rev_id='rev2a') |
|
485 |
branch_b = target.bzrdir.sprout('branch_b').open_workingtree() |
|
486 |
self.build_tree(['branch_b/file2']) |
|
487 |
branch_b.add('file2') |
|
488 |
branch_b.commit('added file2', rev_id='rev2b') |
|
489 |
branch_b.merge_from_branch(branch_a.branch) |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
490 |
self.assertPathExists('branch_b/file1') |
1551.15.66
by Aaron Bentley
Improve behavior with revision ids |
491 |
branch_b.commit('merged branch_a', rev_id='rev3b') |
492 |
||
493 |
# It works if the revid has an interger revno
|
|
494 |
self.run_bzr('merge -d target -r revid:rev2a branch_a') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
495 |
self.assertPathExists('target/file1') |
496 |
self.assertPathDoesNotExist('target/file2') |
|
2748.3.2
by Aaron Bentley
Fix revert, remove-tree, and various tests to use None for 'no files specified' |
497 |
target.revert() |
1551.15.66
by Aaron Bentley
Improve behavior with revision ids |
498 |
|
499 |
# It should work if the revid has no integer revno
|
|
500 |
self.run_bzr('merge -d target -r revid:rev2a branch_b') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
501 |
self.assertPathExists('target/file1') |
502 |
self.assertPathDoesNotExist('target/file2') |
|
2839.5.1
by Alexander Belchenko
add -c option to merge command |
503 |
|
504 |
def assertDirectoryContent(self, directory, entries, message=''): |
|
2839.5.2
by Alexander Belchenko
tweaks suggested by Ian |
505 |
"""Assert whether entries (file or directories) exist in a directory.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
506 |
|
2839.5.2
by Alexander Belchenko
tweaks suggested by Ian |
507 |
It also checks that there are no extra entries.
|
2839.5.1
by Alexander Belchenko
add -c option to merge command |
508 |
"""
|
2839.5.2
by Alexander Belchenko
tweaks suggested by Ian |
509 |
ondisk = os.listdir(directory) |
2839.5.1
by Alexander Belchenko
add -c option to merge command |
510 |
if set(ondisk) == set(entries): |
511 |
return
|
|
512 |
if message: |
|
513 |
message += '\n' |
|
514 |
raise AssertionError( |
|
515 |
'%s"%s" directory content is different:\na = %s\nb = %s\n' |
|
2839.5.2
by Alexander Belchenko
tweaks suggested by Ian |
516 |
% (message, directory, sorted(entries), sorted(ondisk))) |
2839.5.1
by Alexander Belchenko
add -c option to merge command |
517 |
|
518 |
def test_cherrypicking_merge(self): |
|
519 |
# make source branch
|
|
520 |
source = self.make_branch_and_tree('source') |
|
521 |
for f in ('a', 'b', 'c', 'd'): |
|
522 |
self.build_tree(['source/'+f]) |
|
523 |
source.add(f) |
|
524 |
source.commit('added '+f, rev_id='rev_'+f) |
|
525 |
# target branch
|
|
526 |
target = source.bzrdir.sprout('target', 'rev_a').open_workingtree() |
|
527 |
self.assertDirectoryContent('target', ['.bzr', 'a']) |
|
528 |
# pick 1 revision
|
|
529 |
self.run_bzr('merge -d target -r revid:rev_b..revid:rev_c source') |
|
530 |
self.assertDirectoryContent('target', ['.bzr', 'a', 'c']) |
|
531 |
target.revert() |
|
532 |
# pick 2 revisions
|
|
533 |
self.run_bzr('merge -d target -r revid:rev_b..revid:rev_d source') |
|
534 |
self.assertDirectoryContent('target', ['.bzr', 'a', 'c', 'd']) |
|
535 |
target.revert() |
|
536 |
# pick 1 revision with option --changes
|
|
537 |
self.run_bzr('merge -d target -c revid:rev_d source') |
|
538 |
self.assertDirectoryContent('target', ['.bzr', 'a', 'd']) |
|
1551.19.10
by Aaron Bentley
Merge now warns when it encounters a criss-cross |
539 |
|
540 |
def test_merge_criss_cross(self): |
|
541 |
tree_a = self.make_branch_and_tree('a') |
|
542 |
tree_a.commit('', rev_id='rev1') |
|
543 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
|
544 |
tree_a.commit('', rev_id='rev2a') |
|
545 |
tree_b.commit('', rev_id='rev2b') |
|
546 |
tree_a.merge_from_branch(tree_b.branch) |
|
547 |
tree_b.merge_from_branch(tree_a.branch) |
|
548 |
tree_a.commit('', rev_id='rev3a') |
|
549 |
tree_b.commit('', rev_id='rev3b') |
|
550 |
graph = tree_a.branch.repository.get_graph(tree_b.branch.repository) |
|
551 |
out, err = self.run_bzr(['merge', '-d', 'a', 'b']) |
|
552 |
self.assertContainsRe(err, 'Warning: criss-cross merge encountered.') |
|
3062.2.5
by Aaron Bentley
Merge bzr.dev |
553 |
|
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
554 |
def test_merge_from_submit(self): |
555 |
tree_a = self.make_branch_and_tree('a') |
|
5863.5.1
by Jonathan Riddell
add an error message when merging into empty branch |
556 |
tree_a.commit('test') |
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
557 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
558 |
tree_c = tree_a.bzrdir.sprout('c').open_workingtree() |
|
559 |
out, err = self.run_bzr(['merge', '-d', 'c']) |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
560 |
self.assertContainsRe(err, |
561 |
'Merging from remembered parent location .*a\/') |
|
562 |
tree_c.branch.lock_write() |
|
563 |
try: |
|
564 |
tree_c.branch.set_submit_branch(tree_b.bzrdir.root_transport.base) |
|
565 |
finally: |
|
566 |
tree_c.branch.unlock() |
|
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
567 |
out, err = self.run_bzr(['merge', '-d', 'c']) |
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
568 |
self.assertContainsRe(err, |
569 |
'Merging from remembered submit location .*b\/') |
|
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
570 |
|
571 |
def test_remember_sets_submit(self): |
|
572 |
tree_a = self.make_branch_and_tree('a') |
|
5863.5.1
by Jonathan Riddell
add an error message when merging into empty branch |
573 |
tree_a.commit('rev1') |
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
574 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
575 |
self.assertIs(tree_b.branch.get_submit_branch(), None) |
|
576 |
||
577 |
# Remember should not happen if using default from parent
|
|
578 |
out, err = self.run_bzr(['merge', '-d', 'b']) |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
579 |
refreshed = workingtree.WorkingTree.open('b') |
580 |
self.assertIs(refreshed.branch.get_submit_branch(), None) |
|
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
581 |
|
582 |
# Remember should happen if user supplies location
|
|
583 |
out, err = self.run_bzr(['merge', '-d', 'b', 'a']) |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
584 |
refreshed = workingtree.WorkingTree.open('b') |
585 |
self.assertEqual(refreshed.branch.get_submit_branch(), |
|
1551.20.2
by Aaron Bentley
Merge prefers submit branch, but falls back to parent branch |
586 |
tree_a.bzrdir.root_transport.base) |
1551.19.25
by Aaron Bentley
Merge bzr.dev |
587 |
|
5861.1.1
by Vincent Ladeuil
Don't set submit_branch if it's not yet set when merging. |
588 |
def test_no_remember_dont_set_submit(self): |
589 |
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 |
590 |
self.build_tree_contents([('a/file', "a\n")]) |
591 |
tree_a.add('file') |
|
592 |
tree_a.commit('rev1') |
|
5861.1.1
by Vincent Ladeuil
Don't set submit_branch if it's not yet set when merging. |
593 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
594 |
self.assertIs(tree_b.branch.get_submit_branch(), None) |
|
595 |
||
596 |
# Remember should not happen if using default from parent
|
|
597 |
out, err = self.run_bzr(['merge', '-d', 'b', '--no-remember']) |
|
598 |
self.assertEquals(None, tree_b.branch.get_submit_branch()) |
|
599 |
||
600 |
# Remember should not happen if user supplies location but ask for not
|
|
601 |
# remembering it
|
|
602 |
out, err = self.run_bzr(['merge', '-d', 'b', '--no-remember', 'a']) |
|
603 |
self.assertEqual(None, tree_b.branch.get_submit_branch()) |
|
604 |
||
3062.2.4
by Aaron Bentley
Start supporting merge-with-base |
605 |
def test_weave_cherrypick(self): |
606 |
this_tree = self.make_branch_and_tree('this') |
|
607 |
self.build_tree_contents([('this/file', "a\n")]) |
|
608 |
this_tree.add('file') |
|
609 |
this_tree.commit('rev1') |
|
610 |
other_tree = this_tree.bzrdir.sprout('other').open_workingtree() |
|
611 |
self.build_tree_contents([('other/file', "a\nb\n")]) |
|
612 |
other_tree.commit('rev2b') |
|
613 |
self.build_tree_contents([('other/file', "c\na\nb\n")]) |
|
614 |
other_tree.commit('rev3b') |
|
3062.2.6
by Aaron Bentley
Get cherrypick-on-weave working |
615 |
self.run_bzr('merge --weave -d this other -r -2..-1') |
3062.2.4
by Aaron Bentley
Start supporting merge-with-base |
616 |
self.assertFileEqual('c\na\n', 'this/file') |
3008.1.24
by Aaron Bentley
Add merge --preview to show diff |
617 |
|
3144.3.1
by Aaron Bentley
Implement LCA merge, with problematic conflict markers |
618 |
def test_lca_merge_criss_cross(self): |
619 |
tree_a = self.make_branch_and_tree('a') |
|
620 |
self.build_tree_contents([('a/file', 'base-contents\n')]) |
|
621 |
tree_a.add('file') |
|
622 |
tree_a.commit('', rev_id='rev1') |
|
623 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
|
624 |
self.build_tree_contents([('a/file', |
|
625 |
'base-contents\nthis-contents\n')]) |
|
626 |
tree_a.commit('', rev_id='rev2a') |
|
627 |
self.build_tree_contents([('b/file', |
|
628 |
'base-contents\nother-contents\n')]) |
|
629 |
tree_b.commit('', rev_id='rev2b') |
|
630 |
tree_a.merge_from_branch(tree_b.branch) |
|
631 |
self.build_tree_contents([('a/file', |
|
632 |
'base-contents\nthis-contents\n')]) |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
633 |
tree_a.set_conflicts(conflicts.ConflictList()) |
3144.3.1
by Aaron Bentley
Implement LCA merge, with problematic conflict markers |
634 |
tree_b.merge_from_branch(tree_a.branch) |
635 |
self.build_tree_contents([('b/file', |
|
636 |
'base-contents\nother-contents\n')]) |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
637 |
tree_b.set_conflicts(conflicts.ConflictList()) |
3144.3.1
by Aaron Bentley
Implement LCA merge, with problematic conflict markers |
638 |
tree_a.commit('', rev_id='rev3a') |
639 |
tree_b.commit('', rev_id='rev3b') |
|
640 |
out, err = self.run_bzr(['merge', '-d', 'a', 'b', '--lca'], retcode=1) |
|
641 |
self.assertFileEqual('base-contents\n<<<<<<< TREE\nthis-contents\n' |
|
3144.3.2
by Aaron Bentley
Get conflict handling working |
642 |
'=======\nother-contents\n>>>>>>> MERGE-SOURCE\n', |
3144.3.1
by Aaron Bentley
Implement LCA merge, with problematic conflict markers |
643 |
'a/file') |
3008.1.27
by Aaron Bentley
Merge bzr.dev |
644 |
|
3008.1.24
by Aaron Bentley
Add merge --preview to show diff |
645 |
def test_merge_preview(self): |
646 |
this_tree = self.make_branch_and_tree('this') |
|
647 |
this_tree.commit('rev1') |
|
648 |
other_tree = this_tree.bzrdir.sprout('other').open_workingtree() |
|
649 |
self.build_tree_contents([('other/file', 'new line')]) |
|
650 |
other_tree.add('file') |
|
651 |
other_tree.commit('rev2a') |
|
652 |
this_tree.commit('rev2b') |
|
653 |
out, err = self.run_bzr(['merge', '-d', 'this', 'other', '--preview']) |
|
654 |
self.assertContainsRe(out, '\+new line') |
|
655 |
self.assertNotContainsRe(err, '\+N file\n') |
|
656 |
this_tree.lock_read() |
|
657 |
self.addCleanup(this_tree.unlock) |
|
658 |
self.assertEqual([], |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
659 |
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. |
660 |
|
661 |
def test_merge_missing_second_revision_spec(self): |
|
4435.1.4
by Aaron Bentley
Fix tabs. |
662 |
"""Merge uses branch basis when the second revision is unspecified."""
|
663 |
this = self.make_branch_and_tree('this') |
|
664 |
this.commit('rev1') |
|
665 |
other = self.make_branch_and_tree('other') |
|
666 |
self.build_tree(['other/other_file']) |
|
667 |
other.add('other_file') |
|
668 |
other.commit('rev1b') |
|
669 |
self.run_bzr('merge -d this other -r0..') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
670 |
self.assertPathExists('this/other_file') |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
671 |
|
4832.2.1
by Aaron Bentley
Ensure merge -i doesn't leave branch write_locked. |
672 |
def test_merge_interactive_unlocks_branch(self): |
673 |
this = self.make_branch_and_tree('this') |
|
5863.5.1
by Jonathan Riddell
add an error message when merging into empty branch |
674 |
this.commit('empty commit') |
675 |
other = this.bzrdir.sprout('other').open_workingtree() |
|
676 |
other.commit('empty commit 2') |
|
4832.2.1
by Aaron Bentley
Ensure merge -i doesn't leave branch write_locked. |
677 |
self.run_bzr('merge -i -d this other') |
678 |
this.lock_write() |
|
679 |
this.unlock() |
|
680 |
||
5535.3.30
by Andrew Bennetts
Fetch tags during merge too. |
681 |
def test_merge_fetches_tags(self): |
682 |
"""Tags are updated by merge, and revisions named in those tags are
|
|
683 |
fetched.
|
|
684 |
"""
|
|
685 |
# Make a source, sprout a target off it
|
|
686 |
builder = self.make_branch_builder('source') |
|
687 |
builder.build_commit(message="Rev 1", rev_id='rev-1') |
|
688 |
source = builder.get_branch() |
|
689 |
target_bzrdir = source.bzrdir.sprout('target') |
|
690 |
# Add a non-ancestry tag to source
|
|
691 |
builder.build_commit(message="Rev 2a", rev_id='rev-2a') |
|
692 |
source.tags.set_tag('tag-a', 'rev-2a') |
|
693 |
source.set_last_revision_info(1, 'rev-1') |
|
6404.1.1
by Vincent Ladeuil
Migrate branch.fetch_tags |
694 |
source.get_config_stack().set('branch.fetch_tags', True) |
5535.3.30
by Andrew Bennetts
Fetch tags during merge too. |
695 |
builder.build_commit(message="Rev 2b", rev_id='rev-2b') |
696 |
# Merge from source
|
|
697 |
self.run_bzr('merge -d target source') |
|
698 |
target = target_bzrdir.open_branch() |
|
699 |
# The tag is present, and so is its revision.
|
|
700 |
self.assertEqual('rev-2a', target.tags.lookup_tag('tag-a')) |
|
701 |
target.repository.get_revision('rev-2a') |
|
702 |
||
5954.6.2
by Vincent Ladeuil
Put the empty lines in the right file ;) |
703 |
|
5954.6.1
by Vincent Ladeuil
Rewrite the eager bb.test_merge.TestMerge.test_merge_reversed_revision_range test |
704 |
class TestMergeRevisionRange(tests.TestCaseWithTransport): |
705 |
||
706 |
scenarios = (('whole-tree', dict(context='.')), |
|
707 |
('file-only', dict(context='a'))) |
|
708 |
||
709 |
def setUp(self): |
|
710 |
super(TestMergeRevisionRange, self).setUp() |
|
711 |
self.tree = self.make_branch_and_tree(".") |
|
712 |
self.tree.commit('initial commit') |
|
713 |
for f in ("a", "b"): |
|
714 |
self.build_tree([f]) |
|
715 |
self.tree.add(f) |
|
716 |
self.tree.commit("added " + f) |
|
717 |
||
718 |
def test_merge_reversed_revision_range(self): |
|
719 |
self.run_bzr("merge -r 2..1 " + self.context) |
|
720 |
self.assertPathDoesNotExist("a") |
|
721 |
self.assertPathExists("b") |
|
722 |
||
723 |
||
5863.5.1
by Jonathan Riddell
add an error message when merging into empty branch |
724 |
class TestMergeScript(script.TestCaseWithTransportAndScript): |
725 |
def test_merge_empty_branch(self): |
|
726 |
source = self.make_branch_and_tree('source') |
|
727 |
self.build_tree(['source/a']) |
|
728 |
source.add('a') |
|
729 |
source.commit('Added a', rev_id='rev1') |
|
730 |
target = self.make_branch_and_tree('target') |
|
731 |
self.run_script("""\ |
|
732 |
$ bzr merge -d target source
|
|
733 |
2>bzr: ERROR: Merging into empty branches not currently supported, https://bugs.launchpad.net/bzr/+bug/308562
|
|
734 |
""") |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
735 |
|
4672.3.2
by Vincent Ladeuil
Don't allow merge on top of pending merges without --force. |
736 |
class TestMergeForce(tests.TestCaseWithTransport): |
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
737 |
|
4672.3.2
by Vincent Ladeuil
Don't allow merge on top of pending merges without --force. |
738 |
def setUp(self): |
739 |
super(TestMergeForce, self).setUp() |
|
740 |
self.tree_a = self.make_branch_and_tree('a') |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
741 |
self.build_tree(['a/foo']) |
4672.3.2
by Vincent Ladeuil
Don't allow merge on top of pending merges without --force. |
742 |
self.tree_a.add(['foo']) |
743 |
self.tree_a.commit('add file') |
|
744 |
self.tree_b = self.tree_a.bzrdir.sprout('b').open_workingtree() |
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
745 |
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. |
746 |
self.tree_a.commit('change file') |
747 |
self.tree_b.merge_from_branch(self.tree_a.branch) |
|
748 |
||
749 |
def test_merge_force(self): |
|
750 |
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. |
751 |
# Second merge on top of the uncommitted one
|
4672.3.1
by Vincent Ladeuil
Cleanup imports in blackbox/test_merge.py. |
752 |
self.run_bzr(['merge', '../a', '--force'], working_dir='b') |
753 |
||
754 |
||
4672.3.2
by Vincent Ladeuil
Don't allow merge on top of pending merges without --force. |
755 |
def test_merge_with_uncommitted_changes(self): |
756 |
self.run_bzr_error(['Working tree .* has uncommitted changes'], |
|
757 |
['merge', '../a'], working_dir='b') |
|
758 |
||
759 |
def test_merge_with_pending_merges(self): |
|
760 |
# Revert the changes keeping the pending merge
|
|
761 |
self.run_bzr(['revert', 'b']) |
|
762 |
self.run_bzr_error(['Working tree .* has uncommitted changes'], |
|
763 |
['merge', '../a'], working_dir='b') |