3
# import_tests.py: import tests
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 string, re, os.path
24
from svntest import wc, SVNAnyOutput
27
Skip = svntest.testcase.Skip
28
XFail = svntest.testcase.XFail
31
######################################################################
34
# Each test must return on success or raise on failure.
36
#----------------------------------------------------------------------
37
# this test should be SKIPped on systems without the executable bit
38
def import_executable(sbox):
39
"import of executable files"
44
# create a new directory with files of various permissions
45
xt_path = os.path.join(wc_dir, "XT")
47
all_path = os.path.join(wc_dir, "XT/all_exe")
48
none_path = os.path.join(wc_dir, "XT/none_exe")
49
user_path = os.path.join(wc_dir, "XT/user_exe")
50
group_path = os.path.join(wc_dir, "XT/group_exe")
51
other_path = os.path.join(wc_dir, "XT/other_exe")
53
for path in [all_path, none_path, user_path, group_path, other_path]:
54
svntest.main.file_append(path, "some text")
57
os.chmod(all_path, 0777)
58
os.chmod(none_path, 0666)
59
os.chmod(user_path, 0766)
60
os.chmod(group_path, 0676)
61
os.chmod(other_path, 0667)
63
# import new files into repository
64
url = svntest.main.current_repo_url
65
output, errput = svntest.actions.run_and_verify_svn(
66
None, None, [], 'import',
67
'--username', svntest.main.wc_author,
68
'--password', svntest.main.wc_passwd,
69
'-m', 'Log message for new import', xt_path, url)
71
lastline = string.strip(output.pop())
72
cm = re.compile ("(Committed|Imported) revision [0-9]+.")
73
match = cm.search (lastline)
75
### we should raise a less generic error here. which?
78
# remove (uncontrolled) local files
79
svntest.main.safe_rmtree(xt_path)
81
# Create expected disk tree for the update (disregarding props)
82
expected_disk = svntest.main.greek_state.copy()
84
'all_exe' : Item('some text', props={'svn:executable' : ''}),
85
'none_exe' : Item('some text'),
86
'user_exe' : Item('some text', props={'svn:executable' : ''}),
87
'group_exe' : Item('some text'),
88
'other_exe' : Item('some text'),
91
# Create expected status tree for the update (disregarding props).
92
# Newly imported file should be at revision 2.
93
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
95
'all_exe' : Item(status=' ', wc_rev=2),
96
'none_exe' : Item(status=' ', wc_rev=2),
97
'user_exe' : Item(status=' ', wc_rev=2),
98
'group_exe' : Item(status=' ', wc_rev=2),
99
'other_exe' : Item(status=' ', wc_rev=2),
102
# Create expected output tree for the update.
103
expected_output = svntest.wc.State(wc_dir, {
104
'all_exe' : Item(status='A '),
105
'none_exe' : Item(status='A '),
106
'user_exe' : Item(status='A '),
107
'group_exe' : Item(status='A '),
108
'other_exe' : Item(status='A '),
110
# do update and check three ways
111
svntest.actions.run_and_verify_update(wc_dir,
118
#----------------------------------------------------------------------
119
def import_ignores(sbox):
120
'do not import ignored files in imported dirs'
126
# where dir contains some items that match the ignore list and some
127
# do not would add all items, ignored or not.
129
# This has been fixed by testing each item with the new
130
# svn_wc_is_ignored function.
135
dir_path = os.path.join(wc_dir, 'dir')
136
foo_c_path = os.path.join(dir_path, 'foo.c')
137
foo_o_path = os.path.join(dir_path, 'foo.o')
139
os.mkdir(dir_path, 0755)
140
open(foo_c_path, 'w')
141
open(foo_o_path, 'w')
143
# import new dir into repository
144
url = svntest.main.current_repo_url + '/dir'
146
output, errput = svntest.actions.run_and_verify_svn(
147
None, None, [], 'import',
148
'--username', svntest.main.wc_author,
149
'--password', svntest.main.wc_passwd,
150
'-m', 'Log message for new import',
153
lastline = string.strip(output.pop())
154
cm = re.compile ("(Committed|Imported) revision [0-9]+.")
155
match = cm.search (lastline)
157
### we should raise a less generic error here. which?
158
raise svntest.actions.SVNUnexpectedOutput
160
# remove (uncontrolled) local dir
161
svntest.main.safe_rmtree(dir_path)
163
# Create expected disk tree for the update (disregarding props)
164
expected_disk = svntest.main.greek_state.copy()
166
'dir/foo.c' : Item(''),
169
# Create expected status tree for the update (disregarding props).
170
# Newly imported file should be at revision 2.
171
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
172
expected_status.add({
173
'dir' : Item(status=' ', wc_rev=2),
174
'dir/foo.c' : Item(status=' ', wc_rev=2),
177
# Create expected output tree for the update.
178
expected_output = svntest.wc.State(wc_dir, {
179
'dir' : Item(status='A '),
180
'dir/foo.c' : Item(status='A '),
183
# do update and check three ways
184
svntest.actions.run_and_verify_update(wc_dir,
191
#----------------------------------------------------------------------
192
def import_avoid_empty_revision(sbox):
193
"avoid creating empty revisions with import"
198
# create a new directory
199
empty_dir = os.path.join(wc_dir, "empty_dir")
200
os.makedirs(empty_dir)
202
url = svntest.main.current_repo_url
203
svntest.actions.run_and_verify_svn(None, None, None, 'import',
204
'--username', svntest.main.wc_author,
205
'--password', svntest.main.wc_passwd,
206
'-m', 'Log message for new import',
209
svntest.main.safe_rmtree(empty_dir)
211
# Verify that an empty revision has not been created
212
svntest.actions.run_and_verify_svn(None, [ "At revision 1.\n"],
214
'--username', svntest.main.wc_author,
215
'--password', svntest.main.wc_passwd,
218
#----------------------------------------------------------------------
219
########################################################################
223
# list all tests here, starting with None:
225
Skip(import_executable, (os.name != 'posix')),
227
import_avoid_empty_revision,
230
if __name__ == '__main__':
231
svntest.main.run_tests(test_list)