📄 update_tests.py
字号:
expected_output = svntest.wc.State(wc_dir, { 'A/D/G' : Item(status='D '), }) expected_disk = svntest.main.greek_state.copy() expected_disk.remove('A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau') expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.remove('A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau') svntest.actions.run_and_verify_update(wc_dir, expected_output, expected_disk, expected_status) # Do a URL->wc copy, creating a new schedule-add A/D/G. # (Standard procedure when trying to resurrect the directory.) D_path = os.path.join(wc_dir, 'A', 'D') svntest.actions.run_and_verify_svn("Copy error:", None, [], 'cp', '-r', '1', G_url, D_path) # status should now show the dir scheduled for addition-with-history expected_status.add({ 'A/D/G' : Item(status='A ', copied='+', wc_rev='-'), 'A/D/G/pi' : Item(status=' ', copied='+', wc_rev='-'), 'A/D/G/rho' : Item(status=' ', copied='+', wc_rev='-'), 'A/D/G/tau' : Item(status=' ', copied='+', wc_rev='-'), }) svntest.actions.run_and_verify_status (wc_dir, expected_status) # Now update with the schedule-add dir as the target. svntest.actions.run_and_verify_svn(None, None, [], 'up', G_path) # The update should be a no-op, and the schedule-add directory # should still exist! 'svn status' shouldn't change at all. svntest.actions.run_and_verify_status (wc_dir, expected_status) #----------------------------------------------------------------------# Test updating items that do not exist in the current WC rev, but do# exist at some future revision.def update_to_future_add(sbox): "update target that was added in a future rev" sbox.build() wc_dir = sbox.wc_dir # Update the entire WC to rev 0 # Create expected output tree for an update to rev 0 expected_output = svntest.wc.State(wc_dir, { 'iota' : Item(status='D '), 'A' : Item(status='D '), }) # Create expected disk tree for the update to rev 0 expected_disk = svntest.wc.State(wc_dir, { }) # Do the update and check the results. svntest.actions.run_and_verify_update(wc_dir, expected_output, expected_disk, None, None, None, None, None, None, 0, '-r', '0', wc_dir) # Update iota to the current HEAD. iota_path = os.path.join(wc_dir, 'iota') expected_output = svntest.wc.State(wc_dir, { 'iota' : Item(status='A '), }) expected_disk = svntest.wc.State('', { 'iota' : Item("This is the file 'iota'.\n") }) svntest.actions.run_and_verify_update(wc_dir, expected_output, expected_disk, None, None, None, None, None, None, 0, iota_path) # Now try updating the directory into the future A_path = os.path.join(wc_dir, 'A') expected_status = svntest.wc.State(wc_dir, { 'A' : Item(status='A '), 'A/mu' : Item(status='A '), 'A/B' : Item(status='A '), 'A/B/lambda' : Item(status='A '), 'A/B/E' : Item(status='A '), 'A/B/E/alpha' : Item(status='A '), 'A/B/E/beta' : Item(status='A '), 'A/B/F' : Item(status='A '), 'A/C' : Item(status='A '), 'A/D' : Item(status='A '), 'A/D/gamma' : Item(status='A '), 'A/D/G' : Item(status='A '), 'A/D/G/pi' : Item(status='A '), 'A/D/G/rho' : Item(status='A '), 'A/D/G/tau' : Item(status='A '), 'A/D/H' : Item(status='A '), 'A/D/H/chi' : Item(status='A '), 'A/D/H/psi' : Item(status='A '), 'A/D/H/omega' : Item(status='A ') }) expected_disk = svntest.main.greek_state.copy() svntest.actions.run_and_verify_update(wc_dir, expected_status, expected_disk, None, None, None, None, None, None, 0, A_path);#----------------------------------------------------------------------def nested_in_read_only(sbox): "update a nested wc in a read-only wc" sbox.build() wc_dir = sbox.wc_dir # Delete/commit a file alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha') svntest.actions.run_and_verify_svn(None, None, [], 'rm', alpha_path) expected_output = svntest.wc.State(wc_dir, { 'A/B/E/alpha' : Item(verb='Deleting'), }) expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.remove('A/B/E/alpha') svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) svntest.actions.run_and_verify_svn(None, None, [], 'up', wc_dir) expected_status.tweak(wc_rev=2) svntest.actions.run_and_verify_status(wc_dir, expected_status) # Delete/commit a directory that used to contain the deleted file B_path = os.path.join(wc_dir, 'A', 'B') svntest.actions.run_and_verify_svn(None, None, [], 'rm', B_path) expected_output = svntest.wc.State(wc_dir, { 'A/B' : Item(verb='Deleting'), }) expected_status.remove('A/B', 'A/B/lambda', 'A/B/E', 'A/B/E/beta', 'A/B/F') svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) svntest.actions.run_and_verify_svn(None, None, [], 'up', wc_dir) expected_status.tweak(wc_rev=3) svntest.actions.run_and_verify_status(wc_dir, expected_status) # Replace the deleted directory with a new checkout of an old # version of the directory, this gives it a "plausible" URL that # could be part of the containing wc B_url = svntest.main.current_repo_url + '/A/B' svntest.actions.run_and_verify_svn(None, None, [], 'checkout', '-r', '1', B_url + "@1", B_path) expected_status = svntest.wc.State(B_path, { '' : Item(), 'lambda' : Item(), 'E' : Item(), 'E/alpha' : Item(), 'E/beta' : Item(), 'F' : Item(), }) expected_status.tweak(wc_rev=1, status=' ') svntest.actions.run_and_verify_status(B_path, expected_status) # Make enclosing wc read only os.chmod(os.path.join(wc_dir, 'A', svntest.main.get_admin_name()), 0555) try: # Update of nested wc should still work expected_output = svntest.wc.State(B_path, { 'E/alpha' : Item(status='D '), }) expected_disk = wc.State('', { 'lambda' : wc.StateItem("This is the file 'lambda'.\n"), 'E' : wc.StateItem(), 'E/beta' : wc.StateItem("This is the file 'beta'.\n"), 'F' : wc.StateItem(), }) expected_status.remove('E/alpha') expected_status.tweak(wc_rev=2) svntest.actions.run_and_verify_update(B_path, expected_output, expected_disk, expected_status, None, None, None, None, None, 0, '-r', '2', B_path) finally: os.chmod(os.path.join(wc_dir, 'A', svntest.main.get_admin_name()), 0777)#----------------------------------------------------------------------def update_xml_unsafe_dir(sbox): "update dir with xml-unsafe name" sbox.build() wc_dir = sbox.wc_dir # Make a backup copy of the working copy wc_backup = sbox.add_wc_path('backup') svntest.actions.duplicate_dir(wc_dir, wc_backup) # Make a couple of local mods to files test_path = os.path.join(wc_dir, ' foo & bar') svntest.main.run_svn(None, 'mkdir', test_path) # Created expected output tree for 'svn ci' expected_output = wc.State(wc_dir, { ' foo & bar' : Item(verb='Adding'), }) # Create expected status tree; all local revisions should be at 1, # but 'foo & bar' should be at revision 2. expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.add({ ' foo & bar' : Item(status=' ', wc_rev=2), }) # Commit. svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) # chdir into the funky path, and update from there. was_cwd = os.getcwd() os.chdir(test_path) try: expected_output = wc.State('', { }) expected_disk = wc.State('', { }) expected_status = wc.State('', { '' : Item(status=' ', wc_rev=2), }) svntest.actions.run_and_verify_update('', expected_output, expected_disk, expected_status) finally: os.chdir(was_cwd)#----------------------------------------------------------------------# Issue #2529.def checkout_broken_eol(sbox): "checkout file with broken eol style" data_dir = os.path.join(os.path.dirname(sys.argv[0]), 'update_tests_data') dump_str = file(os.path.join(data_dir, "checkout_broken_eol.dump"), "rb").read() # Create virgin repos and working copy svntest.main.safe_rmtree(sbox.repo_dir, 1) svntest.main.create_repos(sbox.repo_dir) svntest.main.set_repos_paths(sbox.repo_dir) URL = svntest.main.current_repo_url # Load the dumpfile into the repos. output, errput = \ svntest.main.run_command_stdin( "%s load --quiet %s" % (svntest.main.svnadmin_binary, sbox.repo_dir), None, 1, [dump_str]) expected_output = svntest.wc.State(sbox.wc_dir, { 'file': Item(status='A '), }) expected_wc = svntest.wc.State('', { 'file': Item(contents='line\nline2\n'), }) svntest.actions.run_and_verify_checkout(URL, sbox.wc_dir, expected_output, expected_wc)def conflict_markers_matching_eol(sbox): "conflict markers should match the file's eol style" sbox.build() wc_dir = sbox.wc_dir filecount = 1 mu_path = os.path.join(wc_dir, 'A', 'mu') if os.name == 'nt': crlf = '\n' else: crlf = '\r\n' # Checkout a second working copy of wc_backup = sbox.add_wc_path('backup') svntest.actions.run_and_verify_svn(None, None, [], 'checkout', sbox.repo_url, wc_backup) # set starting revision cur_rev = 1 expected_disk = svntest.main.greek_state.copy() expected_status = svntest.actions.get_virginal_state(wc_dir, cur_rev) expected_backup_status = svntest.actions.get_virginal_state(wc_backup, cur_rev) # do the test for each eol-style for eol, eolchar in zip(['CRLF', 'CR', 'native', 'LF'], [crlf, '\015', '\n', '\012']): path_backup = os.path.join(wc_backup, 'A', 'mu') # add a new file with the eol-style property set. open(mu_path, 'wb').write("This is the file 'mu'."+ eolchar) svntest.main.run_svn(None, 'propset', 'svn:eol-style', eol, mu_path) expected_disk.add({ 'A/mu' : Item("This is the file 'mu'." + eolchar) }) expected_output = svntest.wc.State(wc_dir, { 'A/mu' : Item(verb='Sending'), }) expected_status.tweak(wc_rev = cur_rev) expected_status.add({ 'A/mu' : Item(status=' ', wc_rev = cur_rev + 1), }) # Commit the original change and note the 'base' revision number svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) cur_rev = cur_rev + 1 base_rev = cur_rev svntest.main.run_svn(None, 'update', wc_backup) # Make a local mod to mu svntest.main.file_append(mu_path, 'Original appended text for mu' + eolchar) # Commit the original change and note the 'theirs' revision number svntest.main.run_svn(None, 'commit', '-m', 'test log', wc_dir) cur_rev = cur_rev + 1 theirs_rev = cur_rev # Make a local mod to mu, will conflict with the previous change svntest.main.file_append (path_backup, 'Conflicting appended text for mu' + eolchar) # Create expected output tree for an update of the wc_backup. expected_back
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -