Debian Codegraph @

subversion/tests/cmdline/merge_tree_conflict_tests.py

raw
1 #!/usr/bin/env python
2 #
3 # merge_tests.py: testing tree conflicts during merge
4 #
5 # Subversion is a tool for revision control.
6 # See http://subversion.apache.org for more information.
7 #
8 # ====================================================================
9 # Licensed to the Apache Software Foundation (ASF) under one
10 # or more contributor license agreements. See the NOTICE file
11 # distributed with this work for additional information
12 # regarding copyright ownership. The ASF licenses this file
13 # to you under the Apache License, Version 2.0 (the
14 # "License"); you may not use this file except in compliance
15 # with the License. You may obtain a copy of the License at
16 #
17 # http://www.apache.org/licenses/LICENSE-2.0
18 #
19 # Unless required by applicable law or agreed to in writing,
20 # software distributed under the License is distributed on an
21 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 # KIND, either express or implied. See the License for the
23 # specific language governing permissions and limitations
24 # under the License.
25 ######################################################################
26
27 # General modules
28 import shutil, sys, re, os
29 import time
30
31 # Our testing module
32 import svntest
33 from svntest import main, wc, verify, actions, deeptrees
34
35 # (abbreviation)
36 Item = wc.StateItem
37 Skip = svntest.testcase.Skip_deco
38 SkipUnless = svntest.testcase.SkipUnless_deco
39 XFail = svntest.testcase.XFail_deco
40 Issues = svntest.testcase.Issues_deco
41 Issue = svntest.testcase.Issue_deco
42 Wimp = svntest.testcase.Wimp_deco
43
44 from svntest.main import SVN_PROP_MERGEINFO
45 from svntest.main import server_has_mergeinfo
46 from svntest.mergetrees import set_up_branch
47 from svntest.mergetrees import svn_copy
48 from svntest.mergetrees import svn_merge
49 from svntest.mergetrees import expected_merge_output
50
51 #----------------------------------------------------------------------
52 @SkipUnless(server_has_mergeinfo)
53 def delete_file_and_dir(sbox):
54 "merge that deletes items"
55
56 sbox.build()
57 wc_dir = sbox.wc_dir
58
59 # Rev 2 copy B to B2
60 B_path = os.path.join(wc_dir, 'A', 'B')
61 B2_path = os.path.join(wc_dir, 'A', 'B2')
62 B_url = sbox.repo_url + '/A/B'
63
64 svntest.actions.run_and_verify_svn(None, [],
65 'copy', B_path, B2_path)
66
67 expected_output = wc.State(wc_dir, {
68 'A/B2' : Item(verb='Adding'),
69 })
70 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
71 expected_status.add({
72 'A/B2' : Item(status=' ', wc_rev=2),
73 'A/B2/E' : Item(status=' ', wc_rev=2),
74 'A/B2/E/alpha' : Item(status=' ', wc_rev=2),
75 'A/B2/E/beta' : Item(status=' ', wc_rev=2),
76 'A/B2/F' : Item(status=' ', wc_rev=2),
77 'A/B2/lambda' : Item(status=' ', wc_rev=2),
78 })
79 svntest.actions.run_and_verify_commit(wc_dir,
80 expected_output,
81 expected_status)
82
83 # Rev 3 delete E and lambda from B
84 E_path = os.path.join(B_path, 'E')
85 lambda_path = os.path.join(B_path, 'lambda')
86 svntest.actions.run_and_verify_svn(None, [],
87 'delete', E_path, lambda_path)
88
89 expected_output = wc.State(wc_dir, {
90 'A/B/E' : Item(verb='Deleting'),
91 'A/B/lambda' : Item(verb='Deleting'),
92 })
93 expected_status.remove('A/B/E',
94 'A/B/E/alpha',
95 'A/B/E/beta',
96 'A/B/lambda')
97 svntest.actions.run_and_verify_commit(wc_dir,
98 expected_output,
99 expected_status)
100
101 def modify_B2():
102 # Local mods in B2
103 B2_E_path = os.path.join(B2_path, 'E')
104 B2_lambda_path = os.path.join(B2_path, 'lambda')
105 svntest.actions.run_and_verify_svn(None, [],
106 'propset', 'foo', 'foo_val',
107 B2_E_path, B2_lambda_path)
108 expected_status.tweak(
109 'A/B2/E', 'A/B2/lambda', status=' M'
110 )
111 svntest.actions.run_and_verify_status(wc_dir, expected_status)
112
113 modify_B2()
114
115 # Merge rev 3 into B2
116
117 # The local mods to the paths modified in r3 cause the paths to be
118 # tree-conflicted upon deletion, resulting in only the mergeinfo change
119 # to the target of the merge 'B2'.
120 expected_output = wc.State(B2_path, {
121 '' : Item(),
122 'lambda' : Item(status=' ', treeconflict='C'),
123 'E' : Item(status=' ', treeconflict='C'),
124 })
125 expected_mergeinfo_output = wc.State(B2_path, {
126 '' : Item(status=' U'),
127 })
128 expected_elision_output = wc.State(B2_path, {
129 })
130 expected_disk = wc.State('', {
131 '' : Item(props={SVN_PROP_MERGEINFO : '/A/B:3'}),
132 'E' : Item(props={'foo' : 'foo_val'}),
133 'E/alpha' : Item("This is the file 'alpha'.\n"),
134 'E/beta' : Item("This is the file 'beta'.\n"),
135 'F' : Item(),
136 'lambda' : Item("This is the file 'lambda'.\n",
137 props={'foo' : 'foo_val'}),
138 })
139 expected_status2 = wc.State(B2_path, {
140 '' : Item(status=' M'),
141 'E' : Item(status=' M', treeconflict='C'),
142 'E/alpha' : Item(status=' '),
143 'E/beta' : Item(status=' '),
144 'F' : Item(status=' '),
145 'lambda' : Item(status=' M', treeconflict='C'),
146 })
147 expected_status2.tweak(wc_rev=2)
148 expected_skip = wc.State('', { })
149 svntest.actions.run_and_verify_merge(B2_path, '2', '3', B_url, None,
150 expected_output,
151 expected_mergeinfo_output,
152 expected_elision_output,
153 expected_disk,
154 expected_status2,
155 expected_skip,
156 check_props=True)
157
158 #----------------------------------------------------------------------
159 # This is a regression for issue #1176.
160 @Issue(1176)
161 @SkipUnless(server_has_mergeinfo)
162 def merge_catches_nonexistent_target(sbox):
163 "merge should not die if a target file is absent"
164
165 sbox.build()
166 wc_dir = sbox.wc_dir
167
168 # Copy G to a new directory, Q. Create Q/newfile. Commit a change
169 # to Q/newfile. Now merge that change... into G. Merge should not
170 # error, rather, it should report the tree conflict and continue.
171
172 G_path = os.path.join(wc_dir, 'A', 'D', 'G')
173 Q_path = os.path.join(wc_dir, 'A', 'D', 'Q')
174 newfile_path = os.path.join(Q_path, 'newfile')
175 Q_url = sbox.repo_url + '/A/D/Q'
176
177 # Copy dir A/D/G to A/D/Q
178 svntest.actions.run_and_verify_svn(None, [], 'cp', G_path, Q_path)
179
180 svntest.main.file_append(newfile_path, 'This is newfile.\n')
181 svntest.actions.run_and_verify_svn(None, [], 'add', newfile_path)
182
183 # Add newfile to dir G, creating r2.
184 expected_output = wc.State(wc_dir, {
185 'A/D/Q' : Item(verb='Adding'),
186 'A/D/Q/newfile' : Item(verb='Adding'),
187 })
188 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
189 expected_status.add({
190 'A/D/Q' : Item(status=' ', wc_rev=2),
191 'A/D/Q/pi' : Item(status=' ', wc_rev=2),
192 'A/D/Q/rho' : Item(status=' ', wc_rev=2),
193 'A/D/Q/tau' : Item(status=' ', wc_rev=2),
194 'A/D/Q/newfile' : Item(status=' ', wc_rev=2),
195 })
196 ### right now, we cannot denote that Q/newfile is a local-add rather than
197 ### a child of the A/D/Q copy. thus, it appears in the status output as a
198 ### (M)odified child.
199 svntest.actions.run_and_verify_commit(wc_dir,
200 expected_output,
201 expected_status)
202
203 # Change newfile, creating r3.
204 svntest.main.file_append(newfile_path, 'A change to newfile.\n')
205 expected_output = wc.State(wc_dir, {
206 'A/D/Q/newfile' : Item(verb='Sending'),
207 })
208 expected_status.tweak('A/D/Q/newfile', wc_rev=3)
209 svntest.actions.run_and_verify_commit(wc_dir,
210 expected_output,
211 expected_status)
212
213 # Merge the change to newfile (from r3) into G, where newfile
214 # doesn't exist. This is a tree conflict (use case 4, see
215 # notes/tree-conflicts/detection.txt).
216 os.chdir(G_path)
217 expected_output = wc.State('', {
218 'newfile' : Item(status=' ', treeconflict='C'),
219 })
220 expected_mergeinfo_output = wc.State('', {
221 '' : Item(status=' U'),
222 })
223 expected_elision_output = wc.State('', {
224 })
225 expected_status = wc.State('', {
226 '' : Item(status=' M' ),
227 'pi' : Item(status=' ' ),
228 'rho' : Item(status=' ' ),
229 'tau' : Item(status=' ' ),
230 })
231 expected_status.tweak(wc_rev=1)
232
233 expected_status.add({
234 'newfile': Item(status='! ', treeconflict='C' )
235 })
236
237 expected_status.tweak('', status=' M')
238
239 expected_disk = wc.State('', {
240 '' : Item(props={SVN_PROP_MERGEINFO : '/A/D/Q:3'}),
241 'pi' : Item("This is the file 'pi'.\n"),
242 'rho' : Item("This is the file 'rho'.\n"),
243 'tau' : Item("This is the file 'tau'.\n"),
244 })
245 expected_skip = wc.State('', {
246 })
247 svntest.actions.run_and_verify_merge('', '2', '3', Q_url, None,
248 expected_output,
249 expected_mergeinfo_output,
250 expected_elision_output,
251 expected_disk,
252 expected_status,
253 expected_skip,
254 check_props=True)
255
256 expected_status.add({
257 'newfile' : Item(status='! ', treeconflict='C'),
258 })
259 svntest.actions.run_and_verify_unquiet_status('', expected_status)
260
261 #----------------------------------------------------------------------
262 @SkipUnless(server_has_mergeinfo)
263 def merge_tree_deleted_in_target(sbox):
264 "merge on deleted directory in target"
265
266 sbox.build()
267 wc_dir = sbox.wc_dir
268
269 # Copy B to a new directory, I. Modify B/E/alpha, Remove I/E. Now
270 # merge that change... into I. Merge should report a tree conflict.
271
272 B_path = os.path.join(wc_dir, 'A', 'B')
273 I_path = os.path.join(wc_dir, 'A', 'I')
274 alpha_path = os.path.join(B_path, 'E', 'alpha')
275 B_url = sbox.repo_url + '/A/B'
276 I_url = sbox.repo_url + '/A/I'
277
278
279 # Copy B to I, creating r1.
280 svntest.actions.run_and_verify_svn(None, [],
281 'cp', B_url, I_url, '-m', 'rev 2')
282
283 # Change some files, creating r2.
284 svntest.main.file_append(alpha_path, 'A change to alpha.\n')
285 svntest.main.file_append(os.path.join(B_path, 'lambda'), 'change lambda.\n')
286 svntest.actions.run_and_verify_svn(None, [],
287 'ci', '-m', 'rev 3', B_path)
288
289 # Remove E, creating r3.
290 E_url = sbox.repo_url + '/A/I/E'
291 svntest.actions.run_and_verify_svn(None, [],
292 'rm', E_url, '-m', 'rev 4')
293
294 svntest.actions.run_and_verify_svn(None, [],
295 'up', os.path.join(wc_dir,'A'))
296
297 expected_output = wc.State(I_path, {
298 'lambda' : Item(status='U '),
299 'E' : Item(status=' ', treeconflict='C'),
300 })
301 expected_mergeinfo_output = wc.State(I_path, {
302 '' : Item(status=' U'),
303 })
304 expected_elision_output = wc.State(I_path, {
305 })
306 expected_disk = wc.State('', {
307 '' : Item(props={SVN_PROP_MERGEINFO : '/A/B:3'}),
308 'F' : Item(),
309 'lambda' : Item("This is the file 'lambda'.\nchange lambda.\n"),
310 })
311 expected_status = wc.State(I_path, {
312 '' : Item(status=' M'),
313 'F' : Item(status=' '),
314 'lambda' : Item(status='M '),
315 })
316 expected_status.tweak(wc_rev=4)
317 expected_status.add({
318 'E' : Item(status='! ', treeconflict='C' )
319 })
320 expected_skip = wc.State(I_path, {
321 })
322 svntest.actions.run_and_verify_merge(I_path, '2', '3', B_url, None,
323 expected_output,
324 expected_mergeinfo_output,
325 expected_elision_output,
326 expected_disk,
327 expected_status,
328 expected_skip,
329 check_props=True)
330 expected_status.add({
331 'E' : Item(status='! ', treeconflict='C'),
332 })
333 svntest.actions.run_and_verify_unquiet_status(I_path, expected_status)
334
335 #----------------------------------------------------------------------
336 # Regression test for issue #2403: Incorrect 3-way merge of "added"
337 # binary file which already exists (unmodified) in the WC
338 @SkipUnless(server_has_mergeinfo)
339 @Issue(2403)
340 def three_way_merge_add_of_existing_binary_file(sbox):
341 "3-way merge of 'file add' into existing binary"
342
343 sbox.build()
344 wc_dir = sbox.wc_dir
345
346 # Create a branch of A, creating revision 2.
347 A_url = sbox.repo_url + "/A"
348 branch_A_url = sbox.repo_url + "/copy-of-A"
349 svntest.actions.run_and_verify_svn(None, [],
350 "cp",
351 A_url, branch_A_url,
352 "-m", "Creating copy-of-A")
353
354 # Add a binary file to the WC.
355 theta_contents = open(os.path.join(sys.path[0], "theta.bin"), 'rb').read()
356 # Write PNG file data into 'A/theta'.
357 A_path = os.path.join(wc_dir, 'A')
358 theta_path = os.path.join(wc_dir, 'A', 'theta')
359 svntest.main.file_write(theta_path, theta_contents, 'wb')
360
361 svntest.main.run_svn(None, "add", theta_path)
362
363 # Commit the new binary file to the repos, creating revision 3.
364 expected_output = svntest.wc.State(wc_dir, {
365 "A/theta" : Item(verb="Adding (bin)"),
366 })
367 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
368 expected_status.add({
369 "A/theta" : Item(status=" ", wc_rev=3),
370 })
371 svntest.actions.run_and_verify_commit(wc_dir, expected_output,
372 expected_status)
373
374 # In the working copy, attempt to 'svn merge branch_A_url@2 A_url@3 A'.
375 # We should *not* see a conflict during the merge, but an 'A'.
376 # And after the merge, the status should not report any differences.
377
378 expected_output = wc.State(wc_dir, {
379 "A/theta" : Item(status=" ", treeconflict='C'),
380 })
381 expected_elision_output = wc.State(wc_dir, {
382 })
383
384 # As greek_state is rooted at / instead of /A (our merge target), we
385 # need a sub-tree of it rather than straight copy.
386 expected_disk = svntest.main.greek_state.subtree("A")
387 expected_disk.add({
388 "" : Item(props={SVN_PROP_MERGEINFO : '/A:2-3'}),
389 "theta" : Item(theta_contents,
390 props={"svn:mime-type" : "application/octet-stream"}),
391 })
392 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
393 expected_status.add({
394 "A/theta" : Item(status=" ", wc_rev=3, treeconflict='C'),
395 })
396 expected_status.tweak("A", status=" M")
397 expected_status.remove("") # top-level of the WC
398 expected_status.remove("iota")
399 expected_skip = wc.State("", { })
400
401 # If we merge into wc_dir alone, theta appears at the WC root,
402 # which is in the wrong location -- append "/A" to stay on target.
403 #
404 # Note we don't bother checking expected mergeinfo output because
405 # three-way merges record mergeinfo multiple times on the same
406 # path, 'A' in this case. The first recording is reported as ' U'
407 # but the second is reported as ' G'. Our expected tree structures
408 # can't handle checking for multiple values for the same key.
409 svntest.actions.run_and_verify_merge(A_path, "2", "3",
410 branch_A_url, A_url,
411 expected_output,
412 None, # expected_mergeinfo_output
413 expected_elision_output,
414 expected_disk,
415 expected_status,
416 expected_skip,
417 [], True, False,
418 '--allow-mixed-revisions', A_path)
419
420 #----------------------------------------------------------------------
421 # Issue #2515
422 @Issue(2515)
423 def merge_added_dir_to_deleted_in_target(sbox):
424 "merge an added dir on a deleted dir in target"
425
426 sbox.build()
427 wc_dir = sbox.wc_dir
428
429 # copy B to a new directory, I.
430 # delete F in I.
431 # add J to B/F.
432 # merge add to I.
433
434 B_url = sbox.repo_url + '/A/B'
435 I_url = sbox.repo_url + '/A/I'
436 F_url = sbox.repo_url + '/A/I/F'
437 J_url = sbox.repo_url + '/A/B/F/J'
438 I_path = os.path.join(wc_dir, 'A', 'I')
439
440
441 svntest.actions.run_and_verify_svn(None, [],
442 'cp', B_url, I_url, '-m', 'rev 2')
443
444 svntest.actions.run_and_verify_svn(None, [],
445 'rm', F_url, '-m', 'rev 3')
446
447 svntest.actions.run_and_verify_svn(None, [],
448 'mkdir', '-m', 'rev 4', J_url)
449
450 svntest.actions.run_and_verify_svn(None, [],
451 'up', os.path.join(wc_dir,'A'))
452
453 expected_output = wc.State(I_path, {
454 'F' : Item(status=' ', treeconflict='C'),
455 })
456 expected_mergeinfo_output = wc.State(I_path, {
457 '' : Item(status=' U'),
458 })
459 expected_elision_output = wc.State(I_path, {
460 })
461 expected_disk = wc.State('', {
462 'E' : Item(),
463 'E/alpha' : Item("This is the file 'alpha'.\n"),
464 'E/beta' : Item("This is the file 'beta'.\n"),
465 'lambda' : Item("This is the file 'lambda'.\n"),
466 })
467 expected_skip = wc.State(I_path, {
468 })
469
470 svntest.actions.run_and_verify_merge(I_path, '2', '4', B_url, None,
471 expected_output,
472 expected_mergeinfo_output,
473 expected_elision_output,
474 expected_disk,
475 None,
476 expected_skip)
477
478 #----------------------------------------------------------------------
479 # Issue 2584
480 @Issue(2584)
481 @SkipUnless(server_has_mergeinfo)
482 def merge_add_over_versioned_file_conflicts(sbox):
483 "conflict from merge of add over versioned file"
484
485 sbox.build()
486 wc_dir = sbox.wc_dir
487
488 E_path = os.path.join(wc_dir, 'A', 'B', 'E')
489 alpha_path = os.path.join(E_path, 'alpha')
490 new_alpha_path = os.path.join(wc_dir, 'A', 'C', 'alpha')
491
492 # Create a new "alpha" file, with enough differences to cause a conflict.
493 svntest.main.file_write(new_alpha_path, 'new alpha content\n')
494
495 # Add and commit the new "alpha" file, creating revision 2.
496 svntest.main.run_svn(None, "add", new_alpha_path)
497
498 expected_output = svntest.wc.State(wc_dir, {
499 'A/C/alpha' : Item(verb='Adding'),
500 })
501 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
502 expected_status.add({
503 'A/C/alpha' : Item(status=' ', wc_rev=2),
504 })
505 svntest.actions.run_and_verify_commit(wc_dir, expected_output,
506 expected_status)
507
508 # Merge r1:2 from A/C to A/B/E. This will attempt to add A/C/alpha,
509 # but since A/B/E/alpha already exists we get a tree conflict.
510 expected_output = wc.State(E_path, {
511 'alpha' : Item(status=' ', treeconflict='C'),
512 })
513 expected_mergeinfo_output = wc.State(E_path, {
514 '' : Item(status=' U'),
515 })
516 expected_elision_output = wc.State(E_path, {
517 })
518 expected_disk = wc.State('', {
519 'alpha' : Item("This is the file 'alpha'.\n"),
520 'beta' : Item("This is the file 'beta'.\n"),
521 })
522 expected_status = wc.State(E_path, {
523 '' : Item(status=' M', wc_rev=1),
524 'alpha' : Item(status=' ', wc_rev=1, treeconflict='C'),
525 'beta' : Item(status=' ', wc_rev=1),
526 })
527 expected_skip = wc.State(E_path, { })
528 svntest.actions.run_and_verify_merge(E_path, '1', '2',
529 sbox.repo_url + '/A/C', None,
530 expected_output,
531 expected_mergeinfo_output,
532 expected_elision_output,
533 expected_disk,
534 expected_status,
535 expected_skip)
536
537 #----------------------------------------------------------------------
538 @SkipUnless(server_has_mergeinfo)
539 @Issue(2829)
540 def mergeinfo_recording_in_skipped_merge(sbox):
541 "mergeinfo recording in skipped merge"
542
543 ## See https://issues.apache.org/jira/browse/SVN-2829. ##
544
545 # Create a WC with a single branch
546 sbox.build()
547 wc_dir = sbox.wc_dir
548 wc_disk, wc_status = set_up_branch(sbox, True, 1)
549
550 # Some paths we'll care about
551 A_url = sbox.repo_url + '/A'
552 A_COPY_path = os.path.join(wc_dir, 'A_COPY')
553 mu_path = os.path.join(wc_dir, 'A', 'mu')
554 alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')
555 A_COPY_B_E_path = os.path.join(wc_dir, 'A_COPY', 'B', 'E')
556 A_COPY_alpha_path = os.path.join(wc_dir, 'A_COPY', 'B', 'E', 'alpha')
557 A_COPY_beta_path = os.path.join(wc_dir, 'A_COPY', 'B', 'E', 'beta')
558
559 # Make a modification to A/mu
560 svntest.main.file_write(mu_path, "This is the file 'mu' modified.\n")
561 expected_output = wc.State(wc_dir, {'A/mu' : Item(verb='Sending')})
562 wc_status.add({'A/mu' : Item(status=' ', wc_rev=3)})
563 svntest.actions.run_and_verify_commit(wc_dir, expected_output,
564 wc_status)
565
566 # Make a modification to A/B/E/alpha
567 svntest.main.file_write(alpha_path, "This is the file 'alpha' modified.\n")
568 expected_output = wc.State(wc_dir, {'A/B/E/alpha' : Item(verb='Sending')})
569 wc_status.add({'A/B/E/alpha' : Item(status=' ', wc_rev=4)})
570 svntest.actions.run_and_verify_commit(wc_dir, expected_output,
571 wc_status)
572
573 # Delete A_COPY/B/E
574 svntest.actions.run_and_verify_svn(None, [], 'rm',
575 A_COPY_B_E_path)
576
577 # Merge /A to /A_COPY ie., r1 to r4
578 expected_output = wc.State(A_COPY_path, {
579 'mu' : Item(status='U '),
580 'B/E' : Item(status=' ', treeconflict='C'),
581 })
582 expected_mergeinfo_output = wc.State(A_COPY_path, {
583 '' : Item(status=' U'),
584 })
585 expected_elision_output = wc.State(A_COPY_path, {
586 })
587 expected_status = wc.State(A_COPY_path, {
588 '' : Item(status=' M', wc_rev=2),
589 'mu' : Item(status='M ', wc_rev=2),
590 'B' : Item(status=' ', wc_rev=2),
591 'B/lambda' : Item(status=' ', wc_rev=2),
592 'B/F' : Item(status=' ', wc_rev=2),
593 'B/E' : Item(status='D ', wc_rev=2, treeconflict='C'),
594 'B/E/alpha': Item(status='D ', wc_rev=2),
595 'B/E/beta' : Item(status='D ', wc_rev=2),
596 'C' : Item(status=' ', wc_rev=2),
597 'D' : Item(status=' ', wc_rev=2),
598 'D/gamma' : Item(status=' ', wc_rev=2),
599 'D/G' : Item(status=' ', wc_rev=2),
600 'D/G/pi' : Item(status=' ', wc_rev=2),
601 'D/G/rho' : Item(status=' ', wc_rev=2),
602 'D/G/tau' : Item(status=' ', wc_rev=2),
603 'D/H' : Item(status=' ', wc_rev=2),
604 'D/H/chi' : Item(status=' ', wc_rev=2),
605 'D/H/omega': Item(status=' ', wc_rev=2),
606 'D/H/psi' : Item(status=' ', wc_rev=2),
607 })
608 expected_disk = wc.State('', {
609 '' : Item(props={SVN_PROP_MERGEINFO : '/A:2-4'}),
610 'mu' : Item("This is the file 'mu' modified.\n"),
611 'C' : Item(),
612 'D' : Item(),
613 'B' : Item(),
614 'B/lambda' : Item(contents="This is the file 'lambda'.\n"),
615 'B/F' : Item(),
616 'D/gamma' : Item("This is the file 'gamma'.\n"),
617 'D/G' : Item(),
618 'D/G/pi' : Item("This is the file 'pi'.\n"),
619 'D/G/rho' : Item("This is the file 'rho'.\n"),
620 'D/G/tau' : Item("This is the file 'tau'.\n"),
621 'D/H' : Item(),
622 'D/H/chi' : Item("This is the file 'chi'.\n"),
623 'D/H/omega': Item("This is the file 'omega'.\n"),
624 'D/H/psi' : Item("This is the file 'psi'.\n"),
625 })
626 expected_skip = wc.State(A_COPY_path, {})
627 svntest.actions.run_and_verify_merge(A_COPY_path, None, None,
628 A_url, None,
629 expected_output,
630 expected_mergeinfo_output,
631 expected_elision_output,
632 expected_disk,
633 expected_status,
634 expected_skip,
635 [], True, True)
636
637 #----------------------------------------------------------------------
638 def del_differing_file(sbox):
639 "merge tries to delete a file of different content"
640
641 # Setup a standard greek tree in r1.
642 sbox.build()
643
644 saved_cwd = os.getcwd()
645 os.chdir(sbox.wc_dir)
646 sbox.wc_dir = ''
647
648 source = 'A/D/G'
649 s_rev_orig = 1
650
651 # Delete files in the source
652 sbox.simple_rm(source+"/tau")
653 sbox.simple_commit(source)
654 s_rev_tau = 2
655 sbox.simple_rm(source+"/pi")
656 sbox.simple_commit(source)
657 s_rev_pi = 3
658
659 # Copy a file, modify it, and merge a deletion to it.
660 target = 'A/D/G2'
661 svn_copy(s_rev_orig, source, target)
662 svntest.main.file_append(target+"/tau", "An extra line in the target.\n")
663 svntest.actions.run_and_verify_svn(None, [], 'propset',
664 'newprop', 'v', target+"/pi")
665
666 dir_D = os.path.join('A','D')
667 tau = os.path.join(dir_D,'G2','tau')
668 pi = os.path.join(dir_D, 'G2', 'pi')
669 # Should complain and "skip" it.
670 svn_merge(s_rev_tau, source, target, [
671 " C %s\n" % tau, # merge
672 ], tree_conflicts=1)
673
674 svn_merge(s_rev_pi, source, target, [
675 " C %s\n" % pi, # merge
676 ], tree_conflicts=1)
677
678
679 # Copy a file, modify it, commit, and merge a deletion to it.
680 target = 'A/D/G3'
681 svn_copy(s_rev_orig, source, target)
682 svntest.main.file_append(target+"/tau", "An extra line in the target.\n")
683 svntest.actions.run_and_verify_svn(None, [], 'propset',
684 'newprop', 'v', target+"/pi")
685 sbox.simple_commit(target)
686
687
688 tau = os.path.join(dir_D,'G3','tau')
689 pi = os.path.join(dir_D, 'G3', 'pi')
690
691 # Should complain and "skip" it.
692 svn_merge(s_rev_tau, source, target, [
693 " C %s\n" % tau,
694 ], tree_conflicts=1)
695
696 svn_merge(s_rev_pi, source, target, [
697 " C %s\n" % pi,
698 ], tree_conflicts=1)
699
700 os.chdir(saved_cwd)
701
702 #----------------------------------------------------------------------
703 # This test used to involve tree conflicts, hence its name.
704 @Issue(3146)
705 def tree_conflicts_and_obstructions(sbox):
706 "tree conflicts and obstructions"
707
708 ## See https://issues.apache.org/jira/browse/SVN-3146. ##
709
710 sbox.build()
711 wc_dir = sbox.wc_dir
712
713 trunk_url = sbox.repo_url + '/A/B/E'
714 branch_path = os.path.join(wc_dir, 'branch')
715 br_alpha_moved = os.path.join(branch_path, 'alpha-moved')
716
717 # Create a branch
718 svntest.actions.run_and_verify_svn(None, [], 'cp',
719 trunk_url,
720 sbox.repo_url + '/branch',
721 '-m', "Creating the Branch")
722
723 svntest.actions.run_and_verify_svn(None, [], 'mv',
724 trunk_url + '/alpha',
725 trunk_url + '/alpha-moved',
726 '-m', "Move alpha to alpha-moved")
727
728 # Update to revision 2.
729 svntest.actions.run_and_verify_svn(None, [],
730 'update', wc_dir)
731
732 svntest.main.file_write(br_alpha_moved, "I am blocking myself from trunk\n")
733
734 branch_path = os.path.join(wc_dir, "branch")
735
736 # Merge the obstructions into the branch.
737 expected_output = svntest.wc.State(branch_path, {
738 'alpha' : Item(status='D '),
739 })
740 expected_mergeinfo_output = wc.State(branch_path, {
741 '' : Item(status=' U'),
742 })
743 expected_elision_output = wc.State(branch_path, {
744 })
745 expected_disk = wc.State('', {
746 'beta' : Item("This is the file 'beta'.\n"),
747 'alpha-moved' : Item("I am blocking myself from trunk\n"),
748 })
749 expected_status = wc.State(branch_path, {
750 '' : Item(status=' M', wc_rev=3),
751 'alpha' : Item(status='D ', wc_rev=3),
752 'beta' : Item(status=' ', wc_rev=3),
753 })
754 expected_skip = wc.State(branch_path, {
755 'alpha-moved' : Item(verb='Skipped'),
756 })
757
758 svntest.actions.run_and_verify_merge(branch_path,
759 '1', 'HEAD', trunk_url, None,
760 expected_output,
761 expected_mergeinfo_output,
762 expected_elision_output,
763 expected_disk,
764 expected_status,
765 expected_skip)
766
767
768 #----------------------------------------------------------------------
769
770 # Detect tree conflicts among files and directories,
771 # edited or deleted in a deep directory structure.
772 #
773 # See use cases 4-6 in notes/tree-conflicts/use-cases.txt for background.
774 # Note that we do not try to track renames. The only difference from
775 # the behavior of Subversion 1.4 and 1.5 is the conflicted status of the
776 # parent directory.
777
778 # convenience definitions
779 leaf_edit = svntest.deeptrees.deep_trees_leaf_edit
780 tree_del = svntest.deeptrees.deep_trees_tree_del
781 leaf_del = svntest.deeptrees.deep_trees_leaf_del
782
783 disk_after_leaf_edit = svntest.deeptrees.deep_trees_after_leaf_edit
784 disk_after_leaf_del = svntest.deeptrees.deep_trees_after_leaf_del
785 disk_after_tree_del = svntest.deeptrees.deep_trees_after_tree_del
786 disk_after_leaf_del_no_ci = svntest.deeptrees.deep_trees_after_leaf_del_no_ci
787 disk_after_tree_del_no_ci = svntest.deeptrees.deep_trees_after_tree_del_no_ci
788
789 deep_trees_conflict_output = svntest.deeptrees.deep_trees_conflict_output
790
791 j = os.path.join
792
793 DeepTreesTestCase = svntest.deeptrees.DeepTreesTestCase
794
795 alpha_beta_gamma = svntest.wc.State('', {
796 'F/alpha' : Item(),
797 'DF/D1/beta' : Item(),
798 'DDF/D1/D2/gamma' : Item(),
799 })
800
801 #----------------------------------------------------------------------
802 def tree_conflicts_on_merge_local_ci_4_1(sbox):
803 "tree conflicts 4.1: tree del, leaf edit"
804
805 # use case 4, as in notes/tree-conflicts/use-cases.txt
806 # 4.1) local tree delete, incoming leaf edit
807
808 expected_output = deep_trees_conflict_output
809
810 expected_disk = disk_after_tree_del
811
812 expected_status = svntest.wc.State('', {
813 '' : Item(status=' M', wc_rev='3'),
814 'F' : Item(status=' ', wc_rev='3'),
815 'D' : Item(status=' ', wc_rev='3'),
816 'DF' : Item(status=' ', wc_rev='3'),
817 'DD' : Item(status=' ', wc_rev='3'),
818 'DDF' : Item(status=' ', wc_rev='3'),
819 'DDD' : Item(status=' ', wc_rev='3'),
820 'D/D1' : Item(status='! ', treeconflict='C'),
821 'F/alpha' : Item(status='! ', treeconflict='C'),
822 'DD/D1' : Item(status='! ', treeconflict='C'),
823 'DF/D1' : Item(status='! ', treeconflict='C'),
824 'DDD/D1' : Item(status='! ', treeconflict='C'),
825 'DDF/D1' : Item(status='! ', treeconflict='C'),
826 })
827
828 expected_skip = svntest.wc.State('', { })
829
830 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
831 [ DeepTreesTestCase("local_tree_del_incoming_leaf_edit",
832 tree_del,
833 leaf_edit,
834 expected_output,
835 expected_disk,
836 expected_status,
837 expected_skip) ], True)
838
839 #----------------------------------------------------------------------
840 def tree_conflicts_on_merge_local_ci_4_2(sbox):
841 "tree conflicts 4.2: tree del, leaf del"
842
843 # 4.2) local tree delete, incoming leaf delete
844
845 expected_output = deep_trees_conflict_output
846
847 expected_disk = disk_after_tree_del
848
849 expected_status = svntest.wc.State('', {
850 '' : Item(status=' M', wc_rev='3'),
851 'F' : Item(status=' ', wc_rev='3'),
852 'D' : Item(status=' ', wc_rev='3'),
853 'DF' : Item(status=' ', wc_rev='3'),
854 'DD' : Item(status=' ', wc_rev='3'),
855 'DDF' : Item(status=' ', wc_rev='3'),
856 'DDD' : Item(status=' ', wc_rev='3'),
857 'F/alpha' : Item(status='! ', treeconflict='C'),
858 'D/D1' : Item(status='! ', treeconflict='C'),
859 'DF/D1' : Item(status='! ', treeconflict='C'),
860 'DD/D1' : Item(status='! ', treeconflict='C'),
861 'DDF/D1' : Item(status='! ', treeconflict='C'),
862 'DDD/D1' : Item(status='! ', treeconflict='C'),
863 })
864
865 expected_skip = svntest.wc.State('', {
866 })
867
868 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
869 [ DeepTreesTestCase("local_tree_del_incoming_leaf_del",
870 tree_del,
871 leaf_del,
872 expected_output,
873 expected_disk,
874 expected_status,
875 expected_skip) ], True)
876
877 #----------------------------------------------------------------------
878 @Issue(2282)
879 def tree_conflicts_on_merge_local_ci_5_1(sbox):
880 "tree conflicts 5.1: leaf edit, tree del"
881
882 # use case 5, as in notes/tree-conflicts/use-cases.txt
883 # 5.1) local leaf edit, incoming tree delete
884
885 expected_output = deep_trees_conflict_output
886
887 expected_disk = disk_after_leaf_edit
888
889 # We should detect 6 tree conflicts, and nothing should be deleted (when
890 # we skip tree conflict victims).
891 expected_status = svntest.wc.State('', {
892 '' : Item(status=' M', wc_rev='3'),
893 'D' : Item(status=' ', wc_rev='3'),
894 'D/D1' : Item(status=' ', treeconflict='C', wc_rev='4'),
895 'D/D1/delta' : Item(status=' ', wc_rev='4'),
896 'DD' : Item(status=' ', wc_rev='3'),
897 'DD/D1' : Item(status=' ', treeconflict='C', wc_rev='3'),
898 'DD/D1/D2' : Item(status=' ', wc_rev='4'),
899 'DD/D1/D2/epsilon' : Item(status=' ', wc_rev='4'),
900 'DDD' : Item(status=' ', wc_rev='3'),
901 'DDD/D1' : Item(status=' ', treeconflict='C', wc_rev='3'),
902 'DDD/D1/D2' : Item(status=' ', wc_rev='3'),
903 'DDD/D1/D2/D3' : Item(status=' ', wc_rev='4'),
904 'DDD/D1/D2/D3/zeta' : Item(status=' ', wc_rev='4'),
905 'DDF' : Item(status=' ', wc_rev='3'),
906 'DDF/D1' : Item(status=' ', treeconflict='C', wc_rev='3'),
907 'DDF/D1/D2' : Item(status=' ', wc_rev='3'),
908 'DDF/D1/D2/gamma' : Item(status=' ', wc_rev='4'),
909 'DF' : Item(status=' ', wc_rev='3'),
910 'DF/D1' : Item(status=' ', treeconflict='C', wc_rev='3'),
911 'DF/D1/beta' : Item(status=' ', wc_rev='4'),
912 'F' : Item(status=' ', wc_rev='3'),
913 'F/alpha' : Item(status=' ', treeconflict='C', wc_rev='4'),
914
915 })
916
917 expected_skip = svntest.wc.State('', {
918 })
919
920 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
921 [ DeepTreesTestCase("local_leaf_edit_incoming_tree_del",
922 leaf_edit,
923 tree_del,
924 expected_output,
925 expected_disk,
926 expected_status,
927 expected_skip) ], True)
928
929 #----------------------------------------------------------------------
930 @Issue(2282)
931 def tree_conflicts_on_merge_local_ci_5_2(sbox):
932 "tree conflicts 5.2: leaf del, tree del"
933
934 # 5.2) local leaf del, incoming tree delete
935
936 expected_output = deep_trees_conflict_output
937
938 expected_disk = disk_after_leaf_del
939
940 expected_status = svntest.wc.State('', {
941 '' : Item(status=' M', wc_rev='3'),
942 'D' : Item(status=' ', wc_rev='3'),
943 'F' : Item(status=' ', wc_rev='3'),
944 'DD' : Item(status=' ', wc_rev='3'),
945 'DD/D1' : Item(status=' ', wc_rev='3', treeconflict='C'),
946 'DF' : Item(status=' ', wc_rev='3'),
947 'DF/D1' : Item(status=' ', wc_rev='3', treeconflict='C'),
948 'DDD' : Item(status=' ', wc_rev='3'),
949 'DDD/D1' : Item(status=' ', wc_rev='3', treeconflict='C'),
950 'DDD/D1/D2' : Item(status=' ', wc_rev='3'),
951 'DDF' : Item(status=' ', wc_rev='3'),
952 'DDF/D1' : Item(status=' ', wc_rev='3', treeconflict='C'),
953 'DDF/D1/D2' : Item(status=' ', wc_rev='3'),
954 'D/D1' : Item(status='! ', treeconflict='C'),
955 'F/alpha' : Item(status='! ', treeconflict='C'),
956 })
957
958 expected_skip = svntest.wc.State('', {
959 })
960
961 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
962 [ DeepTreesTestCase("local_leaf_del_incoming_tree_del",
963 leaf_del,
964 tree_del,
965 expected_output,
966 expected_disk,
967 expected_status,
968 expected_skip) ], True)
969
970 #----------------------------------------------------------------------
971 def tree_conflicts_on_merge_local_ci_6(sbox):
972 "tree conflicts 6: tree del, tree del"
973
974 # use case 6, as in notes/tree-conflicts/use-cases.txt
975 # local tree delete, incoming tree delete
976
977 expected_output = deep_trees_conflict_output
978
979 expected_disk = disk_after_tree_del
980
981 expected_status = svntest.wc.State('', {
982 '' : Item(status=' M', wc_rev='3'),
983 'D' : Item(status=' ', wc_rev='3'),
984 'F' : Item(status=' ', wc_rev='3'),
985 'DD' : Item(status=' ', wc_rev='3'),
986 'DF' : Item(status=' ', wc_rev='3'),
987 'DDD' : Item(status=' ', wc_rev='3'),
988 'DDF' : Item(status=' ', wc_rev='3'),
989 'D/D1' : Item(status='! ', treeconflict='C'),
990 'F/alpha' : Item(status='! ', treeconflict='C'),
991 'DD/D1' : Item(status='! ', treeconflict='C'),
992 'DF/D1' : Item(status='! ', treeconflict='C'),
993 'DDD/D1' : Item(status='! ', treeconflict='C'),
994 'DDF/D1' : Item(status='! ', treeconflict='C'),
995 })
996
997 expected_skip = svntest.wc.State('', {
998 })
999
1000 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
1001 [ DeepTreesTestCase("local_tree_del_incoming_tree_del",
1002 tree_del,
1003 tree_del,
1004 expected_output,
1005 expected_disk,
1006 expected_status,
1007 expected_skip) ], True)
1008
1009 #----------------------------------------------------------------------
1010 def tree_conflicts_on_merge_no_local_ci_4_1(sbox):
1011 "tree conflicts 4.1: tree del (no ci), leaf edit"
1012
1013 sbox.build()
1014
1015 # use case 4, as in notes/tree-conflicts/use-cases.txt
1016 # 4.1) local tree delete, incoming leaf edit
1017
1018 expected_output = deep_trees_conflict_output
1019
1020 expected_disk = disk_after_tree_del_no_ci(sbox.wc_dir)
1021
1022 expected_status = svntest.wc.State('', {
1023 '' : Item(status=' M', wc_rev='3'),
1024 'D' : Item(status=' ', wc_rev='3'),
1025 'D/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1026 'DD' : Item(status=' ', wc_rev='3'),
1027 'DD/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1028 'DD/D1/D2' : Item(status='D ', wc_rev='3'),
1029 'DDD' : Item(status=' ', wc_rev='3'),
1030 'DDD/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1031 'DDD/D1/D2' : Item(status='D ', wc_rev='3'),
1032 'DDD/D1/D2/D3' : Item(status='D ', wc_rev='3'),
1033 'DDF' : Item(status=' ', wc_rev='3'),
1034 'DDF/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1035 'DDF/D1/D2' : Item(status='D ', wc_rev='3'),
1036 'DDF/D1/D2/gamma' : Item(status='D ', wc_rev='3'),
1037 'DF' : Item(status=' ', wc_rev='3'),
1038 'DF/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1039 'DF/D1/beta' : Item(status='D ', wc_rev='3'),
1040 'F' : Item(status=' ', wc_rev='3'),
1041 'F/alpha' : Item(status='D ', treeconflict='C', wc_rev='3'),
1042 })
1043
1044 expected_skip = svntest.wc.State('', {
1045 })
1046
1047 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
1048 [ DeepTreesTestCase(
1049 "local_tree_del_incoming_leaf_edit",
1050 tree_del,
1051 leaf_edit,
1052 expected_output,
1053 expected_disk,
1054 expected_status,
1055 expected_skip,
1056 ) ], False)
1057
1058 #----------------------------------------------------------------------
1059 def tree_conflicts_on_merge_no_local_ci_4_2(sbox):
1060 "tree conflicts 4.2: tree del (no ci), leaf del"
1061
1062 sbox.build()
1063
1064 # 4.2) local tree delete, incoming leaf delete
1065
1066 expected_output = deep_trees_conflict_output
1067
1068 expected_disk = disk_after_tree_del_no_ci(sbox.wc_dir)
1069
1070 expected_status = svntest.wc.State('', {
1071 '' : Item(status=' M', wc_rev='3'),
1072 'D' : Item(status=' ', wc_rev='3'),
1073 'D/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1074 'DD' : Item(status=' ', wc_rev='3'),
1075 'DD/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1076 'DD/D1/D2' : Item(status='D ', wc_rev='3'),
1077 'DDD' : Item(status=' ', wc_rev='3'),
1078 'DDD/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1079 'DDD/D1/D2' : Item(status='D ', wc_rev='3'),
1080 'DDD/D1/D2/D3' : Item(status='D ', wc_rev='3'),
1081 'DDF' : Item(status=' ', wc_rev='3'),
1082 'DDF/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1083 'DDF/D1/D2' : Item(status='D ', wc_rev='3'),
1084 'DDF/D1/D2/gamma' : Item(status='D ', wc_rev='3'),
1085 'DF' : Item(status=' ', wc_rev='3'),
1086 'DF/D1' : Item(status='D ', treeconflict='C', wc_rev='3'),
1087 'DF/D1/beta' : Item(status='D ', wc_rev='3'),
1088 'F' : Item(status=' ', wc_rev='3'),
1089 'F/alpha' : Item(status='D ', treeconflict='C', wc_rev='3'),
1090 })
1091
1092 expected_skip = svntest.wc.State('', {
1093 })
1094
1095 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
1096 [ DeepTreesTestCase(
1097 "local_tree_del_incoming_leaf_del",
1098 tree_del,
1099 leaf_del,
1100 expected_output,
1101 expected_disk,
1102 expected_status,
1103 expected_skip,
1104 ) ], False)
1105
1106 #----------------------------------------------------------------------
1107 def tree_conflicts_on_merge_no_local_ci_5_1(sbox):
1108 "tree conflicts 5.1: leaf edit (no ci), tree del"
1109
1110
1111 # use case 5, as in notes/tree-conflicts/use-cases.txt
1112 # 5.1) local leaf edit, incoming tree delete
1113
1114 expected_output = deep_trees_conflict_output
1115
1116 expected_disk = disk_after_leaf_edit
1117
1118 expected_status = svntest.wc.State('', {
1119 '' : Item(status=' M', wc_rev='3'),
1120 'D' : Item(status=' ', wc_rev='3'),
1121 'D/D1' : Item(status=' M', treeconflict='C', wc_rev='3'),
1122 'D/D1/delta' : Item(status='A ', wc_rev='0'),
1123 'DD' : Item(status=' ', wc_rev='3'),
1124 'DD/D1' : Item(status=' ', treeconflict='C', wc_rev='3'),
1125 'DD/D1/D2' : Item(status=' M', wc_rev='3'),
1126 'DD/D1/D2/epsilon' : Item(status='A ', wc_rev='0'),
1127 'DDD' : Item(status=' ', wc_rev='3'),
1128 'DDD/D1' : Item(status=' ', treeconflict='C', wc_rev='3'),
1129 'DDD/D1/D2' : Item(status=' ', wc_rev='3'),
1130 'DDD/D1/D2/D3' : Item(status=' M', wc_rev='3'),
1131 'DDD/D1/D2/D3/zeta' : Item(status='A ', wc_rev='0'),
1132 'DDF' : Item(status=' ', wc_rev='3'),
1133 'DDF/D1' : Item(status=' ', treeconflict='C', wc_rev='3'),
1134 'DDF/D1/D2' : Item(status=' ', wc_rev='3'),
1135 'DDF/D1/D2/gamma' : Item(status='MM', wc_rev='3'),
1136 'DF' : Item(status=' ', wc_rev='3'),
1137 'DF/D1' : Item(status=' ', treeconflict='C', wc_rev='3'),
1138 'DF/D1/beta' : Item(status='MM', wc_rev='3'),
1139 'F' : Item(status=' ', wc_rev='3'),
1140 'F/alpha' : Item(status='MM', treeconflict='C', wc_rev='3'),
1141 })
1142
1143 expected_skip = svntest.wc.State('', {
1144 })
1145
1146 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
1147 [ DeepTreesTestCase(
1148 "local_leaf_edit_incoming_tree_del",
1149 leaf_edit,
1150 tree_del,
1151 expected_output,
1152 expected_disk,
1153 expected_status,
1154 expected_skip,
1155 ) ], False)
1156
1157 #----------------------------------------------------------------------
1158 @Issue(2282)
1159 def tree_conflicts_on_merge_no_local_ci_5_2(sbox):
1160 "tree conflicts 5.2: leaf del (no ci), tree del"
1161
1162 # 5.2) local leaf del, incoming tree delete
1163
1164 expected_output = deep_trees_conflict_output
1165
1166 expected_disk = disk_after_leaf_del_no_ci(sbox.wc_dir)
1167
1168 expected_status = svntest.wc.State('', {
1169 '' : Item(status=' M', wc_rev='3'),
1170 'D' : Item(status=' ', wc_rev='3'),
1171 'D/D1' : Item(status='D ', wc_rev='3', treeconflict='C'),
1172 'F' : Item(status=' ', wc_rev='3'),
1173 'F/alpha' : Item(status='D ', wc_rev='3', treeconflict='C'),
1174 'DD' : Item(status=' ', wc_rev='3'),
1175 'DD/D1' : Item(status=' ', wc_rev='3', treeconflict='C'),
1176 'DD/D1/D2' : Item(status='D ', wc_rev='3'),
1177 'DF' : Item(status=' ', wc_rev='3'),
1178 'DF/D1' : Item(status=' ', wc_rev='3', treeconflict='C'),
1179 'DF/D1/beta' : Item(status='D ', wc_rev='3'),
1180 'DDD' : Item(status=' ', wc_rev='3'),
1181 'DDD/D1' : Item(status=' ', wc_rev='3', treeconflict='C'),
1182 'DDD/D1/D2' : Item(status=' ', wc_rev='3'),
1183 'DDD/D1/D2/D3' : Item(status='D ', wc_rev='3'),
1184 'DDF' : Item(status=' ', wc_rev='3'),
1185 'DDF/D1' : Item(status=' ', wc_rev='3', treeconflict='C'),
1186 'DDF/D1/D2' : Item(status=' ', wc_rev='3'),
1187 'DDF/D1/D2/gamma' : Item(status='D ', wc_rev='3'),
1188 })
1189
1190 expected_skip = svntest.wc.State('', {
1191 })
1192
1193 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
1194 [ DeepTreesTestCase(
1195 "local_leaf_del_incoming_tree_del",
1196 leaf_del,
1197 tree_del,
1198 expected_output,
1199 expected_disk,
1200 expected_status,
1201 expected_skip,
1202 ) ], False)
1203
1204 #----------------------------------------------------------------------
1205 def tree_conflicts_on_merge_no_local_ci_6(sbox):
1206 "tree conflicts 6: tree del (no ci), tree del"
1207
1208 sbox.build()
1209
1210 # use case 6, as in notes/tree-conflicts/use-cases.txt
1211 # local tree delete, incoming tree delete
1212
1213 expected_output = deep_trees_conflict_output
1214
1215 expected_disk = disk_after_tree_del_no_ci(sbox.wc_dir)
1216
1217 expected_status = svntest.wc.State('', {
1218 '' : Item(status=' M', wc_rev='3'),
1219 'D' : Item(status=' ', wc_rev='3'),
1220 'D/D1' : Item(status='D ', wc_rev='3', treeconflict='C'),
1221 'F' : Item(status=' ', wc_rev='3'),
1222 'F/alpha' : Item(status='D ', wc_rev='3', treeconflict='C'),
1223 'DD' : Item(status=' ', wc_rev='3'),
1224 'DD/D1' : Item(status='D ', wc_rev='3', treeconflict='C'),
1225 'DD/D1/D2' : Item(status='D ', wc_rev='3'),
1226 'DF' : Item(status=' ', wc_rev='3'),
1227 'DF/D1' : Item(status='D ', wc_rev='3', treeconflict='C'),
1228 'DF/D1/beta' : Item(status='D ', wc_rev='3'),
1229 'DDD' : Item(status=' ', wc_rev='3'),
1230 'DDD/D1' : Item(status='D ', wc_rev='3', treeconflict='C'),
1231 'DDD/D1/D2' : Item(status='D ', wc_rev='3'),
1232 'DDD/D1/D2/D3' : Item(status='D ', wc_rev='3'),
1233 'DDF' : Item(status=' ', wc_rev='3'),
1234 'DDF/D1' : Item(status='D ', wc_rev='3', treeconflict='C'),
1235 'DDF/D1/D2' : Item(status='D ', wc_rev='3'),
1236 'DDF/D1/D2/gamma' : Item(status='D ', wc_rev='3'),
1237 })
1238
1239 expected_skip = svntest.wc.State('', {
1240 })
1241
1242 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
1243 [ DeepTreesTestCase(
1244 "local_tree_del_incoming_tree_del",
1245 tree_del,
1246 tree_del,
1247 expected_output,
1248 expected_disk,
1249 expected_status,
1250 expected_skip,
1251 ) ], False)
1252
1253 #----------------------------------------------------------------------
1254 def tree_conflicts_merge_edit_onto_missing(sbox):
1255 "tree conflicts: tree missing, leaf edit"
1256
1257 # local tree missing (via shell delete), incoming leaf edit
1258
1259 # Note: In 1.7 merge tracking aware merges raise an error if the
1260 # merge target has subtrees missing due to a shell delete. To
1261 # preserve the original intent of this test we'll run the merge
1262 # with the --ignore-ancestry option, which neither considers nor
1263 # records mergeinfo. With this option the merge should "succeed"
1264 # while skipping the missing paths. Of course with no mergeinfo
1265 # recorded and everything skipped, there is nothing to commit, so
1266 # unlike most of the tree conflict tests we don't bother with the
1267 # final commit step.
1268
1269 sbox.build()
1270 expected_output = wc.State('', {
1271 # Below the skips
1272 'DD/D1/D2' : Item(status=' ', treeconflict='U'),
1273 'DD/D1/D2/epsilon' : Item(status=' ', treeconflict='A'),
1274 'DDD/D1/D2/D3' : Item(status=' ', treeconflict='U'),
1275 'DDD/D1/D2/D3/zeta' : Item(status=' ', treeconflict='A'),
1276 'DDF/D1/D2/gamma' : Item(status=' ', treeconflict='U'),
1277 'D/D1/delta' : Item(status=' ', treeconflict='A'),
1278 'DF/D1/beta' : Item(status=' ', treeconflict='U'),
1279 })
1280
1281 expected_disk = disk_after_tree_del
1282
1283 # Don't expect any mergeinfo property changes because we run
1284 # the merge with the --ignore-ancestry option.
1285 expected_status = svntest.wc.State('', {
1286 '' : Item(status=' ', wc_rev=3),
1287 'F' : Item(status=' ', wc_rev=3),
1288 'F/alpha' : Item(status='! ', wc_rev=3),
1289 'D' : Item(status=' ', wc_rev=3),
1290 'D/D1' : Item(status='! ', wc_rev='3', entry_rev='?'),
1291 'DF' : Item(status=' ', wc_rev=3),
1292 'DF/D1' : Item(status='! ', wc_rev=3, entry_rev='?'),
1293 'DF/D1/beta' : Item(status='! ', wc_rev=3),
1294 'DD' : Item(status=' ', wc_rev=3),
1295 'DD/D1' : Item(status='! ', wc_rev=3, entry_rev='?'),
1296 'DD/D1/D2' : Item(status='! ', wc_rev=3),
1297 'DDF' : Item(status=' ', wc_rev=3),
1298 'DDF/D1' : Item(status='! ', wc_rev=3, entry_rev='?'),
1299 'DDF/D1/D2' : Item(status='! ', wc_rev=3),
1300 'DDF/D1/D2/gamma' : Item(status='! ', wc_rev=3),
1301 'DDD' : Item(status=' ', wc_rev=3),
1302 'DDD/D1' : Item(status='! ', wc_rev=3, entry_rev='?'),
1303 'DDD/D1/D2' : Item(status='! ', wc_rev=3),
1304 'DDD/D1/D2/D3' : Item(status='! ', wc_rev=3),
1305 })
1306
1307 expected_skip = svntest.wc.State('', {
1308 'F/alpha' : Item(verb='Skipped missing target'),
1309 # Obstruction handling improvements in 1.7 and 1.8 added
1310 'DDD/D1' : Item(verb='Skipped missing target'),
1311 'DF/D1' : Item(verb='Skipped missing target'),
1312 'DDF/D1' : Item(verb='Skipped missing target'),
1313 'D/D1' : Item(verb='Skipped missing target'),
1314 'DD/D1' : Item(verb='Skipped missing target'),
1315 'F/alpha' : Item(verb='Skipped missing target'),
1316 })
1317
1318 # Currently this test fails because some parts of the merge
1319 # start succeeding.
1320 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
1321 [ DeepTreesTestCase(
1322 "local_tree_missing_incoming_leaf_edit",
1323 svntest.deeptrees.deep_trees_rmtree,
1324 leaf_edit,
1325 expected_output,
1326 expected_disk,
1327 expected_status,
1328 expected_skip,
1329 ) ], False, do_commit_conflicts=False, ignore_ancestry=True)
1330
1331 #----------------------------------------------------------------------
1332 def tree_conflicts_merge_del_onto_missing(sbox):
1333 "tree conflicts: tree missing, leaf del"
1334
1335 # local tree missing (via shell delete), incoming leaf edit
1336
1337 # Note: In 1.7 merge tracking aware merges raise an error if the
1338 # merge target has subtrees missing due to a shell delete. To
1339 # preserve the original intent of this test we'll run the merge
1340 # with the --ignore-ancestry option, which neither considers nor
1341 # records mergeinfo. With this option the merge should "succeed"
1342 # while skipping the missing paths. Of course with no mergeinfo
1343 # recorded and everything skipped, there is nothing to commit, so
1344 # unlike most of the tree conflict tests we don't bother with the
1345 # final commit step.
1346
1347 sbox.build()
1348 expected_output = wc.State('', {
1349 # Below the skips
1350 'DF/D1/beta' : Item(status=' ', treeconflict='D'),
1351 'DDD/D1/D2/D3' : Item(status=' ', treeconflict='D'),
1352 'DD/D1/D2' : Item(status=' ', treeconflict='D'),
1353 'DDF/D1/D2/gamma' : Item(status=' ', treeconflict='D'),
1354 })
1355
1356 expected_disk = disk_after_tree_del
1357
1358 # Don't expect any mergeinfo property changes because we run
1359 # the merge with the --ignore-ancestry option.
1360 expected_status = svntest.wc.State('', {
1361 '' : Item(status=' ', wc_rev=3),
1362 'F' : Item(status=' ', wc_rev=3),
1363 'F/alpha' : Item(status='! ', wc_rev=3),
1364 'D' : Item(status=' ', wc_rev=3),
1365 'D/D1' : Item(status='! ', wc_rev=3),
1366 'DF' : Item(status=' ', wc_rev=3),
1367 'DF/D1' : Item(status='! ', wc_rev=3),
1368 'DF/D1/beta' : Item(status='! ', wc_rev=3),
1369 'DD' : Item(status=' ', wc_rev=3),
1370 'DD/D1' : Item(status='! ', wc_rev=3),
1371 'DD/D1/D2' : Item(status='! ', wc_rev=3),
1372 'DDF' : Item(status=' ', wc_rev=3),
1373 'DDF/D1' : Item(status='! ', wc_rev=3),
1374 'DDF/D1/D2' : Item(status='! ', wc_rev=3),
1375 'DDF/D1/D2/gamma' : Item(status='! ', wc_rev=3),
1376 'DDD' : Item(status=' ', wc_rev=3),
1377 'DDD/D1' : Item(status='! ', wc_rev=3),
1378 'DDD/D1/D2' : Item(status='! ', wc_rev=3),
1379 'DDD/D1/D2/D3' : Item(status='! ', wc_rev=3),
1380 })
1381
1382 expected_skip = svntest.wc.State('', {
1383 'F/alpha' : Item(verb='Skipped missing target'),
1384 'D/D1' : Item(verb='Skipped missing target'),
1385 # Obstruction handling improvements in 1.7 and 1.8 added
1386 'DDD/D1' : Item(verb='Skipped missing target'),
1387 'DD/D1' : Item(verb='Skipped missing target'),
1388 'DDF/D1' : Item(verb='Skipped missing target'),
1389 'DF/D1' : Item(verb='Skipped missing target'),
1390 })
1391
1392 svntest.deeptrees.deep_trees_run_tests_scheme_for_merge(sbox,
1393 [ DeepTreesTestCase(
1394 "local_tree_missing_incoming_leaf_del",
1395 svntest.deeptrees.deep_trees_rmtree,
1396 leaf_del,
1397 expected_output,
1398 expected_disk,
1399 expected_status,
1400 expected_skip,
1401 ) ], False, do_commit_conflicts=False, ignore_ancestry=True)
1402
1403 #----------------------------------------------------------------------
1404 def merge_replace_setup(sbox):
1405 "helper for merge_replace_causes_tree_conflict*()."
1406
1407 # svntest.factory.make(sbox,r"""
1408 # # make a branch of A
1409 # svn cp $URL/A $URL/branch
1410 # svn up
1411 # # ACTIONS ON THE MERGE SOURCE (branch)
1412 # # various deletes of files and dirs
1413 # svn delete branch/mu branch/B/E branch/D/G/pi branch/D/H
1414 # svn ci
1415 # svn up
1416 #
1417 # # replacements.
1418 # # file-with-file
1419 # echo "replacement for mu" > branch/mu
1420 # svn add branch/mu
1421 # # dir-with-dir
1422 # svn mkdir branch/B/E
1423 # svn ps propname propval branch/B/E
1424 # # file-with-dir
1425 # svn mkdir branch/D/G/pi
1426 # svn ps propname propval branch/D/G/pi
1427 # # dir-with-file
1428 # echo "replacement for H" > branch/D/H
1429 # svn add branch/D/H
1430 # svn ci
1431 # """)
1432
1433 sbox.build()
1434 wc_dir = sbox.wc_dir
1435 url = sbox.repo_url
1436
1437 branch_B_E = os.path.join(wc_dir, 'branch', 'B', 'E')
1438 branch_D_G_pi = os.path.join(wc_dir, 'branch', 'D', 'G', 'pi')
1439 branch_D_H = os.path.join(wc_dir, 'branch', 'D', 'H')
1440 branch_mu = os.path.join(wc_dir, 'branch', 'mu')
1441 url_A = url + '/A'
1442 url_branch = url + '/branch'
1443
1444 # make a branch of A
1445 # svn cp $URL/A $URL/branch
1446 expected_stdout = [
1447 'Committing transaction...\n',
1448 'Committed revision 2.\n',
1449 ]
1450
1451 actions.run_and_verify_svn2(expected_stdout, [], 0, 'cp', url_A,
1452 url_branch, '-m', 'copy log')
1453
1454 # svn up
1455 expected_output = svntest.wc.State(wc_dir, {
1456 'branch' : Item(status='A '),
1457 'branch/B' : Item(status='A '),
1458 'branch/B/F' : Item(status='A '),
1459 'branch/B/E' : Item(status='A '),
1460 'branch/B/E/beta' : Item(status='A '),
1461 'branch/B/E/alpha' : Item(status='A '),
1462 'branch/B/lambda' : Item(status='A '),
1463 'branch/D' : Item(status='A '),
1464 'branch/D/H' : Item(status='A '),
1465 'branch/D/H/psi' : Item(status='A '),
1466 'branch/D/H/chi' : Item(status='A '),
1467 'branch/D/H/omega' : Item(status='A '),
1468 'branch/D/G' : Item(status='A '),
1469 'branch/D/G/tau' : Item(status='A '),
1470 'branch/D/G/pi' : Item(status='A '),
1471 'branch/D/G/rho' : Item(status='A '),
1472 'branch/D/gamma' : Item(status='A '),
1473 'branch/C' : Item(status='A '),
1474 'branch/mu' : Item(status='A '),
1475 })
1476
1477 expected_disk = svntest.main.greek_state.copy()
1478 expected_disk.add({
1479 'branch' : Item(),
1480 'branch/D' : Item(),
1481 'branch/D/G' : Item(),
1482 'branch/D/G/rho' : Item(contents="This is the file 'rho'.\n"),
1483 'branch/D/G/tau' : Item(contents="This is the file 'tau'.\n"),
1484 'branch/D/G/pi' : Item(contents="This is the file 'pi'.\n"),
1485 'branch/D/H' : Item(),
1486 'branch/D/H/omega' : Item(contents="This is the file 'omega'.\n"),
1487 'branch/D/H/chi' : Item(contents="This is the file 'chi'.\n"),
1488 'branch/D/H/psi' : Item(contents="This is the file 'psi'.\n"),
1489 'branch/D/gamma' : Item(contents="This is the file 'gamma'.\n"),
1490 'branch/B' : Item(),
1491 'branch/B/E' : Item(),
1492 'branch/B/E/alpha' : Item(contents="This is the file 'alpha'.\n"),
1493 'branch/B/E/beta' : Item(contents="This is the file 'beta'.\n"),
1494 'branch/B/F' : Item(),
1495 'branch/B/lambda' : Item(contents="This is the file 'lambda'.\n"),
1496 'branch/mu' : Item(contents="This is the file 'mu'.\n"),
1497 'branch/C' : Item(),
1498 })
1499
1500 expected_status = actions.get_virginal_state(wc_dir, 2)
1501 expected_status.add({
1502 'branch' : Item(status=' ', wc_rev='2'),
1503 'branch/D' : Item(status=' ', wc_rev='2'),
1504 'branch/D/gamma' : Item(status=' ', wc_rev='2'),
1505 'branch/D/H' : Item(status=' ', wc_rev='2'),
1506 'branch/D/H/omega' : Item(status=' ', wc_rev='2'),
1507 'branch/D/H/chi' : Item(status=' ', wc_rev='2'),
1508 'branch/D/H/psi' : Item(status=' ', wc_rev='2'),
1509 'branch/D/G' : Item(status=' ', wc_rev='2'),
1510 'branch/D/G/tau' : Item(status=' ', wc_rev='2'),
1511 'branch/D/G/pi' : Item(status=' ', wc_rev='2'),
1512 'branch/D/G/rho' : Item(status=' ', wc_rev='2'),
1513 'branch/B' : Item(status=' ', wc_rev='2'),
1514 'branch/B/F' : Item(status=' ', wc_rev='2'),
1515 'branch/B/E' : Item(status=' ', wc_rev='2'),
1516 'branch/B/E/beta' : Item(status=' ', wc_rev='2'),
1517 'branch/B/E/alpha' : Item(status=' ', wc_rev='2'),
1518 'branch/B/lambda' : Item(status=' ', wc_rev='2'),
1519 'branch/C' : Item(status=' ', wc_rev='2'),
1520 'branch/mu' : Item(status=' ', wc_rev='2'),
1521 })
1522
1523 actions.run_and_verify_update(wc_dir, expected_output, expected_disk,
1524 expected_status)
1525
1526 # ACTIONS ON THE MERGE SOURCE (branch)
1527 # various deletes of files and dirs
1528 # svn delete branch/mu branch/B/E branch/D/G/pi branch/D/H
1529 expected_stdout = verify.UnorderedOutput([
1530 'D ' + branch_mu + '\n',
1531 'D ' + os.path.join(branch_B_E, 'alpha') + '\n',
1532 'D ' + os.path.join(branch_B_E, 'beta') + '\n',
1533 'D ' + branch_B_E + '\n',
1534 'D ' + branch_D_G_pi + '\n',
1535 'D ' + os.path.join(branch_D_H, 'chi') + '\n',
1536 'D ' + os.path.join(branch_D_H, 'omega') + '\n',
1537 'D ' + os.path.join(branch_D_H, 'psi') + '\n',
1538 'D ' + branch_D_H + '\n',
1539 ])
1540
1541 actions.run_and_verify_svn2(expected_stdout, [], 0, 'delete',
1542 branch_mu, branch_B_E, branch_D_G_pi, branch_D_H)
1543
1544 # svn ci
1545 expected_output = svntest.wc.State(wc_dir, {
1546 'branch/D/G/pi' : Item(verb='Deleting'),
1547 'branch/D/H' : Item(verb='Deleting'),
1548 'branch/mu' : Item(verb='Deleting'),
1549 'branch/B/E' : Item(verb='Deleting'),
1550 })
1551
1552 expected_status.remove('branch/mu', 'branch/D/H', 'branch/D/H/omega',
1553 'branch/D/H/chi', 'branch/D/H/psi', 'branch/D/G/pi', 'branch/B/E',
1554 'branch/B/E/beta', 'branch/B/E/alpha')
1555
1556 actions.run_and_verify_commit(wc_dir, expected_output, expected_status)
1557
1558 # svn up
1559 expected_output = svntest.wc.State(wc_dir, {})
1560
1561 expected_disk.remove('branch/mu', 'branch/D/H', 'branch/D/H/omega',
1562 'branch/D/H/chi', 'branch/D/H/psi', 'branch/D/G/pi', 'branch/B/E',
1563 'branch/B/E/alpha', 'branch/B/E/beta')
1564
1565 expected_status.tweak(wc_rev='3')
1566
1567 actions.run_and_verify_update(wc_dir, expected_output, expected_disk,
1568 expected_status)
1569
1570 # replacements.
1571 # file-with-file
1572 # echo "replacement for mu" > branch/mu
1573 main.file_write(branch_mu, 'replacement for mu')
1574
1575 # svn add branch/mu
1576 expected_stdout = ['A ' + branch_mu + '\n']
1577
1578 actions.run_and_verify_svn2(expected_stdout, [], 0, 'add',
1579 branch_mu)
1580
1581 # dir-with-dir
1582 # svn mkdir branch/B/E
1583 expected_stdout = ['A ' + branch_B_E + '\n']
1584
1585 actions.run_and_verify_svn2(expected_stdout, [], 0, 'mkdir',
1586 branch_B_E)
1587
1588 # svn ps propname propval branch/B/E
1589 expected_stdout = ["property 'propname' set on '" + branch_B_E + "'\n"]
1590
1591 actions.run_and_verify_svn2(expected_stdout, [], 0, 'ps',
1592 'propname', 'propval', branch_B_E)
1593
1594 # file-with-dir
1595 # svn mkdir branch/D/G/pi
1596 expected_stdout = ['A ' + branch_D_G_pi + '\n']
1597
1598 actions.run_and_verify_svn2(expected_stdout, [], 0, 'mkdir',
1599 branch_D_G_pi)
1600
1601 # svn ps propname propval branch/D/G/pi
1602 expected_stdout = ["property 'propname' set on '" + branch_D_G_pi + "'\n"]
1603
1604 actions.run_and_verify_svn2(expected_stdout, [], 0, 'ps',
1605 'propname', 'propval', branch_D_G_pi)
1606
1607 # dir-with-file
1608 # echo "replacement for H" > branch/D/H
1609 main.file_write(branch_D_H, 'replacement for H')
1610
1611 # svn add branch/D/H
1612 expected_stdout = ['A ' + branch_D_H + '\n']
1613
1614 actions.run_and_verify_svn2(expected_stdout, [], 0, 'add',
1615 branch_D_H)
1616
1617 # svn ci
1618 expected_output = svntest.wc.State(wc_dir, {
1619 'branch/D/G/pi' : Item(verb='Adding'),
1620 'branch/D/H' : Item(verb='Adding'),
1621 'branch/mu' : Item(verb='Adding'),
1622 'branch/B/E' : Item(verb='Adding'),
1623 })
1624
1625 expected_status.add({
1626 'branch/D/G/pi' : Item(status=' ', wc_rev='4'),
1627 'branch/D/H' : Item(status=' ', wc_rev='4'),
1628 'branch/B/E' : Item(status=' ', wc_rev='4'),
1629 'branch/mu' : Item(status=' ', wc_rev='4'),
1630 })
1631
1632 actions.run_and_verify_commit(wc_dir, expected_output, expected_status)
1633
1634 return expected_disk, expected_status
1635
1636 #----------------------------------------------------------------------
1637 # ra_serf causes duplicate notifications with this test:
1638 @Issue(3802)
1639 def merge_replace_causes_tree_conflict(sbox):
1640 "replace vs. edit tree-conflicts"
1641
1642 expected_disk, expected_status = merge_replace_setup(sbox)
1643
1644 # svntest.factory.make(sbox,r"""
1645 # # ACTIONS ON THE MERGE TARGET (A)
1646 # # local mods to conflict with merge source
1647 # echo modified > A/mu
1648 # svn ps propname otherpropval A/B/E
1649 # echo modified > A/D/G/pi
1650 # svn ps propname propval A/D/H
1651 # svn merge $URL/A $URL/branch A
1652 # svn st
1653 # """, prev_status=expected_status, prev_disk=expected_disk)
1654
1655 wc_dir = sbox.wc_dir
1656 url = sbox.repo_url
1657
1658 A = os.path.join(wc_dir, 'A')
1659 A_B_E = os.path.join(wc_dir, 'A', 'B', 'E')
1660 A_D_G_pi = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')
1661 A_D_H = os.path.join(wc_dir, 'A', 'D', 'H')
1662 A_mu = os.path.join(wc_dir, 'A', 'mu')
1663 url_A = url + '/A'
1664 url_branch = url + '/branch'
1665
1666 # ACTIONS ON THE MERGE TARGET (A)
1667 # local mods to conflict with merge source
1668 # echo modified > A/mu
1669 main.file_write(A_mu, 'modified')
1670
1671 # svn ps propname otherpropval A/B/E
1672 expected_stdout = ["property 'propname' set on '" + A_B_E + "'\n"]
1673
1674 actions.run_and_verify_svn2(expected_stdout, [], 0, 'ps',
1675 'propname', 'otherpropval', A_B_E)
1676
1677 # echo modified > A/D/G/pi
1678 main.file_write(A_D_G_pi, 'modified')
1679
1680 # svn ps propname propval A/D/H
1681 expected_stdout = ["property 'propname' set on '" + A_D_H + "'\n"]
1682
1683 actions.run_and_verify_svn2(expected_stdout, [], 0, 'ps',
1684 'propname', 'propval', A_D_H)
1685
1686 # svn merge $URL/A $URL/branch A
1687 expected_stdout = expected_merge_output(None, [
1688 # merge
1689 ' C ' + A_B_E + '\n',
1690 ' C ' + A_mu + '\n',
1691 ' C ' + A_D_G_pi + '\n',
1692 ' C ' + A_D_H + '\n',
1693 # mergeinfo
1694 ' U ' + A + '\n',
1695 ], target=A, two_url=True, tree_conflicts=4)
1696
1697 actions.run_and_verify_svn2(expected_stdout, [], 0, 'merge',
1698 url_A, url_branch, A, '--accept=postpone')
1699
1700 # svn st
1701 expected_status.tweak('A', status=' M')
1702 expected_status.tweak('A/D/G/pi', 'A/mu', status='M ', treeconflict='C')
1703 expected_status.tweak('A/D/H', status=' M', treeconflict='C')
1704 expected_status.tweak('A/B/E', status=' M', treeconflict='C')
1705
1706 actions.run_and_verify_status(wc_dir, expected_status)
1707
1708 #----------------------------------------------------------------------
1709 @Issue(3806)
1710 def merge_replace_causes_tree_conflict2(sbox):
1711 "replace vs. delete tree-conflicts"
1712
1713 expected_disk, expected_status = merge_replace_setup(sbox)
1714
1715 # svntest.factory.make(sbox,r"""
1716 # # ACTIONS ON THE MERGE TARGET (A)
1717 # # local mods to conflict with merge source
1718 # # Delete each of the files and dirs to be replaced by the merge.
1719 # svn delete A/mu A/B/E A/D/G/pi A/D/H
1720 # # Merge them one by one to see all the errors.
1721 # svn merge $URL/A/mu $URL/branch/mu A/mu
1722 # svn merge $URL/A/B $URL/branch/B A/B
1723 # svn merge --depth=immediates $URL/A/D $URL/branch/D A/D
1724 # svn merge $URL/A/D/G $URL/branch/D/G A/D/G
1725 # svn st
1726 # """, prev_disk=expected_disk, prev_status=expected_status)
1727
1728 wc_dir = sbox.wc_dir
1729 url = sbox.repo_url
1730
1731 A_B = os.path.join(wc_dir, 'A', 'B')
1732 A_B_E = os.path.join(wc_dir, 'A', 'B', 'E')
1733 A_D = os.path.join(wc_dir, 'A', 'D')
1734 A_D_G = os.path.join(wc_dir, 'A', 'D', 'G')
1735 A_D_G_pi = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')
1736 A_D_H = os.path.join(wc_dir, 'A', 'D', 'H')
1737 A = os.path.join(wc_dir, 'A')
1738 A_mu = os.path.join(wc_dir, 'A', 'mu')
1739 url_A_B = url + '/A/B'
1740 url_A_D = url + '/A/D'
1741 url_A_D_G = url + '/A/D/G'
1742 url_A = url + '/A'
1743 url_branch_B = url + '/branch/B'
1744 url_branch_D = url + '/branch/D'
1745 url_branch_D_G = url + '/branch/D/G'
1746 url_branch = url + '/branch'
1747
1748 # ACTIONS ON THE MERGE TARGET (A)
1749 # local mods to conflict with merge source
1750 # Delete each of the files and dirs to be replaced by the merge.
1751 # svn delete A/mu A/B/E A/D/G/pi A/D/H
1752 expected_stdout = verify.UnorderedOutput([
1753 'D ' + A_mu + '\n',
1754 'D ' + os.path.join(A_B_E, 'alpha') + '\n',
1755 'D ' + os.path.join(A_B_E, 'beta') + '\n',
1756 'D ' + A_B_E + '\n',
1757 'D ' + A_D_G_pi + '\n',
1758 'D ' + os.path.join(A_D_H, 'chi') + '\n',
1759 'D ' + os.path.join(A_D_H, 'omega') + '\n',
1760 'D ' + os.path.join(A_D_H, 'psi') + '\n',
1761 'D ' + A_D_H + '\n',
1762 ])
1763 actions.run_and_verify_svn2(expected_stdout, [], 0, 'delete',
1764 A_mu, A_B_E, A_D_G_pi, A_D_H)
1765 expected_status.tweak('A/B/E', 'A/B/E/alpha', 'A/B/E/beta', 'A/D/G/pi',
1766 'A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi',
1767 status='D ')
1768
1769 # H is now a file. This hides the status of the descendants.
1770 expected_status.remove('A/D/H/chi', 'A/D/H/psi', 'A/D/H/omega')
1771
1772 # Merge them one by one to see all the errors.
1773
1774 ### A file-with-file replacement onto a deleted file.
1775 # svn merge $URL/A/mu $URL/branch/mu A/mu
1776 expected_stdout = expected_merge_output(None, [
1777 ' C ' + A_mu + '\n', # merge
1778 'A ' + A_mu + '\n', # merge
1779 " U " + A + "\n", # mergeinfo
1780 " U " + A_mu + "\n", # mergeinfo -> 'RM' status
1781 ], target=A, two_url=True, tree_conflicts=1)
1782
1783 actions.run_and_verify_svn2(expected_stdout, [], 0, 'merge',
1784 url_A, url_branch, A, '--depth=files', '--accept=postpone')
1785 # New mergeinfo describing the merge.
1786 expected_status.tweak('A', status=' M')
1787 # Currently this fails because the local status is 'D'eleted rather than
1788 # 'R'eplaced with history:
1789 #
1790 # D C merge_tree_conflict_tests-23\A\mu
1791 # > local delete, incoming replace upon merge
1792 expected_status.tweak('A/mu', status='RM', wc_rev='-', copied='+',
1793 treeconflict='C')
1794
1795 ### A dir-with-dir replacement onto a deleted directory.
1796 # svn merge $URL/A/B $URL/branch/B A/B
1797 expected_stdout = expected_merge_output(None, [
1798 ' C ' + A_B_E + '\n', # merge
1799 'A ' + A_B_E + '\n', # merge
1800 " U " + A_B + "\n", # mergeinfo
1801 ], target=A_B, two_url=True, tree_conflicts=1)
1802
1803 actions.run_and_verify_svn2(expected_stdout, [], 0, 'merge',
1804 url_A_B, url_branch_B, A_B, '--accept=postpone')
1805 # New mergeinfo describing the merge.
1806 expected_status.tweak('A/B', status=' M')
1807 # Currently this fails because the local status shows a property mod (and
1808 # the TC type is listed as incoming delete, not incoming replace):
1809 #
1810 # RM + C merge_tree_conflict_tests-23\A\B\E
1811 # > local delete, incoming delete upon merge
1812 expected_status.tweak('A/B/E', status='R ', wc_rev='-', copied='+',
1813 treeconflict='C')
1814
1815 ### A dir-with-file replacement onto a deleted directory.
1816 # svn merge --depth=immediates $URL/A/D $URL/branch/D A/D
1817 expected_stdout = expected_merge_output(None, [
1818 ' C ' + A_D_H + '\n', # merge
1819 'A ' + A_D_H + '\n', # merge
1820 " U " + A_D + "\n", # mergeinfo
1821 ], target=A_D, two_url=True, tree_conflicts=1)
1822
1823 actions.run_and_verify_svn2(expected_stdout, [], 0, 'merge',
1824 '--depth=immediates', url_A_D, url_branch_D, A_D, '--accept=postpone')
1825 # New mergeinfo describing the merge.
1826 expected_status.tweak('A/D', 'A/D/G', status=' M')
1827 # Currently this fails because the local status is 'D'eleted rather than
1828 # 'R'eplaced with history:
1829 #
1830 # D C merge_tree_conflict_tests-23\A\D\H
1831 # > local delete, incoming replace upon merge
1832 expected_status.tweak('A/D/H', status='R ', wc_rev='-', copied='+',
1833 treeconflict='C')
1834
1835 ### A file-with-dir replacement onto a deleted file.
1836 # svn merge $URL/A/D/G $URL/branch/D/G A/D/G
1837 expected_stdout = expected_merge_output(None, [
1838 ' C ' + A_D_G_pi + '\n', # merge
1839 'A ' + A_D_G_pi + '\n', # merge
1840 " U " + A_D_G + "\n", # mergeinfo
1841 ], target=A_D_G, two_url=True, tree_conflicts=1)
1842
1843 actions.run_and_verify_svn2(expected_stdout, [], 0, 'merge',
1844 url_A_D_G, url_branch_D_G, A_D_G, '--accept=postpone')
1845 # New mergeinfo describing the merge.
1846 expected_status.tweak('A/D/G', status=' M')
1847 # Currently this fails because the local status shows a property mod (and
1848 # the TC type is listed as incoming delete, not incoming replace):
1849 #
1850 # RM + C merge_tree_conflict_tests-23\A\D\G\pi
1851 # > local delete, incoming delete upon merge
1852 expected_status.tweak('A/D/G/pi', status='R ', wc_rev='-', copied='+',
1853 treeconflict='C')
1854
1855 # Check the resulting status:
1856 actions.run_and_verify_status(wc_dir, expected_status)
1857
1858 # Check the tree conflict types:
1859 expected_stdout = r'(R.*)|(Summary of conflicts.*)|( Tree conflicts.*)' \
1860 r'|(.*local delete, incoming replace upon merge.*)' \
1861 r'|( \>.*)'
1862 tree_conflicted_path = [A_B_E, A_mu, A_D_G_pi, A_D_H]
1863 for path in tree_conflicted_path:
1864 actions.run_and_verify_svn2(expected_stdout, [], 0, 'st',
1865 '--depth=empty', path)
1866
1867 #----------------------------------------------------------------------
1868 # Test for issue #4011 'merge of replacement on local delete fails'
1869 @SkipUnless(server_has_mergeinfo)
1870 @Issue(4011)
1871 def merge_replace_on_del_fails(sbox):
1872 "merge replace on local delete fails"
1873
1874 sbox.build()
1875 wc_dir = sbox.wc_dir
1876
1877 C_path = os.path.join(wc_dir, 'A', 'C')
1878 branch_path = os.path.join(wc_dir, 'branch')
1879 C_branch_path = os.path.join(wc_dir, 'branch', 'C')
1880
1881 # r2 - Copy ^/A to ^/branch
1882 svntest.actions.run_and_verify_svn(None, [], 'copy',
1883 sbox.repo_url + '/A',
1884 sbox.repo_url + '/branch',
1885 '-m', 'Create a branch')
1886
1887 # r3 - Replace A/C
1888 svntest.actions.run_and_verify_svn(None, [], 'del', C_path)
1889 svntest.actions.run_and_verify_svn(None, [], 'mkdir', C_path)
1890 svntest.actions.run_and_verify_svn(None, [], 'ci',
1891 '-m', 'Replace A/C', wc_dir)
1892
1893 # r4 - Delete branch/C
1894 svntest.actions.run_and_verify_svn(None, [], 'up', wc_dir)
1895 svntest.actions.run_and_verify_svn(None, [], 'del', C_branch_path)
1896 svntest.actions.run_and_verify_svn(None, [], 'ci',
1897 '-m', 'Delete branch/C', wc_dir)
1898
1899 # Sync merge ^/A to branch
1900 svntest.actions.run_and_verify_svn(None, [], 'up', wc_dir)
1901 expected_stdout = expected_merge_output([[2,4]], [
1902 ' C ' + C_branch_path + '\n', # merge
1903 ' U ' + branch_path + '\n', # mergeinfo
1904 ], target=branch_path, tree_conflicts=1)
1905 # This currently fails with:
1906 #
1907 # >svn merge ^/A branch
1908 # ..\..\..\subversion\svn\util.c:913: (apr_err=155010)
1909 # ..\..\..\subversion\libsvn_client\merge.c:11349: (apr_err=155010)
1910 # ..\..\..\subversion\libsvn_client\merge.c:11303: (apr_err=155010)
1911 # ..\..\..\subversion\libsvn_client\merge.c:11303: (apr_err=155010)
1912 # ..\..\..\subversion\libsvn_client\merge.c:11273: (apr_err=155010)
1913 # ..\..\..\subversion\libsvn_client\merge.c:9287: (apr_err=155010)
1914 # ..\..\..\subversion\libsvn_client\merge.c:8870: (apr_err=155010)
1915 # ..\..\..\subversion\libsvn_client\merge.c:5349: (apr_err=155010)
1916 # ..\..\..\subversion\libsvn_repos\reporter.c:1430: (apr_err=155010)
1917 # ..\..\..\subversion\libsvn_client\ra.c:247: (apr_err=155010)
1918 # ..\..\..\subversion\libsvn_repos\reporter.c:1269: (apr_err=155010)
1919 # ..\..\..\subversion\libsvn_repos\reporter.c:1205: (apr_err=155010)
1920 # ..\..\..\subversion\libsvn_repos\reporter.c:920: (apr_err=155010)
1921 # ..\..\..\subversion\libsvn_delta\cancel.c:120: (apr_err=155010)
1922 # ..\..\..\subversion\libsvn_delta\cancel.c:120: (apr_err=155010)
1923 # ..\..\..\subversion\libsvn_client\repos_diff.c:710: (apr_err=155010)
1924 # ..\..\..\subversion\libsvn_client\merge.c:2234: (apr_err=155010)
1925 # ..\..\..\subversion\libsvn_wc\adm_ops.c:1069: (apr_err=155010)
1926 # ..\..\..\subversion\libsvn_wc\adm_ops.c:956: (apr_err=155010)
1927 # ..\..\..\subversion\libsvn_wc\update_editor.c:5036: (apr_err=155010)
1928 # ..\..\..\subversion\libsvn_wc\wc_db.c:6985: (apr_err=155010)
1929 # ..\..\..\subversion\libsvn_wc\wc_db.c:6929: (apr_err=155010)
1930 # ..\..\..\subversion\libsvn_wc\wc_db.c:6920: (apr_err=155010)
1931 # svn: E155010: The node 'C:\SVN\src-trunk\Debug\subversion\tests\
1932 # cmdline\svn-test-work\working_copies\merge_tree_conflict_tests-24\
1933 # branch\C' was not found.
1934 actions.run_and_verify_svn2(expected_stdout, [], 0, 'merge',
1935 sbox.repo_url + '/A', branch_path, '--accept=postpone')
1936
1937 def merge_conflict_details(sbox):
1938 "merge conflict details"
1939
1940 sbox.build()
1941 wc_dir = sbox.wc_dir
1942
1943 sbox.simple_append('A/B/E/new', 'new\n')
1944 sbox.simple_add('A/B/E/new')
1945 sbox.simple_append('A/B/E/alpha', '\nextra\nlines\n')
1946 sbox.simple_rm('A/B/E/beta', 'A/B/F')
1947 sbox.simple_propset('key', 'VAL', 'A/B/E', 'A/B')
1948 sbox.simple_mkdir('A/B/E/new-dir1')
1949 sbox.simple_mkdir('A/B/E/new-dir2')
1950 sbox.simple_mkdir('A/B/E/new-dir3')
1951 sbox.simple_rm('A/B/lambda')
1952 sbox.simple_mkdir('A/B/lambda')
1953 sbox.simple_commit()
1954
1955 sbox.simple_update('', 1)
1956
1957 sbox.simple_move('A/B', 'B')
1958
1959 sbox.simple_propset('key', 'vAl', 'B')
1960 sbox.simple_move('B/E/beta', 'beta')
1961 sbox.simple_propset('a', 'b', 'B/F', 'B/lambda')
1962 sbox.simple_append('B/E/alpha', 'other\nnew\nlines')
1963 sbox.simple_mkdir('B/E/new')
1964 sbox.simple_mkdir('B/E/new-dir1')
1965 sbox.simple_append('B/E/new-dir2', 'something')
1966 sbox.simple_append('B/E/new-dir3', 'something')
1967 sbox.simple_add('B/E/new-dir3')
1968
1969 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
1970 expected_status.add({
1971 'B' : Item(status=' C', copied='+', moved_from='A/B',
1972 wc_rev='-', entry_status='AC'),
1973 'B/E' : Item(status=' M', copied='+', wc_rev='-'),
1974 'B/E/new' : Item(status='A ', treeconflict='C', wc_rev='-'),
1975 'B/E/beta' : Item(status='D ', copied='+', treeconflict='C',
1976 wc_rev='-', moved_to='beta'),
1977 'B/E/alpha' : Item(status='C ', copied='+', wc_rev='-'),
1978 'B/E/new-dir3' : Item(status='A ', treeconflict='C', wc_rev='-'),
1979 'B/E/new-dir1' : Item(status='A ', treeconflict='C', wc_rev='-'),
1980 'B/F' : Item(status=' M', copied='+', treeconflict='C',
1981 wc_rev='-'),
1982 'B/lambda' : Item(status=' M', copied='+', treeconflict='C',
1983 wc_rev='-'),
1984 'beta' : Item(status='A ', copied='+',
1985 moved_from='B/E/beta', wc_rev='-')
1986 })
1987 expected_status.tweak('A/B', status='D ', wc_rev='1', moved_to='B')
1988 expected_status.tweak('A/B/lambda', 'A/B/E', 'A/B/E/beta', 'A/B/E/alpha',
1989 'A/B/F', status='D ')
1990
1991 expected_output = svntest.wc.State(wc_dir, {
1992 'B' : Item(status=' C'),
1993 'B/E' : Item(status=' U'),
1994 'B/E/new' : Item(status=' ', treeconflict='C'),
1995 'B/E/beta' : Item(status=' ', treeconflict='C'),
1996 'B/E/alpha' : Item(status='C '),
1997 'B/E/new-dir3' : Item(status=' ', treeconflict='C'),
1998 'B/E/new-dir1' : Item(status=' ', treeconflict='C'),
1999 'B/F' : Item(status=' ', treeconflict='C'),
2000 'B/lambda' : Item(status=' ', treeconflict='C'),
2001 })
2002 expected_skip = wc.State(wc_dir, {
2003 'B/E/new-dir2' : Item(verb='Skipped'),
2004 })
2005 svntest.actions.run_and_verify_merge(sbox.ospath('B'),
2006 1, 2, '^/A/B', '^/A/B',
2007 expected_output,
2008 None, None,
2009 None, None, expected_skip)
2010 svntest.actions.run_and_verify_status(wc_dir, expected_status)
2011
2012 expected_info = [
2013 {
2014 "Path" : re.escape(sbox.ospath('B')),
2015 "Conflicted Properties" : "key",
2016 "Conflict Details": re.escape(
2017 'incoming dir edit upon merge' +
2018 ' Source left: (dir) ^/A/B@1' +
2019 ' Source right: (dir) ^/A/B@2')
2020 },
2021 {
2022 "Path" : re.escape(sbox.ospath('B/E')),
2023 },
2024 {
2025 "Path" : re.escape(sbox.ospath('B/E/alpha')),
2026 "Conflict Previous Base File" : '.*alpha.*',
2027 "Conflict Previous Working File" : '.*alpha.*',
2028 "Conflict Current Base File": '.*alpha.*',
2029 "Conflict Details": re.escape(
2030 'incoming file edit upon merge' +
2031 ' Source left: (file) ^/A/B/E/alpha@1' +
2032 ' Source right: (file) ^/A/B/E/alpha@2')
2033 },
2034 {
2035 "Path" : re.escape(sbox.ospath('B/E/beta')),
2036 "Tree conflict": re.escape(
2037 'local file moved away, incoming file delete or move upon merge' +
2038 ' Source left: (file) ^/A/B/E/beta@1' +
2039 ' Source right: (none) ^/A/B/E/beta@2')
2040 },
2041 {
2042 "Path" : re.escape(sbox.ospath('B/E/new')),
2043 "Tree conflict": re.escape(
2044 'local dir add, incoming file add upon merge' +
2045 ' Source left: (none) ^/A/B/E/new@1' +
2046 ' Source right: (file) ^/A/B/E/new@2')
2047 },
2048 {
2049 "Path" : re.escape(sbox.ospath('B/E/new-dir1')),
2050 "Tree conflict": re.escape(
2051 'local dir add, incoming dir add upon merge' +
2052 ' Source left: (none) ^/A/B/E/new-dir1@1' +
2053 ' Source right: (dir) ^/A/B/E/new-dir1@2')
2054 },
2055 #{ ### Skipped
2056 # "Path" : re.escape(sbox.ospath('B/E/new-dir2')),
2057 # "Tree conflict": re.escape(
2058 # 'local file unversioned, incoming dir add upon merge' +
2059 # ' Source left: (none) ^/A/B/E/new-dir2@1' +
2060 # ' Source right: (dir) ^/A/B/E/new-dir2@2')
2061 #},
2062 {
2063 "Path" : re.escape(sbox.ospath('B/E/new-dir3')),
2064 "Tree conflict": re.escape(
2065 'local file add, incoming dir add upon merge' +
2066 ' Source left: (none) ^/A/B/E/new-dir3@1' +
2067 ' Source right: (dir) ^/A/B/E/new-dir3@2')
2068 },
2069 {
2070 "Path" : re.escape(sbox.ospath('B/F')),
2071 "Tree conflict": re.escape(
2072 'local dir edit, incoming dir delete or move upon merge' +
2073 ' Source left: (dir) ^/A/B/F@1' +
2074 ' Source right: (none) ^/A/B/F@2')
2075 },
2076 {
2077 "Path" : re.escape(sbox.ospath('B/lambda')),
2078 "Tree conflict": re.escape(
2079 'local file edit, incoming replace with dir upon merge' +
2080 ' Source left: (file) ^/A/B/lambda@1' +
2081 ' Source right: (dir) ^/A/B/lambda@2')
2082 },
2083 ]
2084
2085 svntest.actions.run_and_verify_info(expected_info, sbox.ospath('B'),
2086 '--depth', 'infinity')
2087
2088 def merge_obstruction_recording(sbox):
2089 "merge obstruction recording"
2090
2091 sbox.build(empty=True)
2092 wc_dir = sbox.wc_dir
2093
2094 sbox.simple_mkdir('trunk')
2095 sbox.simple_mkdir('branches')
2096 sbox.simple_commit() #r1
2097
2098 svntest.actions.run_and_verify_svn(None, [],
2099 'copy', sbox.repo_url + '/trunk',
2100 sbox.repo_url + '/branches/branch',
2101 '-mCopy') # r2
2102
2103 sbox.simple_mkdir('trunk/dir')
2104 sbox.simple_add_text('The file on trunk\n', 'trunk/dir/file.txt')
2105 sbox.simple_commit() #r3
2106
2107 sbox.simple_update()
2108
2109 sbox.simple_mkdir('branches/branch/dir')
2110 sbox.simple_add_text('The file on branch\n', 'branches/branch/dir/file.txt')
2111 sbox.simple_commit() #r4
2112
2113 sbox.simple_update()
2114
2115 svntest.actions.run_and_verify_svn(None, [],
2116 'switch', '^/branches/branch', wc_dir,
2117 '--ignore-ancestry')
2118
2119 expected_output = wc.State(wc_dir, {
2120 'dir' : Item(status=' ', treeconflict='C'),
2121 'dir/file.txt' : Item(status=' ', treeconflict='A'),
2122 })
2123 expected_mergeinfo_output = wc.State(wc_dir, {
2124 '' : Item(status=' U'),
2125 })
2126 expected_elision_output = wc.State(wc_dir, {
2127 })
2128 expected_disk = wc.State('', {
2129 'dir/file.txt' : Item(contents="The file on branch\n"),
2130 '.' : Item(props={'svn:mergeinfo':'/trunk:2-4'}),
2131 })
2132 expected_status = wc.State(wc_dir, {
2133 '' : Item(status=' M', wc_rev='4'),
2134 'dir' : Item(status=' ', treeconflict='C', wc_rev='4'),
2135 'dir/file.txt' : Item(status=' ', wc_rev='4'),
2136 })
2137 expected_skip = wc.State('', {
2138 })
2139 svntest.actions.run_and_verify_merge(wc_dir, '1', '4', sbox.repo_url + '/trunk',
2140 None,
2141 expected_output,
2142 expected_mergeinfo_output,
2143 expected_elision_output,
2144 expected_disk,
2145 expected_status,
2146 expected_skip,
2147 check_props=True)
2148 expected_info = [
2149 {
2150 "Path" : re.escape(sbox.ospath('dir')),
2151 "Tree conflict": re.escape(
2152 'local dir obstruction, incoming dir add upon merge' +
2153 ' Source left: (none) ^/trunk/dir@1' +
2154 ' Source right: (dir) ^/trunk/dir@4')
2155 },
2156 ]
2157
2158 svntest.actions.run_and_verify_info(expected_info, sbox.ospath('dir'))
2159
2160 # How should the user handle this conflict?
2161 # ### Would be nice if we could just accept mine (leave as is, fix mergeinfo)
2162 # ### or accept theirs (delete what is here and insert copy
2163 svntest.actions.run_and_verify_svn(None, [],
2164 'resolve', '--accept=working',
2165 sbox.ospath('dir'))
2166
2167 # Redo the skipped merge as record only merge
2168 expected_output = [
2169 '--- Recording mergeinfo for merge of r4 into \'%s\':\n' % \
2170 sbox.ospath('dir'),
2171 ' U %s\n' % sbox.ospath('dir'),
2172 ]
2173 # ### Why are r1-r3 not recorded?
2174 # ### Guess: Because dir's history only exists since r4.
2175 svntest.actions.run_and_verify_svn(expected_output, [],
2176 'merge', '--record-only',
2177 sbox.repo_url + '/trunk/dir',
2178 sbox.ospath('dir'),
2179 '-c', '1-4')
2180
2181 expected_disk = wc.State('', {
2182 'dir' : Item(props={'svn:mergeinfo':'/trunk/dir:4'}),
2183 'dir/file.txt' : Item(contents="The file on branch\n"),
2184 '.' : Item(props={'svn:mergeinfo':'/trunk:2-4'}),
2185 })
2186 svntest.actions.verify_disk(wc_dir, expected_disk, check_props=True)
2187
2188 # Because r1-r3 are not recorded, the mergeinfo is not elided :(
2189
2190 # Even something like a two url merge wouldn't work, because dir
2191 # didn't exist below trunk in r1 either.
2192
2193 # A resolver action could be smarter though...
2194
2195 def added_revision_recording_in_tree_conflict(sbox):
2196 "tree conflict stores added revision for victim"
2197
2198 sbox.build(empty=True)
2199 wc_dir = sbox.wc_dir
2200
2201 sbox.simple_mkdir('trunk')
2202 sbox.simple_commit() #r1
2203
2204 # Create a branch
2205 svntest.actions.run_and_verify_svn(None, [],
2206 'copy', sbox.repo_url + '/trunk',
2207 sbox.repo_url + '/branch',
2208 '-mcopy') # r2
2209
2210 sbox.simple_add_text('The file on trunk\n', 'trunk/foo')
2211 sbox.simple_commit() #r3
2212
2213 sbox.simple_update()
2214
2215 # Merge ^/trunk into ^/branch
2216 expected_output = svntest.wc.State(sbox.ospath('branch'), {
2217 'foo' : Item(status='A '),
2218 })
2219 expected_mergeinfo_output = wc.State(sbox.ospath('branch'), {
2220 '' : Item(status=' U')
2221 })
2222 expected_elision_output = wc.State(wc_dir, {
2223 })
2224 expected_disk = wc.State('', {
2225 'foo' : Item(contents="The file on trunk\n"),
2226 '.' : Item(props={u'svn:mergeinfo': u'/trunk:2-3'}),
2227 })
2228 expected_status = wc.State(sbox.ospath('branch'), {
2229 '' : Item(status=' M', wc_rev='3'),
2230 'foo' : Item(status='A ', copied='+', wc_rev='-'),
2231 })
2232 expected_skip = wc.State('', {
2233 })
2234 svntest.actions.run_and_verify_merge(sbox.ospath('branch'), None, None,
2235 sbox.repo_url + '/trunk',
2236 None,
2237 expected_output,
2238 expected_mergeinfo_output,
2239 expected_elision_output,
2240 expected_disk,
2241 expected_status,
2242 expected_skip,
2243 check_props=True)
2244
2245 sbox.simple_commit() #r4
2246
2247 # Edit the file on the branch
2248 sbox.simple_append('branch/foo', 'The file on the branch\n')
2249 sbox.simple_commit() #r5
2250
2251 # Replace file with a directory on trunk
2252 sbox.simple_rm('trunk/foo')
2253 sbox.simple_mkdir('trunk/foo')
2254 sbox.simple_commit() #r6
2255
2256 sbox.simple_update()
2257
2258 # Merge ^/trunk into ^/branch
2259 expected_output = svntest.wc.State(sbox.ospath('branch'), {
2260 'foo' : Item(status=' ', treeconflict='C')
2261 })
2262 expected_mergeinfo_output = wc.State(sbox.ospath('branch'), {
2263 '' : Item(status=' U'),
2264 })
2265 expected_elision_output = wc.State(wc_dir, {
2266 })
2267 expected_disk = wc.State('', {
2268 'foo' : Item(contents="The file on trunk\nThe file on the branch\n"),
2269 '.' : Item(props={u'svn:mergeinfo': u'/trunk:2-6'}),
2270 })
2271 expected_status = wc.State(sbox.ospath('branch'), {
2272 '' : Item(status=' M', wc_rev='6'),
2273 'foo' : Item(status=' ', treeconflict='C', wc_rev='6'),
2274 })
2275 expected_skip = wc.State('', {
2276 })
2277 svntest.actions.run_and_verify_merge(sbox.ospath('branch'), None, None,
2278 sbox.repo_url + '/trunk',
2279 None,
2280 expected_output,
2281 expected_mergeinfo_output,
2282 expected_elision_output,
2283 expected_disk,
2284 expected_status,
2285 expected_skip,
2286 check_props=True)
2287
2288 # Ensure that revisions in tree conflict info match what we expect.
2289 # We used to record source left as ^/trunk/foo@1 instead of ^/trunk/foo@3.
2290 # Note that foo was first added in r3.
2291 expected_info = [
2292 {
2293 "Path" : re.escape(sbox.ospath('branch/foo')),
2294 "Tree conflict": re.escape(
2295 'local file edit, incoming replace with dir upon merge' +
2296 ' Source left: (file) ^/trunk/foo@3' +
2297 ' Source right: (dir) ^/trunk/foo@6'),
2298 },
2299 ]
2300 svntest.actions.run_and_verify_info(expected_info, sbox.ospath('branch/foo'))
2301
2302 def spurios_tree_conflict_with_added_file(sbox):
2303 "spurious tree conflict with unmodified added file"
2304
2305 sbox.build()
2306 wc_dir = sbox.wc_dir
2307
2308 # Create a branch of A, A_copy
2309 sbox.simple_copy('A', 'A_branch')
2310 sbox.simple_commit()
2311
2312 # Create a new file on the trunk
2313 sbox.simple_append('A/new', 'new\n')
2314 sbox.simple_add('A/new')
2315 sbox.simple_commit()
2316
2317 # Sync the branch with the trunk
2318 sbox.simple_update()
2319 expected_output = wc.State(wc_dir, {
2320 "A_branch/new" : Item(status="A "),
2321 })
2322 expected_skip = wc.State('', { })
2323 svntest.actions.run_and_verify_merge(sbox.ospath('A_branch'),
2324 None, None, '^/A', None,
2325 expected_output,
2326 None, None,
2327 None, None, expected_skip)
2328 sbox.simple_commit()
2329
2330 # Reintegrate the branch (a no-op change, but users are free to do this)
2331 sbox.simple_update()
2332 expected_output = wc.State(wc_dir, { })
2333 svntest.actions.run_and_verify_merge(sbox.ospath('A'),
2334 None, None, '^/A_branch', None,
2335 expected_output,
2336 None, None,
2337 None, None, expected_skip,
2338 [], False, True, '--reintegrate',
2339 sbox.ospath('A'))
2340
2341 # Delete the new file on the branch
2342 sbox.simple_rm('A_branch/new')
2343 sbox.simple_commit()
2344
2345 # Make an unrelated change on the trunk
2346 sbox.simple_append('A/mu', 'more text\n')
2347 sbox.simple_commit()
2348
2349 # Merge the trunk to the branch. Forcing a reintegrate merge here since
2350 # this is what the automatic merge does, as of the time this test was written.
2351 # This merge would raise an 'local missing vs incoming edit' tree conflict
2352 # on the new file, which is bogus since there are no incoming edits.
2353 expected_output = wc.State(wc_dir, {
2354 'A_branch/mu' : Item(status='U '),
2355 })
2356 expected_mergeinfo_output = wc.State(wc_dir, {
2357 'A_branch' : Item(status=' U'),
2358 })
2359 svntest.actions.run_and_verify_merge(sbox.ospath('A_branch'),
2360 None, None, '^/A', None,
2361 expected_output,
2362 expected_mergeinfo_output, None,
2363 None, None, expected_skip,
2364 [], False, True, '--reintegrate',
2365 sbox.ospath('A_branch'))
2366
2367 def merge_local_missing_node_kind_none(sbox):
2368 "crash in resolver triggered by none-type node"
2369
2370 sbox.build()
2371 wc_dir = sbox.wc_dir
2372
2373 sbox.simple_mkdir('branches')
2374 sbox.simple_commit() # r2
2375 sbox.simple_update()
2376
2377 # Create a feature branch of A
2378 sbox.simple_copy('A', 'branches/feature1')
2379 sbox.simple_commit() #r3
2380 sbox.simple_update()
2381
2382 # On the branch, move file alpha to another directory
2383 sbox.simple_move('branches/feature1/B/E/alpha',
2384 'branches/feature1/D/H/alpha-from-B-E')
2385 sbox.simple_commit() # r4
2386 sbox.simple_update()
2387
2388 # Cherry-pick the delete-half of the above move into A (the trunk)
2389 expected_output = svntest.wc.State(sbox.ospath('A/B/E'), {
2390 'alpha' : Item(status='D '),
2391 })
2392 expected_mergeinfo_output = wc.State(sbox.ospath('A/B/E'), {
2393 '' : Item(status=' U')
2394 })
2395 expected_elision_output = wc.State(wc_dir, {
2396 })
2397 expected_disk = wc.State('', {
2398 'beta' : Item(contents="This is the file 'beta'.\n"),
2399 '.' : Item(props={u'svn:mergeinfo':
2400 u'/branches/feature1/B/E:4'}),
2401 })
2402 expected_status = wc.State(sbox.ospath('A/B/E'), {
2403 '' : Item(status=' M', wc_rev='4'),
2404 'alpha' : Item(status='D ', wc_rev='4'),
2405 'beta' : Item(status=' ', wc_rev='4'),
2406 })
2407 expected_skip = wc.State('', {
2408 })
2409 svntest.actions.run_and_verify_merge(sbox.ospath('A/B/E'), 3, 4,
2410 sbox.repo_url + '/branches/feature1/B/E',
2411 None,
2412 expected_output,
2413 expected_mergeinfo_output,
2414 expected_elision_output,
2415 expected_disk,
2416 expected_status,
2417 expected_skip,
2418 check_props=True)
2419 sbox.simple_commit() # r5
2420 sbox.simple_update()
2421
2422 # Create a new file on the feature branch
2423 sbox.simple_add_text("This is the file 'pi'\n", 'branches/feature1/B/E/pi')
2424 sbox.simple_commit() #r6
2425 sbox.simple_update()
2426
2427 # Create a second branch based on the feature branch.
2428 sbox.simple_copy('branches/feature1', 'branches/feature2')
2429 sbox.simple_commit() #r7
2430 sbox.simple_update()
2431
2432 # Create a new file kappa on this second branch
2433 sbox.simple_add_text("This is the file 'kappa'\n",
2434 'branches/feature2/B/E/kappa')
2435 sbox.simple_commit() #r8
2436 sbox.simple_update()
2437
2438 # An unrelated additional change on the second branch.
2439 sbox.simple_append('branches/feature2/B/E/beta',
2440 "This is a change to file 'beta'.\n")
2441 sbox.simple_commit() #r9
2442 sbox.simple_update()
2443
2444 # Merge the second branch back into the feature branch
2445 expected_output = svntest.wc.State(sbox.ospath('branches/feature1'), {
2446 'B/E/kappa' : Item(status='A '),
2447 'B/E/beta' : Item(status='U '),
2448 })
2449 expected_mergeinfo_output = wc.State(sbox.ospath('branches/feature1'), {
2450 '.' : Item(status=' U'),
2451 })
2452 expected_elision_output = wc.State(wc_dir, {
2453 })
2454 expected_disk = wc.State('', {
2455 'C' : Item(),
2456 'B/E/kappa' : Item(contents="This is the file 'kappa'\n"),
2457 'B/E/pi' : Item(contents="This is the file 'pi'\n"),
2458 'B/E/beta' : Item(contents="This is the file 'beta'.\n" +
2459 "This is a change to file 'beta'.\n"),
2460 'B/lambda' : Item(contents="This is the file 'lambda'.\n"),
2461 'B/F' : Item(),
2462 'D/H/omega' : Item(contents="This is the file 'omega'.\n"),
2463 'D/H/alpha-from-B-E': Item(contents="This is the file 'alpha'.\n"),
2464 'D/H/psi' : Item(contents="This is the file 'psi'.\n"),
2465 'D/H/chi' : Item(contents="This is the file 'chi'.\n"),
2466 'D/G/pi' : Item(contents="This is the file 'pi'.\n"),
2467 'D/G/rho' : Item(contents="This is the file 'rho'.\n"),
2468 'D/G/tau' : Item(contents="This is the file 'tau'.\n"),
2469 'D/gamma' : Item(contents="This is the file 'gamma'.\n"),
2470 'mu' : Item(contents="This is the file 'mu'.\n"),
2471 '.' : Item(props={u'svn:mergeinfo':
2472 u'/branches/feature2:7-9'}),
2473 })
2474 expected_status = wc.State(sbox.ospath('branches/feature1'), {
2475 '' : Item(status=' M', wc_rev='9'),
2476 'mu' : Item(status=' ', wc_rev='9'),
2477 'D' : Item(status=' ', wc_rev='9'),
2478 'D/H' : Item(status=' ', wc_rev='9'),
2479 'D/H/alpha-from-B-E': Item(status=' ', wc_rev='9'),
2480 'D/H/psi' : Item(status=' ', wc_rev='9'),
2481 'D/H/chi' : Item(status=' ', wc_rev='9'),
2482 'D/H/omega' : Item(status=' ', wc_rev='9'),
2483 'D/G' : Item(status=' ', wc_rev='9'),
2484 'D/G/pi' : Item(status=' ', wc_rev='9'),
2485 'D/G/tau' : Item(status=' ', wc_rev='9'),
2486 'D/G/rho' : Item(status=' ', wc_rev='9'),
2487 'D/gamma' : Item(status=' ', wc_rev='9'),
2488 'B' : Item(status=' ', wc_rev='9'),
2489 'B/E' : Item(status=' ', wc_rev='9'),
2490 'B/E/beta' : Item(status='M ', wc_rev='9'),
2491 'B/E/kappa' : Item(status='A ', copied='+', wc_rev='-'),
2492 'B/E/pi' : Item(status=' ', wc_rev='9'),
2493 'B/lambda' : Item(status=' ', wc_rev='9'),
2494 'B/F' : Item(status=' ', wc_rev='9'),
2495 'C' : Item(status=' ', wc_rev='9'),
2496 })
2497 expected_skip = wc.State('', {
2498 })
2499 svntest.actions.run_and_verify_merge(sbox.ospath('branches/feature1'),
2500 None, None,
2501 sbox.repo_url + '/branches/feature2',
2502 None,
2503 expected_output,
2504 expected_mergeinfo_output,
2505 expected_elision_output,
2506 expected_disk,
2507 expected_status,
2508 expected_skip,
2509 check_props=True)
2510 sbox.simple_commit() # r10
2511 sbox.simple_update()
2512
2513 # On the feature branch, rename the file kappa
2514 sbox.simple_move('branches/feature1/B/E/kappa',
2515 'branches/feature1/B/E/kappanew')
2516 sbox.simple_commit() # r11
2517 sbox.simple_update()
2518
2519 # On the feature branch, move file kappanew to another directory
2520 sbox.simple_move('branches/feature1/B/E/kappanew',
2521 'branches/feature1/D/H/kappanew')
2522 sbox.simple_commit() # r12
2523 sbox.simple_update()
2524
2525 # Cherry-pick r12 into A (the trunk)
2526 # This triggers an assertion failure in Subversion 1.14.1 because of
2527 # a node type lookup which uses the wrong token map:
2528 # W: subversion/libsvn_subr/token.c:40: (apr_err=SVN_ERR_ASSERTION_FAIL)
2529 # svn: E235000: In file 'subversion/libsvn_subr/token.c' line 40: internal malfunction
2530 expected_output = svntest.wc.State(sbox.ospath('A'), {
2531 'B/E/kappanew' : Item(status=' ', treeconflict='C'),
2532 'D/H/kappanew' : Item(status='A '),
2533 })
2534 expected_mergeinfo_output = wc.State(sbox.ospath('A'), {
2535 '' : Item(status=' U'),
2536 'B/E' : Item(status=' U'),
2537 })
2538 expected_elision_output = wc.State(wc_dir, {
2539 })
2540 expected_disk = wc.State('', {
2541 'C' : Item(),
2542 'B/E' : Item(props={u'svn:mergeinfo':
2543 u'/branches/feature1/B/E:4,12'}),
2544 'B/E/beta' : Item(contents="This is the file 'beta'.\n"),
2545 'B/lambda' : Item(contents="This is the file 'lambda'.\n"),
2546 'B/F' : Item(),
2547 'D/H/omega' : Item(contents="This is the file 'omega'.\n"),
2548 'D/H/kappanew' : Item(contents="This is the file 'kappa'\n"),
2549 'D/H/psi' : Item(contents="This is the file 'psi'.\n"),
2550 'D/H/chi' : Item(contents="This is the file 'chi'.\n"),
2551 'D/G/pi' : Item(contents="This is the file 'pi'.\n"),
2552 'D/G/rho' : Item(contents="This is the file 'rho'.\n"),
2553 'D/G/tau' : Item(contents="This is the file 'tau'.\n"),
2554 'D/gamma' : Item(contents="This is the file 'gamma'.\n"),
2555 'mu' : Item(contents="This is the file 'mu'.\n"),
2556 '.' : Item(props={u'svn:mergeinfo':
2557 u'/branches/feature1:12'}),
2558 })
2559 expected_status = wc.State(sbox.ospath('A'), {
2560 '' : Item(status=' M', wc_rev='12'),
2561 'D' : Item(status=' ', wc_rev='12'),
2562 'D/H' : Item(status=' ', wc_rev='12'),
2563 'D/H/chi' : Item(status=' ', wc_rev='12'),
2564 'D/H/psi' : Item(status=' ', wc_rev='12'),
2565 'D/H/kappanew' : Item(status='A ', copied='+', wc_rev='-'),
2566 'D/H/omega' : Item(status=' ', wc_rev='12'),
2567 'D/G' : Item(status=' ', wc_rev='12'),
2568 'D/G/pi' : Item(status=' ', wc_rev='12'),
2569 'D/G/tau' : Item(status=' ', wc_rev='12'),
2570 'D/G/rho' : Item(status=' ', wc_rev='12'),
2571 'D/gamma' : Item(status=' ', wc_rev='12'),
2572 'B' : Item(status=' ', wc_rev='12'),
2573 'B/E' : Item(status=' M', wc_rev='12'),
2574 'B/E/beta' : Item(status=' ', wc_rev='12'),
2575 'B/E/kappanew' : Item(status='! ', treeconflict='C'),
2576 'B/F' : Item(status=' ', wc_rev='12'),
2577 'B/lambda' : Item(status=' ', wc_rev='12'),
2578 'mu' : Item(status=' ', wc_rev='12'),
2579 'C' : Item(status=' ', wc_rev='12'),
2580 })
2581 expected_skip = wc.State('', {
2582 })
2583 svntest.actions.run_and_verify_merge(sbox.ospath('A'), 11, 12,
2584 sbox.repo_url + '/branches/feature1',
2585 None,
2586 expected_output,
2587 expected_mergeinfo_output,
2588 expected_elision_output,
2589 expected_disk,
2590 expected_status,
2591 expected_skip,
2592 check_props=True)
2593
2594
2595 ########################################################################
2596 # Run the tests
2597
2598
2599 # list all tests here, starting with None:
2600 test_list = [ None,
2601 delete_file_and_dir,
2602 merge_catches_nonexistent_target,
2603 merge_tree_deleted_in_target,
2604 three_way_merge_add_of_existing_binary_file,
2605 merge_added_dir_to_deleted_in_target,
2606 merge_add_over_versioned_file_conflicts,
2607 mergeinfo_recording_in_skipped_merge,
2608 del_differing_file,
2609 tree_conflicts_and_obstructions,
2610 tree_conflicts_on_merge_local_ci_4_1,
2611 tree_conflicts_on_merge_local_ci_4_2,
2612 tree_conflicts_on_merge_local_ci_5_1,
2613 tree_conflicts_on_merge_local_ci_5_2,
2614 tree_conflicts_on_merge_local_ci_6,
2615 tree_conflicts_on_merge_no_local_ci_4_1,
2616 tree_conflicts_on_merge_no_local_ci_4_2,
2617 tree_conflicts_on_merge_no_local_ci_5_1,
2618 tree_conflicts_on_merge_no_local_ci_5_2,
2619 tree_conflicts_on_merge_no_local_ci_6,
2620 tree_conflicts_merge_edit_onto_missing,
2621 tree_conflicts_merge_del_onto_missing,
2622 merge_replace_causes_tree_conflict,
2623 merge_replace_causes_tree_conflict2,
2624 merge_replace_on_del_fails,
2625 merge_conflict_details,
2626 merge_obstruction_recording,
2627 added_revision_recording_in_tree_conflict,
2628 spurios_tree_conflict_with_added_file,
2629 merge_local_missing_node_kind_none,
2630 ]
2631
2632 if __name__ == '__main__':
2633 svntest.main.run_tests(test_list)
2634 # NOTREACHED
2635
2636
2637 ### End of file.