📄 copy_tests.py
字号:
# 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) expected_output = svntest.wc.State(wc_dir, {'A/mu' : Item(verb='Restored')}) svntest.actions.run_and_verify_update(wc_dir, expected_output, expected_disk, expected_status) #----------------------------------------------------------------------# Regression test for issue 1634def 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') 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='-'), 'A/B/E/alpha' : Item(status=' ', copied='+', wc_rev='-'), 'A/B/E/beta' : Item(status=' ', copied='+', wc_rev='-'), }) 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='-'), 'A/B/E/alpha' : Item(status=' ', copied='+', wc_rev='-'), 'A/B/E/beta' : Item(status=' ', copied='+', wc_rev='-'), }) svntest.actions.run_and_verify_status (wc_dir, expected_status)#----------------------------------------------------------------------# Regression test for issue 1814def 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)#----------------------------------------------------------------------# Regression test for issues 2404def wc_to_wc_copy_between_different_repos(sbox): "wc to wc copy attempts between different repos" sbox.build() wc_dir = sbox.wc_dir sbox2 = sbox.clone_dependent() sbox2.build() wc2_dir = sbox2.wc_dir # Attempt a copy between different repositories. out, err = svntest.main.run_svn(1, 'cp', os.path.join(wc2_dir, 'A'), os.path.join(wc_dir, 'A', 'B')) for line in err: if line.find("it is not from repository") != -1: break else: raise svntest.Failure#----------------------------------------------------------------------# Regression test for issues 2101 and 2020def wc_to_wc_copy_deleted(sbox): "wc to wc copy with deleted=true items" sbox.build() wc_dir = sbox.wc_dir B_path = os.path.join(wc_dir, 'A', 'B') B2_path = os.path.join(wc_dir, 'A', 'B2') # Schedule for delete svntest.actions.run_and_verify_svn(None, None, [], 'rm', os.path.join(B_path, 'E', 'alpha'), os.path.join(B_path, 'lambda'), os.path.join(B_path, 'F')) expected_status = svntest.actions.get_virginal_state(wc_dir, 1) expected_status.tweak('A/B/E/alpha', 'A/B/lambda', 'A/B/F', status='D ') svntest.actions.run_and_verify_status (wc_dir, expected_status) # Copy to schedule=delete fails out, err = svntest.main.run_svn(1, 'cp', os.path.join(B_path, 'E'), os.path.join(B_path, 'F')) for line in err: if line.find("is scheduled for deletion") != -1: break else: raise svntest.Failure svntest.actions.run_and_verify_status (wc_dir, expected_status) # Commit to get state deleted expected_status.remove('A/B/E/alpha', 'A/B/lambda', 'A/B/F') expected_output = svntest.wc.State(wc_dir, { 'A/B/E/alpha' : Item(verb='Deleting'), 'A/B/lambda' : Item(verb='Deleting'), 'A/B/F' : Item(verb='Deleting'), }) svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) # Copy including stuff in state deleted=true svntest.actions.run_and_verify_svn(None, None, [], 'copy', B_path, B2_path) expected_status.add({ 'A/B2' : Item(status='A ', wc_rev='-', copied='+'), 'A/B2/E' : Item(status=' ', wc_rev='-', copied='+'), 'A/B2/E/beta' : Item(status=' ', wc_rev='-', copied='+'), 'A/B2/E/alpha' : Item(status='D ', wc_rev='-', copied='+'), 'A/B2/lambda' : Item(status='D ', wc_rev='-', copied='+'), 'A/B2/F' : Item(status='D ', wc_rev='-', copied='+'), }) svntest.actions.run_and_verify_status(wc_dir, expected_status) # Stuff copied from state deleted=true is now schedule=delete. # Attempts to revert the schedule=delete will fail, but should not # break the wc. It's very important that the directory revert fails # since it's a placeholder rather than a full hierarchy out, err = svntest.main.run_svn(1, 'revert', '--recursive', os.path.join(B2_path, 'F')) for line in err: if line.find("Error restoring text") != -1: break else: raise svntest.Failure out, err = svntest.main.run_svn(1, 'revert', os.path.join(B2_path, 'lambda')) for line in err: if line.find("Error restoring text") != -1: break else: raise svntest.Failure svntest.actions.run_and_verify_status(wc_dir, expected_status) # Revert the entire copy including the schedule delete bits svntest.actions.run_and_verify_svn(None, None, [], 'revert', '--recursive', B2_path) expected_status.remove('A/B2', 'A/B2/E', 'A/B2/E/beta', 'A/B2/E/alpha', 'A/B2/lambda', 'A/B2/F') svntest.actions.run_and_verify_status(wc_dir, expected_status) svntest.main.safe_rmtree(B2_path) # Copy again and commit svntest.actions.run_and_verify_svn(None, None, [], 'copy', B_path, B2_path) expected_status.add({ 'A/B2' : Item(status=' ', wc_rev=3), 'A/B2/E' : Item(status=' ', wc_rev=3), 'A/B2/E/beta' : Item(status=' ', wc_rev=3), }) expected_output = svntest.wc.State(wc_dir, { 'A/B2' : Item(verb='Adding'), 'A/B2/E/alpha' : Item(verb='Deleting'), 'A/B2/lambda' : Item(verb='Deleting'), 'A/B2/F' : Item(verb='Deleting'), }) svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir)#----------------------------------------------------------------------# Test for copy into a non-existent URL path def url_to_non_existent_url_path(sbox): "svn cp src-URL non-existent-URL-path" sbox.build(create_wc = False) dirURL1 = svntest.main.current_repo_url + "/A/B/E" dirURL2 = svntest.main.current_repo_url + "/G/C/E/I" # Look for both possible versions of the error message, as the DAV # error is worded differently from that of other RA layers. msg = ".*: (Path 'G' not present|.*G' path not found)" # Expect failure on 'svn cp SRC DST' where one or more ancestor # directories of DST do not exist out, err = svntest.main.run_svn(1, 'cp', dirURL1, dirURL2, '--username', svntest.main.wc_author, '--password', svntest.main.wc_passwd, '-m', 'fooogle') for err_line in err: if re.match (msg, err_line): break else: print "message \"" + msg + "\" not found in error output: ", err raise svntest.Failure#----------------------------------------------------------------------# Test for a copying (URL to URL) an old rev of a deleted file in a# deleted directory.def non_existent_url_to_url(sbox): "svn cp oldrev-of-deleted-URL URL" sbox.build(create_wc = False) adg_url = svntest.main.current_repo_url + '/A/D/G' pi_url = svntest.main.current_repo_url + '/A/D/G/pi' new_url = svntest.main.current_repo_url + '/newfile' svntest.actions.run_and_verify_svn(None, None, [], 'delete', adg_url, '-m', '') svntest.actions.run_and_verify_svn(None, None, [], 'copy', '-r', '1', pi_url, new_url, '-m', '')#----------------------------------------------------------------------def old_dir_url_to_url(sbox): "test URL to URL copying edge case" sbox.build(create_wc = False) adg_url = svntest.main.current_repo_url + '/A/D/G' pi_url = svntest.main.current_repo_url + '/A/D/G/pi' iota_url = svntest.main.current_repo_url + '/iota' new_url = svntest.main.current_repo_url + '/newfile' # Delete a directory svntest.actions.run_and_verify_svn(None, None, [], 'delete', adg_url, '-m', '') # Copy a file to where the directory used to be svntest.actions.run_and_verify_svn(None, None, [], 'copy', iota_url, adg_url, '-m', '') # Try copying a file that was in the deleted directory that is now a # file svntest.actions.run_and_verify_svn(None, None, [], 'copy', '-r', '1', pi_url, new_url, '-m', '')#----------------------------------------------------------------------# Test fix for issue 2224 - copying wc dir to itself causes endless# recursiondef wc_copy_dir_to_itself(sbox): "copy wc dir to itself" sbox.build() wc_dir = sbox.wc_dir dnames = ['A','A/B'] for dirname in dnames: dir_path = os.path.join(sbox.wc_dir, dirname) # try to copy dir to itself svntest.actions.run_and_verify_svn(None, [], '.*Cannot copy .* into its own child.*', 'copy', dir_path, dir_path)#----------------------------------------------------------------------def mixed_wc_to_url(sbox): "copy a complex mixed-rev wc" # For issue 2153. # # Copy a mixed-revision wc (that also has some uncommitted local # mods, and an entry marked as 'deleted') to a URL. Make sure the # copy gets the uncommitted mods, and does not contain the deleted # file. sbox.build() wc_dir = sbox.wc_dir url = svntest.main.current_repo_url G_url = svntest.main.current_repo_url + '/A/D/G' Z_url = svntest.main.current_repo_url + '/A/D/Z
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -