📄 merge_tests.py
字号:
# Commit change as rev 2 expected_output = svntest.wc.State(wc_dir, { 'A/B/E' : Item(verb='Sending'), 'A/B/E/alpha' : Item(verb='Sending'), 'A/B/E/beta' : Item(verb='Sending'), }) expected_status = svntest.actions.get_virginal_state(wc_dir, 1) expected_status.tweak('A/B/E', 'A/B/E/alpha', 'A/B/E/beta', wc_rev=2, status=' ') 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) # Copy B to B2 as rev 3 B_url = svntest.main.current_repo_url + '/A/B' B2_url = svntest.main.current_repo_url + '/A/B2' svntest.actions.run_and_verify_svn(None, None, [], 'copy', '-m', 'fumble', '--username', svntest.main.wc_author, '--password', svntest.main.wc_passwd, B_url, B2_url) svntest.actions.run_and_verify_svn(None, None, [], 'up', wc_dir) # Modify a property and add a property for the file and directory svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'foo', 'mod_foo', alpha_path) svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'bar', 'bar_val', alpha_path) svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'foo', 'mod\201foo', beta_path) svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'bar', 'bar\201val', beta_path) svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'foo', 'mod_foo', E_path) svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'bar', 'bar_val', E_path) # Commit change as rev 4 expected_status = svntest.actions.get_virginal_state(wc_dir, 3) expected_status.tweak('A/B/E', 'A/B/E/alpha', 'A/B/E/beta', wc_rev=4, status=' ') expected_status.add({ 'A/B2' : Item(status=' ', wc_rev=3), 'A/B2/E' : Item(status=' ', wc_rev=3), 'A/B2/E/alpha' : Item(status=' ', wc_rev=3), 'A/B2/E/beta' : Item(status=' ', wc_rev=3), 'A/B2/F' : Item(status=' ', wc_rev=3), 'A/B2/lambda' : Item(status=' ', wc_rev=3), }) 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) pristine_status = expected_status pristine_status.tweak(wc_rev=4) # Merge B 3:4 into B2 B2_path = os.path.join(wc_dir, 'A', 'B2') expected_output = wc.State(B2_path, { 'E' : Item(status=' U'), 'E/alpha' : Item(status=' U'), 'E/beta' : Item(status=' U'), }) expected_disk = wc.State('', { 'E' : Item(), 'E/alpha' : Item("This is the file 'alpha'.\n"), 'E/beta' : Item("This is the file 'beta'.\n"), 'F' : Item(), 'lambda' : Item("This is the file 'lambda'.\n"), }) expected_disk.tweak('E', 'E/alpha', props={'foo' : 'mod_foo', 'bar' : 'bar_val'}) expected_disk.tweak('E/beta', props={'foo' : 'mod\201foo', 'bar' : 'bar\201val'}) expected_status = wc.State(B2_path, { '' : Item(status=' '), 'E' : Item(status=' M'), 'E/alpha' : Item(status=' M'), 'E/beta' : Item(status=' M'), 'F' : Item(status=' '), 'lambda' : Item(status=' '), }) expected_status.tweak(wc_rev=4) expected_skip = wc.State('', { }) svntest.actions.run_and_verify_merge(B2_path, '3', '4', B_url, expected_output, expected_disk, expected_status, expected_skip, None, None, None, None, None, 1) # Revert merge svntest.actions.run_and_verify_svn(None, None, [], 'revert', '--recursive', wc_dir) svntest.actions.run_and_verify_status(wc_dir, pristine_status) # Merge B 2:1 into B2 expected_disk.tweak('E', 'E/alpha', 'E/beta', props={}) svntest.actions.run_and_verify_merge(B2_path, '2', '1', B_url, expected_output, expected_disk, expected_status, expected_skip, None, None, None, None, None, 1) # Merge B 3:4 into B2 now causes a conflict expected_disk.add({ 'E/dir_conflicts.prej' : Item("Trying to change property 'foo' from 'foo_val' to 'mod_foo',\n" + "but the property does not exist."), 'E/alpha.prej' : Item("Trying to change property 'foo' from 'foo_val' to 'mod_foo',\n" + "but the property does not exist."), 'E/beta.prej' : Item("Trying to change property 'foo' from 'foo?\\129val' to" + " 'mod?\\129foo',\n" + "but the property does not exist."), }) expected_disk.tweak('E', 'E/alpha', props={'bar' : 'bar_val'}) expected_disk.tweak('E/beta', props={'bar' : 'bar\201val'}) expected_status.tweak('E', 'E/alpha', 'E/beta', status=' C') svntest.actions.run_and_verify_merge(B2_path, '3', '4', B_url, expected_output, expected_disk, expected_status, expected_skip, None, None, None, None, None, 1) # issue 1109 : single file property merge. This test performs a merge # that should be a no-op (adding properties that are already present). svntest.actions.run_and_verify_svn(None, None, [], 'revert', '--recursive', wc_dir) svntest.actions.run_and_verify_status(wc_dir, pristine_status) A_url = svntest.main.current_repo_url + '/A' A2_url = svntest.main.current_repo_url + '/A2' # Copy to make revision 5 svntest.actions.run_and_verify_svn(None, ['\n', 'Committed revision 5.\n'], [], 'copy', '-m', 'fumble', '--username', svntest.main.wc_author, '--password', svntest.main.wc_passwd, A_url, A2_url) svntest.actions.run_and_verify_svn(None, None, [], 'switch', A2_url, wc_dir) alpha_url = svntest.main.current_repo_url + '/A/B/E/alpha' alpha_path = os.path.join(wc_dir, 'B', 'E', 'alpha') # Cannot use run_and_verify_merge with a file target svntest.actions.run_and_verify_svn(None, [' G ' + alpha_path + '\n'], [], 'merge', '-r', '3:4', alpha_url, alpha_path) output, err = svntest.actions.run_and_verify_svn(None, None, [], 'pl', alpha_path) saw_foo = 0 saw_bar = 0 for line in output: if re.match("\\s*foo\\s*$", line): saw_foo = 1 if re.match("\\s*bar\\s*$", line): saw_bar = 1 if not saw_foo or not saw_bar: raise svntest.Failure #----------------------------------------------------------------------# This is a regression for issue #1176.def merge_catches_nonexistent_target(sbox): "merge should not die if a target file is absent" sbox.build() wc_dir = sbox.wc_dir # Copy G to a new directory, Q. Create Q/newfile. Commit a change # to Q/newfile. Now merge that change... into G. Merge should not # error, but should do nothing. G_path = os.path.join(wc_dir, 'A', 'D', 'G') Q_path = os.path.join(wc_dir, 'A', 'D', 'Q') newfile_path = os.path.join(Q_path, 'newfile') Q_url = svntest.main.current_repo_url + '/A/D/Q' svntest.actions.run_and_verify_svn(None, None, [], 'cp', G_path, Q_path) svntest.main.file_append(newfile_path, 'This is newfile.\n') svntest.actions.run_and_verify_svn(None, None, [], 'add', newfile_path) expected_output = wc.State(wc_dir, { 'A/D/Q' : Item(verb='Adding'), 'A/D/Q/newfile' : Item(verb='Adding'), }) expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.add({ 'A/D/Q' : Item(status=' ', wc_rev=2), 'A/D/Q/pi' : Item(status=' ', wc_rev=2), 'A/D/Q/rho' : Item(status=' ', wc_rev=2), 'A/D/Q/tau' : Item(status=' ', wc_rev=2), 'A/D/Q/newfile' : Item(status=' ', wc_rev=2), }) svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) svntest.main.file_append(newfile_path, 'A change to newfile.\n') expected_output = wc.State(wc_dir, { 'A/D/Q/newfile' : Item(verb='Sending'), }) expected_status.tweak('A/D/Q/newfile', wc_rev=3) svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) saved_cwd = os.getcwd() try: os.chdir(G_path) expected_output = wc.State('', { }) expected_status = wc.State('', { '' : Item(), 'pi' : Item(), 'rho' : Item(), 'tau' : Item(), }) expected_status.tweak(status=' ', wc_rev=1) expected_disk = wc.State('', { 'pi' : Item("This is the file 'pi'.\n"), 'rho' : Item("This is the file 'rho'.\n"), 'tau' : Item("This is the file 'tau'.\n"), }) expected_skip = wc.State('', { 'newfile' :Item(), }) svntest.actions.run_and_verify_merge('', '2', '3', Q_url, expected_output, expected_disk, expected_status, expected_skip) finally: os.chdir(saved_cwd)#----------------------------------------------------------------------def merge_tree_deleted_in_target(sbox): "merge on deleted directory in target" sbox.build() wc_dir = sbox.wc_dir # Copy B to a new directory, I. Modify B/E/alpha, Remove I/E. Now # merge that change... into I. Merge should not error B_path = os.path.join(wc_dir, 'A', 'B') I_path = os.path.join(wc_dir, 'A', 'I') alpha_path = os.path.join(B_path, 'E', 'alpha') B_url = svntest.main.current_repo_url + '/A/B' I_url = svntest.main.current_repo_url + '/A/I' svntest.actions.run_and_verify_svn(None, None, [], 'cp', B_url, I_url, '-m', 'rev 2') svntest.main.file_append(alpha_path, 'A change to alpha.\n') svntest.main.file_append(os.path.join(B_path, 'lambda'), 'change lambda.\n') svntest.actions.run_and_verify_svn(None, None, [], 'ci', '-m', 'rev 3', B_path) E_url = svntest.main.current_repo_url + '/A/I/E' svntest.actions.run_and_verify_svn(None, None, [], 'rm', E_url, '-m', 'rev 4') svntest.actions.run_and_verify_svn(None, None, [], 'up', os.path.join(wc_dir,'A')) expected_output = wc.State(I_path, { 'lambda' : Item(status='U '), }) expected_disk = wc.State('', { 'F' : Item(), 'lambda' : Item("This is the file 'lambda'.\nchange lambda.\n"), }) expected_status = wc.State(I_path, { '' : Item(status=' '), 'F' : Item(status=' '), 'lambda' : Item(status='M '), }) expected_status.tweak(wc_rev=4) expected_skip = wc.State(I_path, { 'E' : Item(), 'E/alpha' : Item(), }) svntest.actions.run_and_verify_merge(I_path, '2', '3', B_url, expected_output, expected_disk, expected_status, expected_skip, None, None, None, None, None, 0, 0)#----------------------------------------------------------------------# Issue #2515def merge_added_dir_to_deleted_in_target(sbox): "merge an added dir on a deleted dir in target" sbox.build() wc_dir = sbox.wc_dir # copy B to a new directory, I. # delete F in I. # add J to B/F. # merge add to I. B_url = svntest.main.current_repo_url + '/A/B' I_url = svntest.main.current_repo_url + '/A/I' F_url = svntest.main.current_repo_url + '/A/I/F' J_url = svntest.main.current_repo_url + '/A/B/F/J' I_path = os.path.join(wc_dir, 'A', 'I')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -