Index: subversion/tests/clients/cmdline/switch_tests.py =================================================================== --- subversion/tests/clients/cmdline/switch_tests.py (revision 17918) +++ subversion/tests/clients/cmdline/switch_tests.py (working copy) @@ -970,7 +970,66 @@ svntest.actions.run_and_verify_svn(None, '^URL: ' + other_A_url + '$', [], 'info', '-rHEAD', A_wc_dir) +#---------------------------------------------------------------------- +# Issue 2306. +def refresh_read_only_attribute(sbox): + "refresh the WC file system read-only attribute " + sbox.build() + wc_dir = sbox.wc_dir + # Create a branch. + url = svntest.main.current_repo_url + '/A' + branch_url = svntest.main.current_repo_url + '/A-branch' + svntest.actions.run_and_verify_svn(None, + ['\n', 'Committed revision 2.\n'], [], + 'cp', '-m', 'svn:needs-lock not set', + url, branch_url) + + # Set the svn:needs-lock property on a file from the "trunk". + A_path = os.path.join(wc_dir, 'A') + mu_path = os.path.join(A_path, 'mu') + svntest.actions.run_and_verify_svn(None, None, [], + 'ps', 'svn:needs-lock', '1', mu_path) + + # Commit the propset of svn:needs-lock. + expected_output = svntest.wc.State(wc_dir, { + 'A/mu' : Item(verb='Sending'), + }) + expected_status = svntest.actions.get_virginal_state(wc_dir, 3) + expected_status.tweak(wc_rev=1) + expected_status.tweak('A/mu', wc_rev=3) + svntest.actions.run_and_verify_commit(wc_dir, + expected_output, expected_status, + None, None, None, None, None, + mu_path) + + # The file on which svn:needs-lock was set is now expected to be read-only. + if os.access(mu_path, os.W_OK): + raise svntest.Failure("'%s' expected to be read-only after having had " + "its svn:needs-lock property set" % mu_path) + + # Switch to the branch with the WC state from before the propset of + # svn:needs-lock. + expected_output = svntest.wc.State(wc_dir, { + 'A/mu' : Item(status=' U'), + }) + expected_disk = svntest.main.greek_state.copy() + expected_status = svntest.actions.get_virginal_state(wc_dir, 3) + expected_status.tweak('', wc_rev=1) + expected_status.tweak('iota', wc_rev=1) + expected_status.tweak('A', switched='S') + svntest.actions.run_and_verify_switch(wc_dir, A_path, branch_url, + expected_output, + expected_disk, + expected_status) + + # The file with we set svn:needs-lock on should now be writable, but + # is still read-only! + if not os.access(mu_path, os.W_OK): + raise svntest.Failure("'%s' expected to be writable after being switched " + "to a branch on which its svn:needs-lock property " + "is not set" % mu_path) + # Check that switch can't change the repository root. def switch_change_repos_root(sbox): "switch shouldn't allow changing repos root" @@ -1022,6 +1081,7 @@ obstructed_switch, XFail(commit_mods_below_switch), relocate_beyond_repos_root, + refresh_read_only_attribute, switch_change_repos_root, ]