3
# resolved_tests.py: testing "resolved" cases.
5
# Subversion is a tool for revision control.
6
# See http://subversion.apache.org for more information.
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
17
# http://www.apache.org/licenses/LICENSE-2.0
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
25
######################################################################
32
from svntest import wc
35
Skip = svntest.testcase.Skip_deco
36
SkipUnless = svntest.testcase.SkipUnless_deco
37
XFail = svntest.testcase.XFail_deco
38
Issues = svntest.testcase.Issues_deco
39
Issue = svntest.testcase.Issue_deco
40
Wimp = svntest.testcase.Wimp_deco
41
Item = svntest.wc.StateItem
43
from svntest.main import SVN_PROP_MERGEINFO, server_has_mergeinfo
45
######################################################################
48
# Each test must return on success or raise on failure.
51
#----------------------------------------------------------------------
53
def resolved_on_wc_root(sbox):
54
"resolved on working copy root"
59
i = os.path.join(wc, 'iota')
60
B = os.path.join(wc, 'A', 'B')
61
g = os.path.join(wc, 'A', 'D', 'gamma')
63
# Create some conflicts...
65
svntest.main.file_append(i, "changed iota.\n")
66
svntest.main.file_append(g, "changed gamma.\n")
67
svntest.actions.run_and_verify_svn(None, None, [],
68
'propset', 'foo', 'foo-val', B)
70
expected_output = svntest.wc.State(wc, {
71
'iota' : Item(verb='Sending'),
72
'A/B' : Item(verb='Sending'),
73
'A/D/gamma' : Item(verb='Sending'),
76
expected_status = svntest.actions.get_virginal_state(wc, 1)
77
expected_status.tweak('iota', 'A/B', 'A/D/gamma', wc_rev = 2)
79
svntest.actions.run_and_verify_commit(wc,
86
expected_output = svntest.wc.State(wc, {
87
'iota' : Item(status='U '),
88
'A/B' : Item(status=' U'),
89
'A/D/gamma' : Item(status='U '),
91
expected_status = svntest.actions.get_virginal_state(wc, 1)
92
expected_disk = svntest.main.greek_state.copy()
93
svntest.actions.run_and_verify_update(wc,
97
None, None, None, None, None, False,
100
# Deletions so that the item becomes unversioned and
101
# will have a tree-conflict upon update.
102
svntest.actions.run_and_verify_svn(None, None, [],
105
# Update so that conflicts appear
106
expected_output = svntest.wc.State(wc, {
107
'iota' : Item(status=' ', treeconflict='C'),
108
'A/B' : Item(status=' ', treeconflict='C'),
109
'A/D/gamma' : Item(status=' ', treeconflict='C'),
112
expected_disk = svntest.main.greek_state.copy()
113
expected_disk.remove('iota',
115
'A/B/E/alpha', 'A/B/E/beta',
117
if svntest.main.wc_is_singledb(sbox.wc_dir):
118
expected_disk.remove('A/B/E', 'A/B/F', 'A/B')
120
expected_status = svntest.actions.get_virginal_state(wc, 2)
121
expected_status.tweak('iota', 'A/B', 'A/D/gamma',
122
status='D ', treeconflict='C')
123
expected_status.tweak('A/B/lambda', 'A/B/E', 'A/B/E/alpha', 'A/B/E/beta',
124
'A/B/F', status='D ')
125
svntest.actions.run_and_verify_update(wc,
129
None, None, None, None, None, False,
131
svntest.actions.run_and_verify_unquiet_status(wc, expected_status)
133
# Resolve recursively
134
svntest.actions.run_and_verify_resolved([i, B, g], '--depth=infinity', wc)
136
expected_status.tweak('iota', 'A/B', 'A/D/gamma', treeconflict=None)
137
svntest.actions.run_and_verify_unquiet_status(wc, expected_status)
143
def resolved_on_deleted_item(sbox):
144
"resolved on deleted item"
149
A = os.path.join(wc, 'A',)
150
B = os.path.join(wc, 'A', 'B')
151
g = os.path.join(wc, 'A', 'D', 'gamma')
152
A2 = os.path.join(wc, 'A2')
153
B2 = os.path.join(A2, 'B')
154
g2 = os.path.join(A2, 'D', 'gamma')
156
A_url = sbox.repo_url + '/A'
157
A2_url = sbox.repo_url + '/A2'
160
svntest.actions.run_and_verify_svn(None, None, [],
161
'cp', A_url, A2_url, '-m', 'm')
163
expected_output = svntest.wc.State(wc, {
164
'A2' : Item(status='A '),
165
'A2/B' : Item(status='A '),
166
'A2/B/lambda' : Item(status='A '),
167
'A2/B/E' : Item(status='A '),
168
'A2/B/E/alpha' : Item(status='A '),
169
'A2/B/E/beta' : Item(status='A '),
170
'A2/B/F' : Item(status='A '),
171
'A2/mu' : Item(status='A '),
172
'A2/C' : Item(status='A '),
173
'A2/D' : Item(status='A '),
174
'A2/D/gamma' : Item(status='A '),
175
'A2/D/G' : Item(status='A '),
176
'A2/D/G/pi' : Item(status='A '),
177
'A2/D/G/rho' : Item(status='A '),
178
'A2/D/G/tau' : Item(status='A '),
179
'A2/D/H' : Item(status='A '),
180
'A2/D/H/chi' : Item(status='A '),
181
'A2/D/H/omega' : Item(status='A '),
182
'A2/D/H/psi' : Item(status='A '),
186
expected_disk = svntest.main.greek_state.copy()
188
'A2/mu' : Item(contents="This is the file 'mu'.\n"),
189
'A2/D/gamma' : Item(contents="This is the file 'gamma'.\n"),
190
'A2/D/H/psi' : Item(contents="This is the file 'psi'.\n"),
191
'A2/D/H/omega' : Item(contents="This is the file 'omega'.\n"),
192
'A2/D/H/chi' : Item(contents="This is the file 'chi'.\n"),
193
'A2/D/G/rho' : Item(contents="This is the file 'rho'.\n"),
194
'A2/D/G/pi' : Item(contents="This is the file 'pi'.\n"),
195
'A2/D/G/tau' : Item(contents="This is the file 'tau'.\n"),
196
'A2/B/lambda' : Item(contents="This is the file 'lambda'.\n"),
198
'A2/B/E/beta' : Item(contents="This is the file 'beta'.\n"),
199
'A2/B/E/alpha' : Item(contents="This is the file 'alpha'.\n"),
204
expected_status = svntest.actions.get_virginal_state(wc, 2)
205
expected_status.add({
208
'A2/B/lambda' : Item(),
210
'A2/B/E/alpha' : Item(),
211
'A2/B/E/beta' : Item(),
216
'A2/D/gamma' : Item(),
218
'A2/D/G/pi' : Item(),
219
'A2/D/G/rho' : Item(),
220
'A2/D/G/tau' : Item(),
222
'A2/D/H/chi' : Item(),
223
'A2/D/H/omega' : Item(),
224
'A2/D/H/psi' : Item(),
226
expected_status.tweak(status=' ', wc_rev='2')
228
svntest.actions.run_and_verify_update(wc,
232
None, None, None, None, None, False,
235
# Create some conflicts...
237
# Modify the paths in the one directory.
238
svntest.actions.run_and_verify_svn(None, None, [],
239
'propset', 'foo', 'foo-val', B)
240
svntest.main.file_append(g, "Modified gamma.\n")
242
expected_output = svntest.wc.State(wc, {
243
'A/B' : Item(verb='Sending'),
244
'A/D/gamma' : Item(verb='Sending'),
247
expected_status.tweak('A/B', 'A/D/gamma', wc_rev='3')
249
svntest.actions.run_and_verify_commit(wc,
255
# Delete the paths in the second directory.
256
svntest.actions.run_and_verify_svn(None, None, [],
259
expected_output = svntest.wc.State(wc, {
260
'A2/B' : Item(verb='Deleting'),
261
'A2/D/gamma' : Item(verb='Deleting'),
264
expected_status.remove('A2/B', 'A2/B/lambda',
265
'A2/B/E', 'A2/B/E/alpha', 'A2/B/E/beta',
269
svntest.actions.run_and_verify_commit(wc,
275
# Now merge A to A2, creating conflicts...
277
expected_output = svntest.wc.State(A2, {
278
'B' : Item(status=' ', treeconflict='C'),
279
'D/gamma' : Item(status=' ', treeconflict='C'),
281
expected_mergeinfo_output = svntest.wc.State(A2, {
282
'' : Item(status=' U')
284
expected_elision_output = svntest.wc.State(A2, {
286
expected_disk = svntest.wc.State('', {
287
'mu' : Item(contents="This is the file 'mu'.\n"),
290
'D/H/psi' : Item(contents="This is the file 'psi'.\n"),
291
'D/H/omega' : Item(contents="This is the file 'omega'.\n"),
292
'D/H/chi' : Item(contents="This is the file 'chi'.\n"),
294
'D/G/rho' : Item(contents="This is the file 'rho'.\n"),
295
'D/G/pi' : Item(contents="This is the file 'pi'.\n"),
296
'D/G/tau' : Item(contents="This is the file 'tau'.\n"),
301
expected_skip = svntest.wc.State(wc, {
304
expected_status = svntest.wc.State(A2, {
305
'' : Item(status=' M', wc_rev='2'),
306
'D' : Item(status=' ', wc_rev='2'),
307
'D/gamma' : Item(status='! ', treeconflict='C'),
308
'D/G' : Item(status=' ', wc_rev='2'),
309
'D/G/pi' : Item(status=' ', wc_rev='2'),
310
'D/G/rho' : Item(status=' ', wc_rev='2'),
311
'D/G/tau' : Item(status=' ', wc_rev='2'),
312
'D/H' : Item(status=' ', wc_rev='2'),
313
'D/H/chi' : Item(status=' ', wc_rev='2'),
314
'D/H/omega' : Item(status=' ', wc_rev='2'),
315
'D/H/psi' : Item(status=' ', wc_rev='2'),
316
'B' : Item(status='! ', treeconflict='C'),
317
'mu' : Item(status=' ', wc_rev='2'),
318
'C' : Item(status=' ', wc_rev='2'),
321
svntest.actions.run_and_verify_merge(A2, None, None, A_url, None,
323
expected_mergeinfo_output,
324
expected_elision_output,
325
expected_disk, None, expected_skip,
326
None, dry_run = False)
327
svntest.actions.run_and_verify_unquiet_status(A2, expected_status)
330
# Now resolve by recursing on the working copy root.
331
svntest.actions.run_and_verify_resolved([B2, g2], '--depth=infinity', wc)
333
expected_status.remove('B', 'D/gamma')
334
svntest.actions.run_and_verify_unquiet_status(A2, expected_status)
338
def theirs_conflict_in_subdir(sbox):
339
"resolve to 'theirs-conflict' in sub-directory"
343
wc2 = sbox.add_wc_path('wc2')
344
svntest.actions.duplicate_dir(sbox.wc_dir, wc2)
346
alpha_path = os.path.join(wc, 'A', 'B', 'E', 'alpha')
347
alpha_path2 = os.path.join(wc2, 'A', 'B', 'E', 'alpha')
349
svntest.main.file_append(alpha_path, "Modified alpha.\n")
350
svntest.main.run_svn(None, 'ci', '-m', 'logmsg', wc)
352
svntest.main.file_append(alpha_path2, "Modified alpha, too.\n")
353
svntest.main.run_svn(None, 'up', wc2)
355
svntest.actions.run_and_verify_resolve([alpha_path2],
356
'--accept=theirs-conflict',
359
#######################################################################
363
# list all tests here, starting with None:
366
resolved_on_deleted_item,
367
theirs_conflict_in_subdir,
370
if __name__ == '__main__':
371
svntest.main.run_tests(test_list)