You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2012/08/24 19:02:43 UTC
svn commit: r1376993 - /subversion/trunk/subversion/libsvn_ra_serf/commit.c
Author: cmpilato
Date: Fri Aug 24 17:02:42 2012
New Revision: 1376993
URL: http://svn.apache.org/viewvc?rev=1376993&view=rev
Log:
Fix a portion of issue #3764 ("Replace + propset of locked file fails
over DAV"), specifically the part that involves explicitly replaced
files (as opposed to files re-added under replaced directories).
* subversion/libsvn_ra_serf/commit.c
(maybe_set_lock_token_header): New helper function.
(setup_proppatch_headers, setup_put_headers): Now use
maybe_set_lock_token_header() to handle the decision and effort of
adding the lock token If: precondition header to the request.
Modified:
subversion/trunk/subversion/libsvn_ra_serf/commit.c
Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1376993&r1=1376992&r2=1376993&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Fri Aug 24 17:02:42 2012
@@ -719,6 +719,44 @@ proppatch_walker(void *baton,
return SVN_NO_ERROR;
}
+/* Possible add the lock-token "If:" precondition header to HEADERS if
+ an examination of COMMIT_CTX and RELPATH indicates that this is the
+ right thing to do.
+
+ Generally speaking, if the client provided a lock token for
+ RELPATH, it's the right thing to do. There is a notable instance
+ where this is not the case, however. If the file at RELPATH was
+ explicitly deleted in this commit already, then mod_dav removed its
+ lock token when it fielded the DELETE request, so we don't want to
+ set the lock precondition again. (See
+ http://subversion.tigris.org/issues/show_bug.cgi?id=3674 for details.)
+*/
+static svn_error_t *
+maybe_set_lock_token_header(serf_bucket_t *headers,
+ commit_context_t *commit_ctx,
+ const char *relpath,
+ apr_pool_t *pool)
+{
+ const char *token;
+
+ if (! (relpath && commit->lock_tokens))
+ return SVN_NO_ERROR;
+
+ if (! apr_hash_get(commit->deleted_entries, relpath, APR_HASH_KEY_STRING))
+ {
+ token = apr_hash_get(commit->lock_tokens, relpath, APR_HASH_KEY_STRING);
+ if (token)
+ {
+ const char *token_header;
+
+ token_header = apr_pstrcat(pool, "(<", token, ">)", (char *)NULL);
+ serf_bucket_headers_set(headers, "If", token_header);
+ }
+ }
+
+ return SVN_NO_ERROR;
+}
+
static svn_error_t *
setup_proppatch_headers(serf_bucket_t *headers,
void *baton,
@@ -733,22 +771,8 @@ setup_proppatch_headers(serf_bucket_t *h
proppatch->base_revision));
}
- if (proppatch->relpath && proppatch->commit->lock_tokens)
- {
- const char *token;
-
- token = apr_hash_get(proppatch->commit->lock_tokens, proppatch->relpath,
- APR_HASH_KEY_STRING);
-
- if (token)
- {
- const char *token_header;
-
- token_header = apr_pstrcat(pool, "(<", token, ">)", (char *)NULL);
-
- serf_bucket_headers_set(headers, "If", token_header);
- }
- }
+ SVN_ERR(maybe_set_lock_token_header(headers, proppatch->commit,
+ proppatch->relpath, pool));
return SVN_NO_ERROR;
}
@@ -951,22 +975,8 @@ setup_put_headers(serf_bucket_t *headers
ctx->result_checksum);
}
- if (ctx->commit->lock_tokens)
- {
- const char *token;
-
- token = apr_hash_get(ctx->commit->lock_tokens, ctx->relpath,
- APR_HASH_KEY_STRING);
-
- if (token)
- {
- const char *token_header;
-
- token_header = apr_pstrcat(pool, "(<", token, ">)", (char *)NULL);
-
- serf_bucket_headers_set(headers, "If", token_header);
- }
- }
+ SVN_ERR(maybe_set_lock_token_header(headers, ctx->commit,
+ ctx->relpath, pool));
return APR_SUCCESS;
}