bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2279.3.1
by mbp at sourcefrog
Add a -d option to push, pull, merge (ported from tags branch) |
1 |
# Copyright (C) 2006, 2007 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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
16 |
#
|
17 |
# Author: Aaron Bentley <aaron.bentley@utoronto.ca>
|
|
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
18 |
|
19 |
"""Black-box tests for bzr merge.
|
|
20 |
"""
|
|
21 |
||
22 |
import os |
|
23 |
||
|
2520.4.109
by Aaron Bentley
start work on directive cherry-picking |
24 |
from bzrlib import merge_directive |
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
25 |
from bzrlib.branch import Branch |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
26 |
from bzrlib.bzrdir import BzrDir |
|
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
27 |
from bzrlib.conflicts import ConflictList, ContentsConflict |
28 |
from bzrlib.osutils import abspath, file_kind |
|
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
29 |
from bzrlib.tests.blackbox import ExternalBase |
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
30 |
import bzrlib.urlutils as urlutils |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
31 |
from bzrlib.workingtree import WorkingTree |
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
32 |
|
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
33 |
|
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
34 |
class TestMerge(ExternalBase): |
35 |
||
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
36 |
def example_branch(test): |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
37 |
test.run_bzr('init') |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
38 |
file('hello', 'wt').write('foo') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
39 |
test.run_bzr('add hello') |
40 |
test.run_bzr('commit -m setup hello') |
|
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
41 |
file('goodbye', 'wt').write('baz') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
42 |
test.run_bzr('add goodbye') |
43 |
test.run_bzr('commit -m setup goodbye') |
|
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
44 |
|
45 |
def test_merge_reprocess(self): |
|
46 |
d = BzrDir.create_standalone_workingtree('.') |
|
47 |
d.commit('h') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
48 |
self.run_bzr('merge . --reprocess --merge-type weave') |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
49 |
|
50 |
def test_merge(self): |
|
51 |
from bzrlib.branch import Branch |
|
52 |
||
53 |
os.mkdir('a') |
|
54 |
os.chdir('a') |
|
55 |
self.example_branch() |
|
|
1907.4.4
by Matthieu Moy
Explain the error messages in the code. |
56 |
ancestor = Branch.open('.').revno() |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
57 |
os.chdir('..') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
58 |
self.run_bzr('branch a b') |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
59 |
os.chdir('b') |
60 |
file('goodbye', 'wt').write('quux') |
|
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
61 |
self.run_bzr(['commit', '-m', "more u's are always good"]) |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
62 |
|
63 |
os.chdir('../a') |
|
64 |
file('hello', 'wt').write('quuux') |
|
65 |
# We can't merge when there are in-tree changes
|
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
66 |
self.run_bzr('merge ../b', retcode=3) |
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
67 |
a = WorkingTree.open('.') |
68 |
a_tip = a.commit("Like an epidemic of u's") |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
69 |
self.run_bzr('merge ../b -r last:1..last:1 --merge-type blooof', |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
70 |
retcode=3) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
71 |
self.run_bzr('merge ../b -r last:1..last:1 --merge-type merge3') |
72 |
self.run_bzr('revert --no-backup') |
|
73 |
self.run_bzr('merge ../b -r last:1..last:1 --merge-type weave') |
|
74 |
self.run_bzr('revert --no-backup') |
|
75 |
self.run_bzr('merge ../b -r last:1..last:1 --reprocess') |
|
76 |
self.run_bzr('revert --no-backup') |
|
77 |
self.run_bzr('merge ../b -r last:1') |
|
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
78 |
self.check_file_contents('goodbye', 'quux') |
79 |
# Merging a branch pulls its revision into the tree
|
|
80 |
b = Branch.open('../b') |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
81 |
b_tip = b.last_revision() |
82 |
self.failUnless(a.branch.repository.has_revision(b_tip)) |
|
83 |
self.assertEqual([a_tip, b_tip], a.get_parent_ids()) |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
84 |
self.run_bzr('revert --no-backup') |
85 |
out, err = self.run_bzr('merge -r revno:1:./hello', retcode=3) |
|
|
1907.4.13
by Matthieu Moy
Better testcase for revno:N:branch/path error. |
86 |
self.assertTrue("Not a branch" in err) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
87 |
self.run_bzr('merge -r revno:%d:./..revno:%d:../b' |
|
1907.4.12
by Matthieu Moy
Made merge work with two revisions in different branches. |
88 |
%(ancestor,b.revno())) |
|
1551.8.25
by Aaron Bentley
Fix deprecated use of pending_merges |
89 |
self.assertEquals(a.get_parent_ids(), |
90 |
[a.branch.last_revision(), b.last_revision()]) |
|
|
1907.4.12
by Matthieu Moy
Made merge work with two revisions in different branches. |
91 |
self.check_file_contents('goodbye', 'quux') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
92 |
self.run_bzr('revert --no-backup') |
93 |
self.run_bzr('merge -r revno:%d:../b'%b.revno()) |
|
|
1551.8.25
by Aaron Bentley
Fix deprecated use of pending_merges |
94 |
self.assertEquals(a.get_parent_ids(), |
95 |
[a.branch.last_revision(), b.last_revision()]) |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
96 |
a_tip = a.commit('merged') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
97 |
self.run_bzr('merge ../b -r last:1') |
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
98 |
self.assertEqual([a_tip], a.get_parent_ids()) |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
99 |
|
100 |
def test_merge_with_missing_file(self): |
|
101 |
"""Merge handles missing file conflicts""" |
|
102 |
os.mkdir('a') |
|
103 |
os.chdir('a') |
|
104 |
os.mkdir('sub') |
|
105 |
print >> file('sub/a.txt', 'wb'), "hello" |
|
106 |
print >> file('b.txt', 'wb'), "hello" |
|
107 |
print >> file('sub/c.txt', 'wb'), "hello" |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
108 |
self.run_bzr('init') |
109 |
self.run_bzr('add') |
|
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
110 |
self.run_bzr(['commit', '-m', 'added a']) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
111 |
self.run_bzr('branch . ../b') |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
112 |
print >> file('sub/a.txt', 'ab'), "there" |
113 |
print >> file('b.txt', 'ab'), "there" |
|
114 |
print >> file('sub/c.txt', 'ab'), "there" |
|
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
115 |
self.run_bzr(['commit', '-m', 'Added there']) |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
116 |
os.unlink('sub/a.txt') |
117 |
os.unlink('sub/c.txt') |
|
118 |
os.rmdir('sub') |
|
119 |
os.unlink('b.txt') |
|
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
120 |
self.run_bzr(['commit', '-m', 'Removed a.txt']) |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
121 |
os.chdir('../b') |
122 |
print >> file('sub/a.txt', 'ab'), "something" |
|
123 |
print >> file('b.txt', 'ab'), "something" |
|
124 |
print >> file('sub/c.txt', 'ab'), "something" |
|
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
125 |
self.run_bzr(['commit', '-m', 'Modified a.txt']) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
126 |
self.run_bzr('merge ../a/', retcode=1) |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
127 |
self.assert_(os.path.exists('sub/a.txt.THIS')) |
128 |
self.assert_(os.path.exists('sub/a.txt.BASE')) |
|
129 |
os.chdir('../a') |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
130 |
self.run_bzr('merge ../b/', retcode=1) |
|
1551.6.16
by Aaron Bentley
Merge from bzr.dev |
131 |
self.assert_(os.path.exists('sub/a.txt.OTHER')) |
132 |
self.assert_(os.path.exists('sub/a.txt.BASE')) |
|
133 |
||
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
134 |
def test_merge_remember(self): |
135 |
"""Merge changes from one branch to another and test parent location.""" |
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
136 |
tree_a = self.make_branch_and_tree('branch_a') |
137 |
branch_a = tree_a.branch |
|
138 |
self.build_tree(['branch_a/a']) |
|
139 |
tree_a.add('a') |
|
140 |
tree_a.commit('commit a') |
|
141 |
branch_b = branch_a.bzrdir.sprout('branch_b').open_branch() |
|
142 |
tree_b = branch_b.bzrdir.open_workingtree() |
|
143 |
branch_c = branch_a.bzrdir.sprout('branch_c').open_branch() |
|
144 |
tree_c = branch_c.bzrdir.open_workingtree() |
|
145 |
self.build_tree(['branch_a/b']) |
|
146 |
tree_a.add('b') |
|
147 |
tree_a.commit('commit b') |
|
148 |
self.build_tree(['branch_c/c']) |
|
149 |
tree_c.add('c') |
|
150 |
tree_c.commit('commit c') |
|
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
151 |
# reset parent
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
152 |
parent = branch_b.get_parent() |
153 |
branch_b.set_parent(None) |
|
154 |
self.assertEqual(None, branch_b.get_parent()) |
|
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
155 |
# test merge for failure without parent set
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
156 |
os.chdir('branch_b') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
157 |
out = self.run_bzr('merge', retcode=3) |
|
1614.2.5
by Olaf Conradi
Added testcase for bzr merge --remember. |
158 |
self.assertEquals(out, |
|
1685.1.59
by Martin Pool
[broken] Fix up & refactor display of remembered urls to unescape properly |
159 |
('','bzr: ERROR: No location specified or remembered\n')) |
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
160 |
# test implicit --remember when no parent set, this merge conflicts
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
161 |
self.build_tree(['d']) |
162 |
tree_b.add('d') |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
163 |
out = self.run_bzr('merge ../branch_a', retcode=3) |
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
164 |
self.assertEquals(out, |
165 |
('','bzr: ERROR: Working tree has uncommitted changes.\n')) |
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
166 |
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent)) |
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
167 |
# test implicit --remember after resolving conflict
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
168 |
tree_b.commit('commit d') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
169 |
out, err = self.run_bzr('merge') |
|
1685.1.38
by John Arbash Meinel
Fix merge_remember to use a complete path. |
170 |
|
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
171 |
base = urlutils.local_path_from_url(branch_a.base) |
|
1685.1.59
by Martin Pool
[broken] Fix up & refactor display of remembered urls to unescape properly |
172 |
self.assertEquals(out, 'Merging from remembered location %s\n' % (base,)) |
|
1551.11.11
by Aaron Bentley
Get tests passing |
173 |
self.assertEquals(err, '+N b\nAll changes applied successfully.\n') |
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
174 |
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent)) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
175 |
# re-open tree as external run_bzr modified it
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
176 |
tree_b = branch_b.bzrdir.open_workingtree() |
177 |
tree_b.commit('merge branch_a') |
|
|
1614.2.6
by Olaf Conradi
Add testcase for --remember when merge fails. It should still remember |
178 |
# test explicit --remember
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
179 |
out, err = self.run_bzr('merge ../branch_c --remember') |
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
180 |
self.assertEquals(out, '') |
|
1551.11.11
by Aaron Bentley
Get tests passing |
181 |
self.assertEquals(err, '+N c\nAll changes applied successfully.\n') |
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
182 |
self.assertEquals(abspath(branch_b.get_parent()), |
183 |
abspath(branch_c.bzrdir.root_transport.base)) |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
184 |
# re-open tree as external run_bzr modified it
|
|
1614.2.16
by Olaf Conradi
Modified blackbox test cases to use bzrlib API. |
185 |
tree_b = branch_b.bzrdir.open_workingtree() |
186 |
tree_b.commit('merge branch_c') |
|
|
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
187 |
|
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
188 |
def test_merge_bundle(self): |
|
1185.82.33
by Aaron Bentley
Strengthen tests |
189 |
from bzrlib.testament import Testament |
|
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
190 |
tree_a = self.make_branch_and_tree('branch_a') |
191 |
f = file('branch_a/a', 'wb') |
|
192 |
f.write('hello') |
|
193 |
f.close() |
|
194 |
tree_a.add('a') |
|
195 |
tree_a.commit('message') |
|
196 |
||
197 |
tree_b = tree_a.bzrdir.sprout('branch_b').open_workingtree() |
|
|
1185.82.23
by Aaron Bentley
Switch the fetcher |
198 |
f = file('branch_a/a', 'wb') |
199 |
f.write('hey there') |
|
200 |
f.close() |
|
201 |
tree_a.commit('message') |
|
202 |
||
|
1185.82.22
by Aaron Bentley
Start getting changeset merging under test |
203 |
f = file('branch_b/a', 'wb') |
204 |
f.write('goodbye') |
|
205 |
f.close() |
|
206 |
tree_b.commit('message') |
|
207 |
os.chdir('branch_b') |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
208 |
file('../bundle', 'wb').write(self.run_bzr('bundle ../branch_a')[0]) |
|
1185.82.26
by Aaron Bentley
Get changeset merges closer to working |
209 |
os.chdir('../branch_a') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
210 |
self.run_bzr('merge ../bundle', retcode=1) |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
211 |
testament_a = Testament.from_revision(tree_a.branch.repository, |
212 |
tree_b.get_parent_ids()[0]) |
|
|
1185.82.33
by Aaron Bentley
Strengthen tests |
213 |
testament_b = Testament.from_revision(tree_b.branch.repository, |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
214 |
tree_b.get_parent_ids()[0]) |
|
1185.82.33
by Aaron Bentley
Strengthen tests |
215 |
self.assertEqualDiff(testament_a.as_text(), |
216 |
testament_b.as_text()) |
|
|
1185.82.141
by Aaron Bentley
Ensure bzr works when you merge an already-merged bundle |
217 |
tree_a.set_conflicts(ConflictList()) |
218 |
tree_a.commit('message') |
|
219 |
# it is legal to attempt to merge an already-merged bundle
|
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
220 |
output = self.run_bzr('merge ../bundle')[1] |
|
1185.82.141
by Aaron Bentley
Ensure bzr works when you merge an already-merged bundle |
221 |
# but it does nothing
|
|
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
222 |
self.assertFalse(tree_a.changes_from(tree_a.basis_tree()).has_changed()) |
|
1185.82.142
by Aaron Bentley
Update for review comments |
223 |
self.assertEqual('Nothing to do.\n', output) |
|
1910.1.1
by Aaron Bentley
Merge takes --uncommitted parameter |
224 |
|
225 |
def test_merge_uncommitted(self): |
|
226 |
"""Check that merge --uncommitted behaves properly""" |
|
227 |
tree_a = self.make_branch_and_tree('a') |
|
228 |
self.build_tree(['a/file_1', 'a/file_2']) |
|
229 |
tree_a.add(['file_1', 'file_2']) |
|
230 |
tree_a.commit('commit 1') |
|
231 |
tree_b = tree_a.bzrdir.sprout('b').open_workingtree() |
|
232 |
self.failUnlessExists('b/file_1') |
|
233 |
tree_a.rename_one('file_1', 'file_i') |
|
234 |
tree_a.commit('commit 2') |
|
235 |
tree_a.rename_one('file_2', 'file_ii') |
|
|
2279.3.1
by mbp at sourcefrog
Add a -d option to push, pull, merge (ported from tags branch) |
236 |
## os.chdir('b')
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
237 |
self.run_bzr('merge a --uncommitted -d b') |
|
2279.3.1
by mbp at sourcefrog
Add a -d option to push, pull, merge (ported from tags branch) |
238 |
self.failUnlessExists('b/file_1') |
239 |
self.failUnlessExists('b/file_ii') |
|
|
1910.1.1
by Aaron Bentley
Merge takes --uncommitted parameter |
240 |
tree_b.revert([]) |
|
2279.3.1
by mbp at sourcefrog
Add a -d option to push, pull, merge (ported from tags branch) |
241 |
self.run_bzr_error(('Cannot use --uncommitted and --revision',), |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
242 |
'merge /a --uncommitted -r1 -d b') |
|
2149.2.1
by Jan Hudec
Option --pull for merge command. |
243 |
|
244 |
def pullable_branch(self): |
|
245 |
os.mkdir('a') |
|
246 |
os.chdir('a') |
|
247 |
self.example_branch() |
|
248 |
os.chdir('..') |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
249 |
self.run_bzr('branch a b') |
|
2149.2.1
by Jan Hudec
Option --pull for merge command. |
250 |
os.chdir('b') |
251 |
file('goodbye', 'wt').write('quux') |
|
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
252 |
self.run_bzr(['commit', '-m', "mode u's are always good"]) |
|
2149.2.1
by Jan Hudec
Option --pull for merge command. |
253 |
os.chdir('../a') |
254 |
||
255 |
def pullable_branch(self): |
|
256 |
tree_a = self.make_branch_and_tree('a') |
|
257 |
self.build_tree(['a/file']) |
|
258 |
tree_a.add(['file']) |
|
259 |
self.id1 = tree_a.commit('commit 1') |
|
260 |
||
261 |
tree_b = self.make_branch_and_tree('b') |
|
262 |
tree_b.pull(tree_a.branch) |
|
263 |
file('b/file', 'wb').write('foo') |
|
264 |
self.id2 = tree_b.commit('commit 2') |
|
265 |
||
266 |
def test_merge_pull(self): |
|
267 |
self.pullable_branch() |
|
268 |
os.chdir('a') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
269 |
(out, err) = self.run_bzr('merge --pull ../b') |
|
2297.1.1
by Martin Pool
Pull now returns a PullResult rather than just an integer. |
270 |
self.assertContainsRe(err, 'Now on revision 2\\.') |
|
2149.2.1
by Jan Hudec
Option --pull for merge command. |
271 |
tree_a = WorkingTree.open('.') |
272 |
self.assertEqual([self.id2], tree_a.get_parent_ids()) |
|
|
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
273 |
|
274 |
def test_merge_kind_change(self): |
|
275 |
tree_a = self.make_branch_and_tree('tree_a') |
|
276 |
self.build_tree_contents([('tree_a/file', 'content_1')]) |
|
277 |
tree_a.add('file', 'file-id') |
|
278 |
tree_a.commit('added file') |
|
279 |
tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree() |
|
280 |
os.unlink('tree_a/file') |
|
281 |
self.build_tree(['tree_a/file/']) |
|
282 |
tree_a.commit('changed file to directory') |
|
283 |
os.chdir('tree_b') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
284 |
self.run_bzr('merge ../tree_a') |
|
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
285 |
self.assertEqual('directory', file_kind('file')) |
286 |
tree_b.revert([]) |
|
287 |
self.assertEqual('file', file_kind('file')) |
|
288 |
self.build_tree_contents([('file', 'content_2')]) |
|
289 |
tree_b.commit('content change') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
290 |
self.run_bzr('merge ../tree_a', retcode=1) |
|
1959.4.6
by Aaron Bentley
Ensure merge works across kind changes |
291 |
self.assertEqual(tree_b.conflicts(), |
292 |
[ContentsConflict('file', file_id='file-id')]) |
|
|
2520.4.109
by Aaron Bentley
start work on directive cherry-picking |
293 |
|
294 |
def test_directive_cherrypick(self): |
|
295 |
source = self.make_branch_and_tree('source') |
|
296 |
self.build_tree(['source/a']) |
|
297 |
source.add('a') |
|
298 |
source.commit('Added a', rev_id='rev1') |
|
299 |
self.build_tree(['source/b']) |
|
300 |
source.add('b') |
|
301 |
source.commit('Added b', rev_id='rev2') |
|
302 |
target = self.make_branch_and_tree('target') |
|
303 |
target.commit('empty commit') |
|
|
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
304 |
self.write_directive('directive', source.branch, 'target', 'rev2', |
305 |
'rev1') |
|
|
2520.4.110
by Aaron Bentley
Implement cherrypick support for merge directives |
306 |
self.run_bzr('merge -d target directive') |
307 |
self.failIfExists('target/a') |
|
308 |
self.failUnlessExists('target/b') |
|
|
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
309 |
|
310 |
def write_directive(self, filename, source, target, revision_id, |
|
311 |
base_revision_id=None, mangle_patch=False): |
|
312 |
md = merge_directive.MergeDirective2.from_objects( |
|
|
2520.4.112
by Aaron Bentley
Make cherry-pick merge directives possible |
313 |
source.repository, revision_id, 0, 0, target, |
314 |
base_revision_id=base_revision_id) |
|
|
2520.4.111
by Aaron Bentley
Ensure that damaged preview patches produce a warning in merge |
315 |
if mangle_patch: |
316 |
md.patch = 'asdf\n' |
|
317 |
self.build_tree_contents([(filename, ''.join(md.to_lines()))]) |
|
318 |
||
319 |
def test_directive_verify_warning(self): |
|
320 |
source = self.make_branch_and_tree('source') |
|
321 |
self.build_tree(['source/a']) |
|
322 |
source.add('a') |
|
323 |
source.commit('Added a', rev_id='rev1') |
|
324 |
target = self.make_branch_and_tree('target') |
|
325 |
target.commit('empty commit') |
|
326 |
self.write_directive('directive', source.branch, 'target', 'rev1') |
|
327 |
err = self.run_bzr('merge -d target directive')[1] |
|
328 |
self.assertNotContainsRe(err, 'Preview patch does not match changes') |
|
329 |
target.revert([]) |
|
330 |
self.write_directive('directive', source.branch, 'target', 'rev1', |
|
331 |
mangle_patch=True) |
|
332 |
err = self.run_bzr('merge -d target directive')[1] |
|
333 |
self.assertContainsRe(err, 'Preview patch does not match changes') |