You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2013/06/01 00:46:46 UTC
svn commit: r1488425 - in /subversion/trunk/subversion:
libsvn_ra_serf/commit.c tests/cmdline/lock_tests.py
tests/cmdline/svntest/sandbox.py
Author: philip
Date: Fri May 31 22:46:46 2013
New Revision: 1488425
URL: http://svn.apache.org/r1488425
Log:
Fix issue 4369, poor serf error message for commit with stolen locks.
* subversion/libsvn_ra_serf/commit.c
(maybe_set_lock_token_header): Associate URI with lock token.
* subversion/tests/cmdline/lock_tests.py
(commit_stolen_lock): New regression test.
(test_list): Add new test.
* subversion/tests/cmdline/svntest/sandbox.py
(simple_lock): New.
Modified:
subversion/trunk/subversion/libsvn_ra_serf/commit.c
subversion/trunk/subversion/tests/cmdline/lock_tests.py
subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py
Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1488425&r1=1488424&r2=1488425&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Fri May 31 22:46:46 2013
@@ -804,8 +804,18 @@ maybe_set_lock_token_header(serf_bucket_
if (token)
{
const char *token_header;
+ const char *token_uri;
+ apr_uri_t uri = commit_ctx->session->session_url;
- token_header = apr_pstrcat(pool, "(<", token, ">)", (char *)NULL);
+ /* Supplying the optional URI affects apache response when
+ the lock is broken, see issue 4369. When present any URI
+ must be absolute (RFC 2518 9.4). */
+ uri.path = (char *)svn_path_url_add_component2(uri.path, relpath,
+ pool);
+ token_uri = apr_uri_unparse(pool, &uri, 0);
+
+ token_header = apr_pstrcat(pool, "<", token_uri, "> (<", token, ">)",
+ (char *)NULL);
serf_bucket_headers_set(headers, "If", token_header);
}
}
Modified: subversion/trunk/subversion/tests/cmdline/lock_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/lock_tests.py?rev=1488425&r1=1488424&r2=1488425&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/lock_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/lock_tests.py Fri May 31 22:46:46 2013
@@ -1815,6 +1815,31 @@ def lock_unlock_deleted(sbox):
expected_status.tweak('A/mu', writelocked=None)
svntest.actions.run_and_verify_status(wc_dir, expected_status)
+@Issue(4369)
+def commit_stolen_lock(sbox):
+ "commit with a stolen lock"
+
+ sbox.build()
+ wc_dir = sbox.wc_dir
+
+ sbox.simple_append('A/mu', 'zig-zag')
+ sbox.simple_lock('A/mu')
+
+ expected_output = '\'mu\' locked by user \'jrandom\'.'
+ svntest.actions.run_and_verify_svn(None, expected_output, [],
+ 'lock', '--force',
+ sbox.repo_url + '/A/mu')
+
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+ expected_status.tweak('A/mu', status='M ', writelocked='T')
+ err_re = "(.*E160037: Cannot verify lock on path '/A/mu')|" + \
+ "(.*E160038: '/.*/A/mu': no lock token available)"
+ svntest.actions.run_and_verify_commit(wc_dir,
+ [],
+ expected_status,
+ err_re,
+ wc_dir)
+
########################################################################
# Run the tests
@@ -1866,6 +1891,7 @@ test_list = [ None,
lock_multi_wc,
locks_stick_over_switch,
lock_unlock_deleted,
+ commit_stolen_lock,
]
if __name__ == '__main__':
Modified: subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py?rev=1488425&r1=1488424&r2=1488425&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py Fri May 31 22:46:46 2013
@@ -362,6 +362,13 @@ class Sandbox:
DEST is a relpath relative to the WC."""
open(self.ospath(dest), truncate and 'w' or 'a').write(contents)
+ def simple_lock(self, *targets):
+ """Lock TARGETS in the WC.
+ TARGETS are relpaths relative to the WC."""
+ assert len(targets) > 0
+ targets = self.ospaths(targets)
+ svntest.main.run_svn(False, 'lock', *targets)
+
def is_url(target):
return (target.startswith('^/')