📄 copy_tests.py
字号:
'F/B/F' : Item(status=' ', wc_rev=2, repos_rev=2),
'F/B/lambda' : Item(status=' ', wc_rev=2, repos_rev=2),
})
svntest.actions.run_and_verify_update(wc_dir,
expected_output,
expected_disk,
expected_status)
#----------------------------------------------------------------------
# Issue 1419: at one point ra_dav->get_uuid() was failing on a
# non-existent public URL, which prevented us from resurrecting files
# (svn cp -rOLD URL wc).
def resurrect_deleted_file(sbox):
"resurrect a deleted file"
sbox.build()
wc_dir = sbox.wc_dir
# Delete a file in the repository via immediate commit
rho_url = svntest.main.current_repo_url + '/A/D/G/rho'
svntest.actions.run_and_verify_svn(None, None, [],
'rm', rho_url, '-m', 'rev 2')
# Update the wc to HEAD (r2)
expected_output = svntest.wc.State(wc_dir, {
'A/D/G/rho' : Item(status='D '),
})
expected_disk = svntest.main.greek_state.copy()
expected_disk.remove('A/D/G/rho')
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.remove('A/D/G/rho')
svntest.actions.run_and_verify_update(wc_dir,
expected_output,
expected_disk,
expected_status)
# repos->wc copy, to resurrect deleted file.
svntest.actions.run_and_verify_svn("Copy error:", None, [],
'cp', '-r', '1', rho_url, wc_dir)
# status should now show the file scheduled for addition-with-history
expected_status.add({
'rho' : Item(status='A ', copied='+', wc_rev='-', repos_rev=2),
})
svntest.actions.run_and_verify_status (wc_dir, expected_status)
#-------------------------------------------------------------
# Regression tests for Issue #1297:
# svn diff failed after a repository to WC copy of a single file
# This test checks just that.
def diff_repos_to_wc_copy(sbox):
"copy file from repos to working copy and run diff"
sbox.build()
wc_dir = sbox.wc_dir
iota_repos_path = svntest.main.current_repo_url + '/iota'
target_wc_path = os.path.join(wc_dir, 'new_file')
# Copy a file from the repository to the working copy.
svntest.actions.run_and_verify_svn(None, None, [], 'cp',
iota_repos_path, target_wc_path)
# Run diff.
svntest.actions.run_and_verify_svn(None, None, [], 'diff', wc_dir)
#-------------------------------------------------------------
def repos_to_wc_copy_eol_keywords(sbox):
"repos->WC copy with keyword or eol property set"
# See issue #1473: repos->wc copy would seg fault if svn:keywords or
# svn:eol were set on the copied file, because we'd be querying an
# entry for keyword values when the entry was still null (because
# not yet been fully installed in the wc).
sbox.build()
wc_dir = sbox.wc_dir
iota_repos_path = svntest.main.current_repo_url + '/iota'
iota_wc_path = os.path.join(wc_dir, 'iota')
target_wc_path = os.path.join(wc_dir, 'new_file')
# Modify iota to make it checkworthy.
f = open(iota_wc_path, "ab")
f.write("\nHello\nSubversion\n$LastChangedRevision$\n")
f.close()
svntest.actions.run_and_verify_svn(None, None, [],
'propset', 'svn:eol-style',
'CRLF', iota_wc_path)
svntest.actions.run_and_verify_svn(None, None, [],
'propset', 'svn:keywords',
'Rev', iota_wc_path)
svntest.actions.run_and_verify_svn(None, None, [],
'commit', '-m', 'log msg',
wc_dir)
# Copy a file from the repository to the working copy.
svntest.actions.run_and_verify_svn(None, None, [], 'cp',
iota_repos_path, target_wc_path)
# The original bug was that the copy would seg fault. So we test
# that the copy target exists now; if it doesn't, it's probably
# because of the segfault. Note that the crash would be independent
# of whether there are actually any line breaks or keywords in the
# file's contents -- the mere existence of the property would
# trigger the bug.
if not os.path.exists(target_wc_path):
raise svntest.Failure
# Okay, if we got this far, we might as well make sure that the
# translations/substitutions were done correctly:
f = open(target_wc_path, "rb")
raw_contents = f.read()
f.seek(0, 0)
line_contents = f.readlines()
f.close()
if re.match('[^\\r]\\n', raw_contents):
raise svntest.Failure
if not re.match('.*\$LastChangedRevision:\s*\d+\s*\$', line_contents[3]):
raise svntest.Failure
#-------------------------------------------------------------
# Regression test for revision 7331, with commented-out parts for a further
# similar bug.
def revision_kinds_local_source(sbox):
"revision-kind keywords with non-URL source"
sbox.build()
wc_dir = sbox.wc_dir
mu_path = os.path.join(wc_dir, 'A', 'mu')
# Make a file with different content in each revision and WC; BASE != HEAD.
expected_output = svntest.wc.State(wc_dir, {
'A/mu' : Item(verb='Sending'), })
svntest.main.file_append(mu_path, "New r2 text.")
svntest.actions.run_and_verify_commit(wc_dir, expected_output, None,
None, None, None, None, None, wc_dir)
svntest.main.file_append(mu_path, "New r3 text.")
svntest.actions.run_and_verify_commit(wc_dir, expected_output, None,
None, None, None, None, None, wc_dir)
svntest.actions.run_and_verify_svn(None, None, [], 'up', '-r2', mu_path)
svntest.main.file_append(mu_path, "Working copy.")
r1 = "This is the file 'mu'."
r2 = r1 + "New r2 text."
r3 = r2 + "New r3 text."
rWC = r2 + "Working copy."
expected_disk = svntest.main.greek_state.copy()
expected_disk.tweak('A/mu', contents=rWC)
# Test the various revision-kind keywords, and none.
sub_tests = [ ('file0', 2, rWC, None),
('file1', 3, r3, '-rHEAD'),
# ('file2', 2, r2, '-rBASE'),
# ('file3', 2, r2, '-rCOMMITTED'),
# ('file4', 1, r1, '-rPREV'),
]
for dst, from_rev, text, rev_arg in sub_tests:
dst_path = os.path.join(wc_dir, dst)
if rev_arg is None:
svntest.actions.run_and_verify_svn(None, None, [], "copy",
mu_path, dst_path)
else:
svntest.actions.run_and_verify_svn(None, None, [], "copy", rev_arg,
mu_path, dst_path)
expected_disk.add({ dst: Item(contents=text) })
# Check that the copied-from revision == from_rev.
output, errput = svntest.main.run_svn(None, "info", dst_path)
for line in output:
if line.rstrip() == "Copied From Rev: " + str(from_rev):
break
else:
print dst, "should have been copied from revision", from_rev
raise svntest.Failure
# Check that the new files have the right contents
actual_disk = svntest.tree.build_tree_from_wc(wc_dir)
svntest.tree.compare_trees(actual_disk, expected_disk.old_tree())
#-------------------------------------------------------------
# Regression test for issue 1581.
def copy_over_missing_file(sbox):
"copy over a missing file"
sbox.build()
wc_dir = sbox.wc_dir
mu_path = os.path.join(wc_dir, 'A', 'mu')
iota_path = os.path.join(wc_dir, 'iota')
iota_url = svntest.main.current_repo_url + "/iota"
# Make the target missing.
os.remove(mu_path)
# Try both wc->wc copy and repos->wc copy, expect failures:
svntest.actions.run_and_verify_svn(None, None, SVNAnyOutput,
'cp', iota_path, mu_path)
svntest.actions.run_and_verify_svn(None, None, SVNAnyOutput,
'cp', iota_url, mu_path)
# Make sure that the working copy is not corrupted:
expected_disk = svntest.main.greek_state.copy()
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
# Technically, we should expect "Restored" for A/mu, but apparently
# our output tree constructor doesn't know how to handle that, so we
# just pass an empty dictionary below. It doesn't matter so much,
# because the bug we're testing for would leave a bogus logfile in
# the .svn/ area after the copy; subsequent updates would fail in a
# much more dramatic way than merely not matching expected output.
expected_output = svntest.wc.State(wc_dir, {})
svntest.actions.run_and_verify_update(wc_dir,
expected_output,
expected_disk,
expected_status)
#----------------------------------------------------------------------
# Regression test for issue 1634
def repos_to_wc_1634(sbox):
"copy a deleted directory back from the repos"
sbox.build()
wc_dir = sbox.wc_dir
# First delete a subdirectory and commit.
E_path = wc_dir + "/A/B/E"
svntest.actions.run_and_verify_svn(None, None, [], 'delete', E_path)
expected_output = svntest.wc.State(wc_dir, {
'A/B/E' : Item(verb='Deleting'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.remove('A/B/E', 'A/B/E/alpha', 'A/B/E/beta')
expected_status.tweak(repos_rev=2)
svntest.actions.run_and_verify_commit (wc_dir,
expected_output,
expected_status,
None, None, None, None, None,
wc_dir)
# Now copy the directory back.
E_url = svntest.main.current_repo_url + "/A/B/E"
svntest.actions.run_and_verify_svn(None, None, [],
'copy', '-r1', E_url, E_path)
expected_status.add({
'A/B/E' : Item(status='A ', copied='+', wc_rev='-', repos_rev=2),
'A/B/E/alpha' : Item(status=' ', copied='+', wc_rev='-', repos_rev=2),
'A/B/E/beta' : Item(status=' ', copied='+', wc_rev='-', repos_rev=2),
})
svntest.actions.run_and_verify_status (wc_dir, expected_status)
svntest.actions.run_and_verify_svn(None, None, [], 'up', wc_dir)
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.add({
'A/B/E' : Item(status='A ', copied='+', wc_rev='-', repos_rev=2),
'A/B/E/alpha' : Item(status=' ', copied='+', wc_rev='-', repos_rev=2),
'A/B/E/beta' : Item(status=' ', copied='+', wc_rev='-', repos_rev=2),
})
svntest.actions.run_and_verify_status (wc_dir, expected_status)
#----------------------------------------------------------------------
# Regression test for issue 1814
def double_uri_escaping_1814(sbox):
"check for double URI escaping in svn ls -R"
sbox.build()
wc_dir = sbox.wc_dir
base_url = svntest.main.current_repo_url + '/base'
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', '-m', 'mybase',
base_url)
orig_url = base_url + '/foo%20bar'
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', '-m', 'r1',
orig_url)
orig_rev = get_repos_rev(sbox);
new_url = base_url + '/foo_bar'
svntest.actions.run_and_verify_svn(None, None, [], 'mv', '-m', 'r2',
orig_url, new_url)
# This had failed with ra_dav because "foo bar" would be double-encoded
# "foo bar" ==> "foo%20bar" ==> "foo%2520bar"
svntest.actions.run_and_verify_svn(None, None, [], 'ls', ('-r'+str(orig_rev)),
'-R', base_url)
########################################################################
# Run the tests
# list all tests here, starting with None:
test_list = [ None,
basic_copy_and_move_files,
mv_unversioned_file,
receive_copy_in_update,
resurrect_deleted_dir,
no_copy_overwrites,
no_wc_copy_overwrites,
copy_modify_commit,
copy_files_with_properties,
copy_delete_commit,
mv_and_revert_directory,
Skip(copy_preserve_executable_bit, (os.name != 'posix')),
wc_to_repos,
repos_to_wc,
copy_to_root,
url_copy_parent_into_child,
wc_copy_parent_into_child,
resurrect_deleted_file,
diff_repos_to_wc_copy,
repos_to_wc_copy_eol_keywords,
revision_kinds_local_source,
copy_over_missing_file,
repos_to_wc_1634,
double_uri_escaping_1814,
]
if __name__ == '__main__':
svntest.main.run_tests(test_list)
# NOTREACHED
### End of file.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -