📄 merge_tests.py
字号:
) expected_status = wc.State(os.path.join(other_wc, 'A', 'D', 'G'), { '' : Item(wc_rev=1, status=' '), 'rho' : Item(wc_rev=2, status='G '), 'pi' : Item(wc_rev=1, status='G '), 'tau' : Item(wc_rev=1, status='C '), }) expected_status.tweak('pi', status='M ') expected_status.tweak('rho', status='M ') expected_status.tweak('tau', status='C ') svntest.actions.run_and_verify_merge( os.path.join(other_wc, 'A', 'D', 'G'), '2', '3', svntest.main.current_repo_url + '/A/D/G', expected_output, expected_disk, expected_status, expected_skip, None, merge_singleton_handler) #----------------------------------------------------------------------# Merge should copy-with-history when adding files or directoriesdef add_with_history(sbox): "merge and add new files/dirs with history" sbox.build() wc_dir = sbox.wc_dir C_path = os.path.join(wc_dir, 'A', 'C') F_path = os.path.join(wc_dir, 'A', 'B', 'F') F_url = svntest.main.current_repo_url + '/A/B/F' Q_path = os.path.join(F_path, 'Q') Q2_path = os.path.join(F_path, 'Q2') foo_path = os.path.join(F_path, 'foo') foo2_path = os.path.join(F_path, 'foo2') bar_path = os.path.join(F_path, 'Q', 'bar') bar2_path = os.path.join(F_path, 'Q', 'bar2') svntest.main.run_svn(None, 'mkdir', Q_path) svntest.main.run_svn(None, 'mkdir', Q2_path) svntest.main.file_append(foo_path, "foo") svntest.main.file_append(foo2_path, "foo2") svntest.main.file_append(bar_path, "bar") svntest.main.file_append(bar2_path, "bar2") svntest.main.run_svn(None, 'add', foo_path, foo2_path, bar_path, bar2_path) svntest.main.run_svn(None, 'propset', 'x', 'x', Q2_path) svntest.main.run_svn(None, 'propset', 'y', 'y', foo2_path) svntest.main.run_svn(None, 'propset', 'z', 'z', bar2_path) expected_output = wc.State(wc_dir, { 'A/B/F/Q' : Item(verb='Adding'), 'A/B/F/Q2' : Item(verb='Adding'), 'A/B/F/Q/bar' : Item(verb='Adding'), 'A/B/F/Q/bar2': Item(verb='Adding'), 'A/B/F/foo' : Item(verb='Adding'), 'A/B/F/foo2' : Item(verb='Adding'), }) expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.add({ 'A/B/F/Q' : Item(status=' ', wc_rev=2), 'A/B/F/Q2' : Item(status=' ', wc_rev=2), 'A/B/F/Q/bar' : Item(status=' ', wc_rev=2), 'A/B/F/Q/bar2': Item(status=' ', wc_rev=2), 'A/B/F/foo' : Item(status=' ', wc_rev=2), 'A/B/F/foo2' : Item(status=' ', wc_rev=2), }) svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) ### "The Merge Kluge" ### ### ***************************************************** ### *** *** ### *** Before erasing this comment, please check *** ### *** for references to "The Merge Kluge" *** ### *** elsewhere in this file. *** ### *** *** ### ***************************************************** ### ### The shortening of C_path and the chdir() below are a kluge to ### work around ### ### http://subversion.tigris.org/issues/show_bug.cgi?id=767#desc16 ### ### Note that the problem isn't simply that 'svn merge' sometimes ### puts temp files in cwd. That's bad enough, but even if svn ### were to choose /tmp or some other static place blessed by ### apr_get_temp_dir(), we'd still experience the error ### ### svn: Move failed ### svn: Can't move 'tmp.2' to '.../.svn/tmp/text-base/file1.svn-base': ### Invalid cross-device link ### ### when running the tests on a ramdisk. After all, there's no ### reason why apr_get_temp_dir() would return a path inside ### svn-test-work/, which is the mount point for the ramdisk. ### ### http://subversion.tigris.org/issues/show_bug.cgi?id=767#desc20 ### starts a discussion on how to solve this in Subversion itself. ### However, until that's settled, we still want to be able to run ### the tests in a ramdisk, hence this kluge. short_C_path = shorten_path_kludge(C_path) expected_output = wc.State(short_C_path, { 'Q' : Item(status='A '), 'Q2' : Item(status='A '), 'Q/bar' : Item(status='A '), 'Q/bar2' : Item(status='A '), 'foo' : Item(status='A '), 'foo2' : Item(status='A '), }) expected_disk = wc.State('', { 'Q' : Item(), 'Q2' : Item(props={'x' : 'x'}), 'Q/bar' : Item("bar"), 'Q/bar2' : Item("bar2", props={'z' : 'z'}), 'foo' : Item("foo"), 'foo2' : Item("foo2", props={'y' : 'y'}), }) expected_status = wc.State(short_C_path, { '' : Item(status=' ', wc_rev=1), 'Q' : Item(status='A ', wc_rev='-', copied='+'), 'Q2' : Item(status='A ', wc_rev='-', copied='+'), 'Q/bar' : Item(status='A ', wc_rev='-', copied='+'), 'Q/bar2' : Item(status='A ', wc_rev='-', copied='+'), 'foo' : Item(status='A ', wc_rev='-', copied='+'), 'foo2' : Item(status='A ', wc_rev='-', copied='+'), }) expected_skip = wc.State(short_C_path, { }) saved_cwd = os.getcwd() try: os.chdir(svntest.main.work_dir) svntest.actions.run_and_verify_merge(short_C_path, '1', '2', F_url, expected_output, expected_disk, expected_status, expected_skip, None, None, None, None, None, 1) # check props finally: os.chdir(saved_cwd) expected_output = svntest.wc.State(wc_dir, { 'A/C/Q' : Item(verb='Adding'), 'A/C/Q2' : Item(verb='Adding'), 'A/C/Q/bar' : Item(verb='Adding'), 'A/C/Q/bar2': Item(verb='Adding'), 'A/C/foo' : Item(verb='Adding'), 'A/C/foo2' : Item(verb='Adding'), }) expected_status = svntest.actions.get_virginal_state(wc_dir, 3) expected_status.tweak(wc_rev=1) expected_status.add({ 'A/B/F/Q' : Item(status=' ', wc_rev=2), 'A/B/F/Q2' : Item(status=' ', wc_rev=2), 'A/B/F/Q/bar' : Item(status=' ', wc_rev=2), 'A/B/F/Q/bar2': Item(status=' ', wc_rev=2), 'A/B/F/foo' : Item(status=' ', wc_rev=2), 'A/B/F/foo2' : Item(status=' ', wc_rev=2), 'A/C/Q' : Item(status=' ', wc_rev=3), 'A/C/Q2' : Item(status=' ', wc_rev=3), 'A/C/Q/bar' : Item(status=' ', wc_rev=3), 'A/C/Q/bar2' : Item(status=' ', wc_rev=3), 'A/C/foo' : Item(status=' ', wc_rev=3), 'A/C/foo2' : Item(status=' ', wc_rev=3), }) svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir)#----------------------------------------------------------------------def delete_file_and_dir(sbox): "merge that deletes items" sbox.build() wc_dir = sbox.wc_dir # Rev 2 copy B to B2 B_path = os.path.join(wc_dir, 'A', 'B') B2_path = os.path.join(wc_dir, 'A', 'B2') B_url = svntest.main.current_repo_url + '/A/B' svntest.actions.run_and_verify_svn(None, None, [], 'copy', B_path, B2_path) expected_output = wc.State(wc_dir, { 'A/B2' : Item(verb='Adding'), }) expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.add({ 'A/B2' : Item(status=' ', wc_rev=2), 'A/B2/E' : Item(status=' ', wc_rev=2), 'A/B2/E/alpha' : Item(status=' ', wc_rev=2), 'A/B2/E/beta' : Item(status=' ', wc_rev=2), 'A/B2/F' : Item(status=' ', wc_rev=2), 'A/B2/lambda' : Item(status=' ', wc_rev=2), }) svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) # Rev 3 delete E and lambda from B E_path = os.path.join(B_path, 'E') lambda_path = os.path.join(B_path, 'lambda') svntest.actions.run_and_verify_svn(None, None, [], 'delete', E_path, lambda_path) expected_output = wc.State(wc_dir, { 'A/B/E' : Item(verb='Deleting'), 'A/B/lambda' : Item(verb='Deleting'), }) expected_status.remove('A/B/E', 'A/B/E/alpha', 'A/B/E/beta', 'A/B/lambda') svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) # Local mods in B2 B2_E_path = os.path.join(B2_path, 'E') B2_lambda_path = os.path.join(B2_path, 'lambda') svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'foo', 'foo_val', B2_E_path, B2_lambda_path) expected_status.tweak( 'A/B2/E', 'A/B2/lambda', status=' M' ) svntest.actions.run_and_verify_status(wc_dir, expected_status) # Merge rev 3 into B2 # Local mods cause everything to be skipped without --force expected_output = wc.State(B2_path, { }) 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_status = wc.State(B2_path, { '' : Item(status=' '), 'E' : Item(status=' M'), 'E/alpha' : Item(status=' '), 'E/beta' : Item(status=' '), 'F' : Item(status=' '), 'lambda' : Item(status=' M'), }) expected_status.tweak(wc_rev=2) expected_skip = wc.State(B2_path, { 'lambda' : Item(), 'E' : Item(), }) svntest.actions.run_and_verify_merge(B2_path, '2', '3', B_url, expected_output, expected_disk, expected_status, expected_skip) expected_output = wc.State(B2_path, { 'E' : Item(status='D '), 'E/alpha' : Item(status='D '), 'E/beta' : Item(status='D '), 'lambda' : Item(status='D '), }) expected_disk.remove('E/alpha', 'E/beta', 'lambda') expected_status.tweak('E', 'E/alpha', 'E/beta', 'lambda', status='D ') expected_skip.remove('lambda', 'E') ### Full-to-dry-run automatic comparison disabled because a) dry-run ### doesn't descend into deleted directories, and b) the full merge ### notifies deleted directories twice. svntest.actions.run_and_verify_merge(B2_path, '2', '3', B_url, expected_output, expected_disk, expected_status, expected_skip, None, None, None, None, None, 0, 0, '--force')#----------------------------------------------------------------------# Issue 953def simple_property_merges(sbox): "some simple property merges" sbox.build() wc_dir = sbox.wc_dir # Add a property to a file and a directory alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha') beta_path = os.path.join(wc_dir, 'A', 'B', 'E', 'beta') E_path = os.path.join(wc_dir, 'A', 'B', 'E') svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'foo', 'foo_val', alpha_path) # A binary, non-UTF8 property value svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'foo', 'foo\201val', beta_path) svntest.actions.run_and_verify_svn(None, None, [], 'propset', 'foo', 'foo_val', E_path)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -