📄 update_tests.py
字号:
expected_status, None, None, None, None, None, 0, mu_path, rho_path, E_path, H_path)#----------------------------------------------------------------------def update_ignores_added(sbox): "update should not munge adds or replaces" sbox.build() wc_dir = sbox.wc_dir # Commit something so there's actually a new revision to update to. rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho') svntest.main.file_append(rho_path, "More stuff in rho.\n") svntest.main.run_svn(None, 'ci', '-m', 'log msg', rho_path) # Create a new file, 'zeta', and schedule it for addition. zeta_path = os.path.join(wc_dir, 'A', 'B', 'zeta') svntest.main.file_append(zeta_path, "This is the file 'zeta'.\n") svntest.main.run_svn(None, 'add', zeta_path) # Schedule another file, say, 'gamma', for replacement. gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma') svntest.main.run_svn(None, 'delete', gamma_path) svntest.main.file_append(gamma_path, "This is a new 'gamma' now.\n") svntest.main.run_svn(None, 'add', gamma_path) # Now update. "zeta at revision 0" should *not* be reported at all, # so it should remain scheduled for addition at revision 0. gamma # was scheduled for replacement, so it also should remain marked as # such, and maintain its revision of 1. # Create expected output tree for an update of the wc_backup. expected_output = svntest.wc.State(wc_dir, { }) # Create expected disk tree for the update. expected_disk = svntest.main.greek_state.copy() expected_disk.add({ 'A/B/zeta' : Item("This is the file 'zeta'.\n"), }) expected_disk.tweak('A/D/gamma', contents="This is a new 'gamma' now.\n") expected_disk.tweak('A/D/G/rho', contents="This is the file 'rho'.\nMore stuff in rho.\n") # Create expected status tree for the update. expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak('A/D/gamma', wc_rev=1, status='R ') expected_status.add({ 'A/B/zeta' : Item(status='A ', wc_rev=0), }) # Do the update and check the results in three ways. svntest.actions.run_and_verify_update(wc_dir, expected_output, expected_disk, expected_status) #----------------------------------------------------------------------def update_to_rev_zero(sbox): "update to revision 0" sbox.build() wc_dir = sbox.wc_dir iota_path = os.path.join(wc_dir, 'iota') A_path = os.path.join(wc_dir, 'A') # 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)#----------------------------------------------------------------------def receive_overlapping_same_change(sbox): "overlapping identical changes should not conflict" ### (See http://subversion.tigris.org/issues/show_bug.cgi?id=682.) ### ### How this test works: ### ### Create working copy foo, modify foo/iota. Duplicate foo, ### complete with locally modified iota, to bar. Now we should ### have: ### ### $ svn st foo ### M foo/iota ### $ svn st bar ### M bar/iota ### $ ### ### Commit the change from foo, then update bar. The repository ### change should get folded into bar/iota with no conflict, since ### the two modifications are identical. sbox.build() wc_dir = sbox.wc_dir # Modify iota. iota_path = os.path.join(wc_dir, 'iota') svntest.main.file_append(iota_path, "A change to iota.\n") # Duplicate locally modified wc, giving us the "other" wc. other_wc = sbox.add_wc_path('other') svntest.actions.duplicate_dir(wc_dir, other_wc) other_iota_path = os.path.join(other_wc, 'iota') # Created expected output tree for 'svn ci' expected_output = svntest.wc.State(wc_dir, { 'iota' : Item(verb='Sending'), }) # Create expected status tree expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.tweak('iota', wc_rev=2) # Commit the change, creating revision 2. svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) # Expected output tree for update of other_wc. expected_output = svntest.wc.State(other_wc, { 'iota' : Item(status='G '), }) # Expected disk tree for the update. expected_disk = svntest.main.greek_state.copy() expected_disk.tweak('iota', contents="This is the file 'iota'.\nA change to iota.\n") # Expected status tree for the update. expected_status = svntest.actions.get_virginal_state(other_wc, 2) # Do the update and check the results in three ways. svntest.actions.run_and_verify_update(other_wc, expected_output, expected_disk, expected_status)#----------------------------------------------------------------------# Helper for update_to_resolve_text_conflicts() test -- a singleton handler.def detect_conflict_files(node, extra_files): """NODE has been discovered an extra file on disk. Verify that it matches one of the regular expressions in the EXTRA_FILES list. If it matches, remove the match from the list. If it doesn't match, raise an exception.""" for pattern in extra_files: mo = re.match(pattern, node.name) if mo: extra_files.pop(extra_files.index(pattern)) # delete pattern from list break else: print "Found unexpected object:", node.name raise svntest.main.SVNTreeUnequaldef update_to_resolve_text_conflicts(sbox): "delete files and update to resolve text conflicts" 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 which will be committed mu_path = os.path.join(wc_dir, 'A', 'mu') rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho') svntest.main.file_append (mu_path, 'Original appended text for mu\n') svntest.main.file_append (rho_path, 'Original appended text for rho\n') svntest.main.run_svn (None, 'propset', 'Kubla', 'Khan', rho_path) # Make a couple of local mods to files which will be conflicted mu_path_backup = os.path.join(wc_backup, 'A', 'mu') rho_path_backup = os.path.join(wc_backup, 'A', 'D', 'G', 'rho') svntest.main.file_append (mu_path_backup, 'Conflicting appended text for mu\n') svntest.main.file_append (rho_path_backup, 'Conflicting appended text for rho\n') svntest.main.run_svn (None, 'propset', 'Kubla', 'Xanadu', rho_path_backup) # Created expected output tree for 'svn ci' expected_output = svntest.wc.State(wc_dir, { 'A/mu' : Item(verb='Sending'), 'A/D/G/rho' : Item(verb='Sending'), }) # Create expected status tree; all local revisions should be at 1, # but mu and rho should be at revision 2. expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.tweak('A/mu', wc_rev=2) expected_status.tweak('A/D/G/rho', wc_rev=2, status=' ') # Commit. svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) # Create expected output tree for an update of the wc_backup. expected_output = svntest.wc.State(wc_backup, { 'A/mu' : Item(status='C '), 'A/D/G/rho' : Item(status='CC'), }) # Create expected disk tree for the update. expected_disk = svntest.main.greek_state.copy() expected_disk.tweak('A/mu', contents= """This is the file 'mu'.<<<<<<< .mineConflicting appended text for mu=======Original appended text for mu>>>>>>> .r2""") expected_disk.tweak('A/D/G/rho', contents="""This is the file 'rho'.<<<<<<< .mineConflicting appended text for rho=======Original appended text for rho>>>>>>> .r2""") # Create expected status tree for the update. expected_status = svntest.actions.get_virginal_state(wc_backup, 2) expected_status.tweak('A/mu', status='C ') expected_status.tweak('A/D/G/rho', status='CC') # "Extra" files that we expect to result from the conflicts. # These are expressed as list of regexps. What a cool system! :-) extra_files = ['mu.*\.r1', 'mu.*\.r2', 'mu.*\.mine', 'rho.*\.r1', 'rho.*\.r2', 'rho.*\.mine', 'rho.*\.prej'] # Do the update and check the results in three ways. # All "extra" files are passed to detect_conflict_files(). svntest.actions.run_and_verify_update(wc_backup, expected_output, expected_disk, expected_status, None, detect_conflict_files, extra_files) # verify that the extra_files list is now empty. if len(extra_files) != 0: print "didn't get expected extra files" raise svntest.Failure # remove the conflicting files to clear text conflict but not props conflict os.remove(mu_path_backup) os.remove(rho_path_backup) # ### TODO: Can't get run_and_verify_update to work here :-( I get # the error "Unequal Types: one Node is a file, the other is a # directory". Use run_svn and then run_and_verify_status instead stdout_lines, stdout_lines = svntest.main.run_svn(None, 'up', wc_backup) if len (stdout_lines) > 0: print "update 2 failed" raise svntest.Failure # Create expected status tree expected_status = svntest.actions.get_virginal_state(wc_backup, 2) expected_status.tweak('A/D/G/rho', status=' C') svntest.actions.run_and_verify_status(wc_backup, expected_status)#----------------------------------------------------------------------def update_delete_modified_files(sbox): "update that deletes modified files" sbox.build() wc_dir = sbox.wc_dir # Delete a file alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha') svntest.actions.run_and_verify_svn("Deleting alpha failed", None, [], 'rm', alpha_path) # Delete a directory containing files G_path = os.path.join(wc_dir, 'A', 'D', 'G') svntest.actions.run_and_verify_svn("Deleting G failed", None, [], 'rm', G_path) # Commit svntest.actions.run_and_verify_svn("Committing deletes failed", None, [], 'ci', '-m', 'log msg', wc_dir) # ### Update before backdating to avoid obstructed update error for G svntest.actions.run_and_verify_svn("Updating after commit failed", None, [], 'up', wc_dir) # Backdate to restore deleted items svntest.actions.run_and_verify_svn("Backdating failed", None, [], 'up', '-r', '1', wc_dir) # Modify the file to be deleted, and a file in the directory to be deleted svntest.main.file_append(alpha_path, 'appended alpha text\n') pi_path = os.path.join(G_path, 'pi') svntest.main.file_append(pi_path, 'appended pi text\n') expected_status = svntest.actions.get_virginal_state(wc_dir, 1) expected_status.tweak('A/B/E/alpha', 'A/D/G/pi', status='M ') svntest.actions.run_and_verify_status(wc_dir, expected_status) # Now update to 'delete' modified files -- that is, remove them from # version control, but leave them on disk. It used to be we would # expect an 'obstructed update' error (see issue #1196), but # nowadays we expect success (see issue #1806). expected_output = svntest.wc.State(wc_dir, { 'A/B/E/alpha' : Item(status='D '), 'A/D/G' : Item(status='D '), }) expected_disk = svntest.main.greek_state.copy() expected_disk.tweak('A/B/E/alpha', contents=\ "This is the file 'alpha'.\nappended alpha text\n") expected_disk.tweak('A/D/G/pi', contents=\ "This is the file 'pi'.\nappended pi text\n") expected_disk.remove('A/D/G/rho') expected_disk.remove('A/D/G/tau') expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.remove('A/B/E/alpha') expected_status.remove('A/D/G') expected_status.remove('A/D/G/pi') expected_status.remove('A/D/G/rho') expected_status.remove('A/D/G/tau')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -