3
# export_tests.py: testing export cases.
5
# Subversion is a tool for revision control.
6
# See http://subversion.tigris.org for more information.
8
# ====================================================================
9
# Copyright (c) 2000-2004 CollabNet. All rights reserved.
11
# This software is licensed as described in the file COPYING, which
12
# you should have received as part of this distribution. The terms
13
# are also available at http://subversion.tigris.org/license-1.html.
14
# If newer versions of this license are posted there, you may use a
15
# newer version instead, at your option.
17
######################################################################
20
import shutil, string, sys, re, os
27
Skip = svntest.testcase.Skip
28
XFail = svntest.testcase.XFail
29
Item = svntest.wc.StateItem
32
######################################################################
35
# Each test must return on success or raise on failure.
38
#----------------------------------------------------------------------
40
def export_empty_directory(sbox):
41
"export an empty directory"
44
svntest.main.safe_rmtree(sbox.wc_dir)
45
export_target = sbox.wc_dir
46
empty_dir_url = svntest.main.current_repo_url + '/A/C'
47
svntest.main.run_svn(None, 'export', empty_dir_url, export_target)
48
if not os.path.exists(export_target):
51
def export_greek_tree(sbox):
52
"export the greek tree"
55
svntest.main.safe_rmtree(sbox.wc_dir)
56
export_target = sbox.wc_dir
57
expected_output = svntest.main.greek_state.copy()
58
expected_output.wc_dir = sbox.wc_dir
59
expected_output.desc[''] = Item()
60
expected_output.tweak(contents=None, status='A ')
62
svntest.actions.run_and_verify_export(svntest.main.current_repo_url,
65
svntest.main.greek_state.copy())
67
def export_working_copy(sbox):
71
export_target = sbox.add_wc_path('export')
73
svntest.actions.run_and_verify_export(sbox.wc_dir,
75
svntest.wc.State(sbox.wc_dir, {}),
76
svntest.main.greek_state.copy())
78
def export_working_copy_with_mods(sbox):
79
"export working copy with mods"
84
# Make a couple of local mods to files
85
mu_path = os.path.join(wc_dir, 'A', 'mu')
86
rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
87
kappa_path = os.path.join(wc_dir, 'kappa')
88
gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
89
E_path = os.path.join(wc_dir, 'A', 'B', 'E')
91
svntest.main.file_append(mu_path, 'appended mu text')
92
svntest.main.file_append(rho_path, 'new appended text for rho')
94
svntest.main.file_append(kappa_path, "This is the file 'kappa'.")
95
svntest.main.run_svn(None, 'add', kappa_path)
96
svntest.main.run_svn(None, 'rm', E_path, gamma_path)
98
expected_disk = svntest.main.greek_state.copy()
99
expected_disk.tweak('A/mu',
100
contents=expected_disk.desc['A/mu'].contents
101
+ 'appended mu text')
102
expected_disk.tweak('A/D/G/rho',
103
contents=expected_disk.desc['A/D/G/rho'].contents
104
+ 'new appended text for rho')
105
expected_disk.add({'kappa' : Item("This is the file 'kappa'.")})
106
expected_disk.remove('A/B/E/alpha', 'A/B/E/beta', 'A/B/E', 'A/D/gamma')
108
export_target = sbox.add_wc_path('export')
110
svntest.actions.run_and_verify_export(sbox.wc_dir,
112
svntest.wc.State(sbox.wc_dir, {}),
115
def export_over_existing_dir(sbox):
116
"export over existing dir"
119
export_target = sbox.add_wc_path('export')
121
# Create the target directory which should cause
122
# the export operation to fail.
123
os.mkdir(export_target)
125
svntest.actions.run_and_verify_svn("No error where one is expected",
126
None, svntest.SVNAnyOutput,
127
'export', sbox.wc_dir, export_target)
129
# As an extra precaution, make sure export_target doesn't have
131
if len(os.listdir(export_target)):
132
raise svntest.Failure("Unexpected files/directories in " + export_target)
134
def export_keyword_translation(sbox):
135
"export with keyword translation"
140
# Add a keyword to A/mu and set the svn:keywords property
141
# appropriately to make sure it's translated during
142
# the export operation
143
mu_path = os.path.join(wc_dir, 'A', 'mu')
144
svntest.main.file_append(mu_path, '$LastChangedRevision$')
145
svntest.main.run_svn(None, 'ps', 'svn:keywords',
146
'LastChangedRevision', mu_path)
147
svntest.main.run_svn(None, 'ci',
148
'--username', svntest.main.wc_author,
149
'--password', svntest.main.wc_passwd,
150
'-m', 'Added keyword to mu', mu_path)
152
expected_disk = svntest.main.greek_state.copy()
153
expected_disk.tweak('A/mu',
154
contents=expected_disk.desc['A/mu'].contents +
155
'$LastChangedRevision: 2 $')
157
export_target = sbox.add_wc_path('export')
159
expected_output = svntest.main.greek_state.copy()
160
expected_output.wc_dir = export_target
161
expected_output.desc[''] = Item()
162
expected_output.tweak(contents=None, status='A ')
164
svntest.actions.run_and_verify_export(sbox.repo_url,
169
def export_eol_translation(sbox):
170
"export with eol translation"
175
# Append a '\n' to A/mu and set svn:eol-style to 'CR'
176
# to see if it's applied correctly in the export operation
177
mu_path = os.path.join(wc_dir, 'A', 'mu')
178
svntest.main.file_append(mu_path, '\n')
179
svntest.main.run_svn(None, 'ps', 'svn:eol-style',
181
svntest.main.run_svn(None, 'ci',
182
'--username', svntest.main.wc_author,
183
'--password', svntest.main.wc_passwd,
184
'-m', 'Added eol-style prop to mu', mu_path)
186
expected_disk = svntest.main.greek_state.copy()
187
expected_disk.tweak('A/mu',
188
contents=expected_disk.desc['A/mu'].contents +
191
export_target = sbox.add_wc_path('export')
193
expected_output = svntest.main.greek_state.copy()
194
expected_output.wc_dir = export_target
195
expected_output.desc[''] = Item()
196
expected_output.tweak(contents=None, status='A ')
198
svntest.actions.run_and_verify_export(sbox.repo_url,
203
def export_working_copy_with_keyword_translation(sbox):
204
"export working copy with keyword translation"
209
# Add a keyword to A/mu and set the svn:keywords property
210
# appropriately to make sure it's translated during
211
# the export operation
212
mu_path = os.path.join(wc_dir, 'A', 'mu')
213
svntest.main.file_append(mu_path, '$LastChangedRevision$')
214
svntest.main.run_svn(None, 'ps', 'svn:keywords',
215
'LastChangedRevision', mu_path)
217
expected_disk = svntest.main.greek_state.copy()
218
expected_disk.tweak('A/mu',
219
contents=expected_disk.desc['A/mu'].contents +
220
'$LastChangedRevision: 1M $')
222
export_target = sbox.add_wc_path('export')
224
svntest.actions.run_and_verify_export(wc_dir,
226
svntest.wc.State(sbox.wc_dir, {}),
229
def export_working_copy_with_property_mods(sbox):
230
"export working copy with property mods"
235
# Make a local property mod to A/mu
236
mu_path = os.path.join(wc_dir, 'A', 'mu')
237
svntest.main.file_append(mu_path, '\n')
238
svntest.main.run_svn(None, 'ps', 'svn:eol-style',
241
expected_disk = svntest.main.greek_state.copy()
242
expected_disk.tweak('A/mu',
243
contents=expected_disk.desc['A/mu'].contents +
246
export_target = sbox.add_wc_path('export')
248
svntest.actions.run_and_verify_export(wc_dir,
250
svntest.wc.State(sbox.wc_dir, {}),
253
def export_working_copy_at_base_revision(sbox):
254
"export working copy at base revision"
259
mu_path = os.path.join(wc_dir, 'A', 'mu')
260
kappa_path = os.path.join(wc_dir, 'kappa')
261
gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
262
E_path = os.path.join(wc_dir, 'A', 'B', 'E')
264
# Appends some text to A/mu, and add a new file
265
# called kappa. These modifications should *not*
266
# get exported at the base revision.
267
svntest.main.file_append(mu_path, 'Appended text')
268
svntest.main.file_append(kappa_path, "This is the file 'kappa'.")
269
svntest.main.run_svn(None, 'add', kappa_path)
270
svntest.main.run_svn(None, 'rm', E_path, gamma_path)
272
# Note that we don't tweak the expected disk tree at all,
273
# since the appended text and kappa should not be present.
274
expected_disk = svntest.main.greek_state.copy()
276
export_target = sbox.add_wc_path('export')
278
svntest.actions.run_and_verify_export(wc_dir,
280
svntest.wc.State(sbox.wc_dir, {}),
282
None, None, None, None,
285
def export_native_eol_option(sbox):
286
"export with --native-eol"
291
# Append a '\n' to A/mu and set svn:eol-style to 'native'
292
# to see if it's applied correctly in the export operation
293
mu_path = os.path.join(wc_dir, 'A', 'mu')
294
svntest.main.file_append(mu_path, '\n')
295
svntest.main.run_svn(None, 'ps', 'svn:eol-style',
297
svntest.main.run_svn(None, 'ci',
298
'--username', svntest.main.wc_author,
299
'--password', svntest.main.wc_passwd,
300
'-m', 'Added eol-style prop to mu', mu_path)
302
expected_disk = svntest.main.greek_state.copy()
303
expected_disk.tweak('A/mu',
304
contents=expected_disk.desc['A/mu'].contents +
307
export_target = sbox.add_wc_path('export')
309
expected_output = svntest.main.greek_state.copy()
310
expected_output.wc_dir = export_target
311
expected_output.desc[''] = Item()
312
expected_output.tweak(contents=None, status='A ')
314
svntest.actions.run_and_verify_export(sbox.repo_url,
318
None, None, None, None,
321
def export_nonexistant_file(sbox):
322
"export nonexistant file"
327
kappa_path = os.path.join(wc_dir, 'kappa')
329
export_target = sbox.add_wc_path('export')
331
svntest.actions.run_and_verify_svn("No error where one is expected",
332
None, svntest.SVNAnyOutput,
333
'export', kappa_path, export_target)
335
def export_unversioned_file(sbox):
336
"export unversioned file"
341
kappa_path = os.path.join(wc_dir, 'kappa')
342
svntest.main.file_append(kappa_path, "This is the file 'kappa'.")
344
export_target = sbox.add_wc_path('export')
346
svntest.actions.run_and_verify_svn("No error where one is expected",
347
None, svntest.SVNAnyOutput,
348
'export', kappa_path, export_target)
350
def export_with_state_deleted(sbox):
351
"export with state deleted=true"
356
# state deleted=true caused export to crash
357
alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')
358
svntest.actions.run_and_verify_svn(None, None, [], 'rm', alpha_path)
359
expected_output = svntest.wc.State(wc_dir, {
360
'A/B/E/alpha' : Item(verb='Deleting'),
362
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
363
expected_status.tweak(wc_rev=1)
364
expected_status.remove('A/B/E/alpha')
365
svntest.actions.run_and_verify_commit(wc_dir,
366
expected_output, expected_status,
367
None, None, None, None, None,
370
export_target = sbox.add_wc_path('export')
371
expected_output = svntest.wc.State(sbox.wc_dir, {})
372
expected_disk = svntest.main.greek_state.copy()
373
expected_disk.remove('A/B/E/alpha')
374
svntest.actions.run_and_verify_export(sbox.wc_dir,
379
########################################################################
383
# list all tests here, starting with None:
385
export_empty_directory,
388
export_working_copy_with_mods,
389
export_over_existing_dir,
390
export_keyword_translation,
391
export_eol_translation,
392
export_working_copy_with_keyword_translation,
393
export_working_copy_with_property_mods,
394
export_working_copy_at_base_revision,
395
export_native_eol_option,
396
export_nonexistant_file,
397
export_unversioned_file,
398
export_with_state_deleted,
401
if __name__ == '__main__':
402
svntest.main.run_tests(test_list)