subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmpil...@apache.org
Subject svn commit: r1391638 - in /subversion/trunk/subversion: include/ libsvn_ra_local/ libsvn_ra_serf/ libsvn_repos/ mod_dav_svn/ tests/cmdline/
Date Fri, 28 Sep 2012 20:26:12 GMT
Author: cmpilato
Date: Fri Sep 28 20:26:11 2012
New Revision: 1391638

URL: http://svn.apache.org/viewvc?rev=1391638&view=rev
Log:
For issue #4124 ("Give servers sufficient means to disallow commits
from clients based on version numbers"):

Add a server capability (with ra_dav and ra_local support only at this
time) for "ephemeral transaction properties" -- that is, properties
which may be set on a commit transaction but which are removed from it
just prior to the transaction's promotion to a revision.

While here, also add a client usage of this new capability:  to report
the user-agent string and client compatibility version to the
repository (so hooks can examine this information).

* subversion/include/svn_props.h
  (SVN_PROP_TXN_PREFIX): New property namespace prefix.
  (SVN_PROP_TXN_CLIENT_COMPAT_VERSION, SVN_PROP_TXN_USER_AGENT): New
    reserved property names.

* subversion/include/svn_dav.h
  (SVN_DAV_NS_DAV_SVN_EPHEMERAL_TXNPROPS): New magic header value.

* subversion/mod_dav_svn/version.c
  (get_vsn_options): Advertise support for ephemeral txnprops.

* subversion/include/svn_ra.h
  (SVN_RA_CAPABILITY_EPHEMERAL_TXNPROPS): New capability.

* subversion/libsvn_ra_serf/options.c
  (capabilities_headers_iterator_callback): Record support for
    ephemeral properties when the server advertises as much.
  (options_response_handler): Add default value for ephemeral
    properties capability support.

* subversion/libsvn_ra_serf/commit.c
  (svn_ra_serf__get_commit_editor): If the server supports them, add
    an ephemeral txnprop with the client compatability version string.

* subversion/libsvn_ra_local/ra_plugin.c
  (svn_ra_local__get_commit_editor): Set the
    SVN_PROP_TXN_CLIENT_COMPAT_VERSION ephemeral property.

* subversion/libsvn_repos/fs-wrap.c
  (svn_repos_fs_commit_txn): Remove ephemeral properties before
    committing.

* subversion/tests/cmdline/svnlook_tests.py
  (test_txn_flags): Update test expectations.

Modified:
    subversion/trunk/subversion/include/svn_dav.h
    subversion/trunk/subversion/include/svn_props.h
    subversion/trunk/subversion/include/svn_ra.h
    subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c
    subversion/trunk/subversion/libsvn_ra_serf/commit.c
    subversion/trunk/subversion/libsvn_ra_serf/options.c
    subversion/trunk/subversion/libsvn_repos/fs-wrap.c
    subversion/trunk/subversion/mod_dav_svn/version.c
    subversion/trunk/subversion/tests/cmdline/svnlook_tests.py

Modified: subversion/trunk/subversion/include/svn_dav.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_dav.h?rev=1391638&r1=1391637&r2=1391638&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_dav.h (original)
+++ subversion/trunk/subversion/include/svn_dav.h Fri Sep 28 20:26:11 2012
@@ -299,6 +299,13 @@ extern "C" {
 #define SVN_DAV_NS_DAV_SVN_PARTIAL_REPLAY\
             SVN_DAV_PROP_NS_DAV "svn/partial-replay"
 
+/** Presence of this in a DAV header in an OPTIONS response indicates
+ * that the transmitter (in this case, the server) knows how to
+ * properly handle ephemeral (that is, deleted-just-before-commit) FS
+ * transaction properties. */
+#define SVN_DAV_NS_DAV_SVN_EPHEMERAL_TXNPROPS\
+            SVN_DAV_PROP_NS_DAV "svn/ephemeral-txnprops"
+  
 /** @} */
 
 /** @} */

Modified: subversion/trunk/subversion/include/svn_props.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_props.h?rev=1391638&r1=1391637&r2=1391638&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_props.h (original)
+++ subversion/trunk/subversion/include/svn_props.h Fri Sep 28 20:26:11 2012
@@ -540,6 +540,33 @@ svn_prop_name_is_valid(const char *prop_
 
 /** @} */
 
+/**
+ * These are reserved properties attached to a "transaction" object in
+ * the repository filesystem in advance of the pre-commit hook script
+ * running on the server, but then automatically removed from the
+ * transaction before its promotion to a new revision.
+ *
+ * @defgroup svn_props_ephemeral_txnprops Ephemeral transaction properties
+ * @{
+ */
+
+/** The prefix used for all (ephemeral) transaction properties. */
+#define SVN_PROP_TXN_PREFIX  SVN_PROP_PREFIX "txn-"
+
+/** Identifies the client version compability level.  For clients
+ * compiled against Subversion libraries, this is @c SVN_VER_NUMBER.
+ * Third-party implementations are advised to use similar formatting
+ * for values of this property.
+ */
+#define SVN_PROP_TXN_CLIENT_COMPAT_VERSION \
+            SVN_PROP_TXN_PREFIX "client-compat-version"
+    
+/** Identifies the client's user agent string, if any. */
+#define SVN_PROP_TXN_USER_AGENT \
+            SVN_PROP_TXN_PREFIX "user-agent"
+
+/** @} */
+
 /** @} */
 
 

Modified: subversion/trunk/subversion/include/svn_ra.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_ra.h?rev=1391638&r1=1391637&r2=1391638&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_ra.h (original)
+++ subversion/trunk/subversion/include/svn_ra.h Fri Sep 28 20:26:11 2012
@@ -1993,6 +1993,15 @@ svn_ra_has_capability(svn_ra_session_t *
  */
 #define SVN_RA_CAPABILITY_ATOMIC_REVPROPS "atomic-revprops"
 
+/**
+ * The capability of a server to automatically remove transaction
+ * properties prefixed with SVN_PROP_EPHEMERAL_PREFIX.
+ *
+ * @since New in 1.8.
+ */
+#define SVN_RA_CAPABILITY_EPHEMERAL_TXNPROPS "ephemeral-txnprops"
+
+
 /*       *** PLEASE READ THIS IF YOU ADD A NEW CAPABILITY ***
  *
  * RA layers generally fetch all capabilities when asked about any

Modified: subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c?rev=1391638&r1=1391637&r2=1391638&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c (original)
+++ subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c Fri Sep 28 20:26:11 2012
@@ -752,6 +752,8 @@ svn_ra_local__get_commit_editor(svn_ra_s
   revprop_table = apr_hash_copy(pool, revprop_table);
   apr_hash_set(revprop_table, SVN_PROP_REVISION_AUTHOR, APR_HASH_KEY_STRING,
                svn_string_create(sess->username, pool));
+  apr_hash_set(revprop_table, SVN_PROP_TXN_CLIENT_COMPAT_VERSION,
+               APR_HASH_KEY_STRING, svn_string_create(SVN_VER_NUMBER, pool));
 
   /* Get the repos commit-editor */
   return svn_repos_get_commit_editor5

Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1391638&r1=1391637&r2=1391638&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Fri Sep 28 20:26:11 2012
@@ -2269,6 +2269,7 @@ svn_ra_serf__get_commit_editor(svn_ra_se
   apr_hash_index_t *hi;
   const char *repos_root;
   const char *base_relpath;
+  svn_boolean_t supports_ephemeral_props;
 
   ctx = apr_pcalloc(pool, sizeof(*ctx));
 
@@ -2289,6 +2290,23 @@ svn_ra_serf__get_commit_editor(svn_ra_se
                    svn_string_dup(val, pool));
     }
 
+  /* If the server supports ephemeral properties, add some carrying
+     interesting version information. */
+  SVN_ERR(svn_ra_serf__has_capability(ra_session, &supports_ephemeral_props,
+                                      SVN_RA_CAPABILITY_EPHEMERAL_TXNPROPS,
+                                      pool));
+  if (supports_ephemeral_props)
+    {
+      apr_hash_set(ctx->revprop_table,
+                   apr_pstrdup(pool, SVN_PROP_TXN_CLIENT_COMPAT_VERSION),
+                   APR_HASH_KEY_STRING,
+                   svn_string_create(SVN_VER_NUMBER, pool));
+      apr_hash_set(ctx->revprop_table,
+                   apr_pstrdup(pool, SVN_PROP_TXN_USER_AGENT),
+                   APR_HASH_KEY_STRING,
+                   svn_string_create(session->useragent, pool));
+    }
+
   ctx->callback = callback;
   ctx->callback_baton = callback_baton;
 

Modified: subversion/trunk/subversion/libsvn_ra_serf/options.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/options.c?rev=1391638&r1=1391637&r2=1391638&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/options.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/options.c Fri Sep 28 20:26:11 2012
@@ -199,6 +199,12 @@ capabilities_headers_iterator_callback(v
                        SVN_RA_CAPABILITY_PARTIAL_REPLAY, APR_HASH_KEY_STRING,
                        capability_yes);
         }
+      if (svn_cstring_match_list(SVN_DAV_NS_DAV_SVN_EPHEMERAL_TXNPROPS, vals))
+        {
+          apr_hash_set(session->capabilities,
+                       SVN_RA_CAPABILITY_EPHEMERAL_TXNPROPS, APR_HASH_KEY_STRING,
+                       capability_yes);
+        }
     }
 
   /* SVN-specific headers -- if present, server supports HTTP protocol v2 */
@@ -317,6 +323,8 @@ options_response_handler(serf_request_t 
                    APR_HASH_KEY_STRING, capability_no);
       apr_hash_set(session->capabilities, SVN_RA_CAPABILITY_ATOMIC_REVPROPS,
                    APR_HASH_KEY_STRING, capability_no);
+      apr_hash_set(session->capabilities, SVN_RA_CAPABILITY_EPHEMERAL_TXNPROPS,
+                   APR_HASH_KEY_STRING, capability_no);
 
       /* Then see which ones we can discover. */
       serf_bucket_headers_do(hdrs, capabilities_headers_iterator_callback,
@@ -325,7 +333,7 @@ options_response_handler(serf_request_t 
       opt_ctx->headers_processed = TRUE;
     }
 
-  /* Execute the 'real' response handler to XML-parse the repsonse body. */
+  /* Execute the 'real' response handler to XML-parse the response body. */
   return opt_ctx->inner_handler(request, response, opt_ctx->inner_baton, pool);
 }
 

Modified: subversion/trunk/subversion/libsvn_repos/fs-wrap.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/fs-wrap.c?rev=1391638&r1=1391637&r2=1391638&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/fs-wrap.c (original)
+++ subversion/trunk/subversion/libsvn_repos/fs-wrap.c Fri Sep 28 20:26:11 2012
@@ -48,6 +48,9 @@ svn_repos_fs_commit_txn(const char **con
 {
   svn_error_t *err, *err2;
   const char *txn_name;
+  apr_hash_t *props;
+  apr_pool_t *iterpool;
+  apr_hash_index_t *hi;
 
   *new_rev = SVN_INVALID_REVNUM;
 
@@ -55,6 +58,24 @@ svn_repos_fs_commit_txn(const char **con
   SVN_ERR(svn_fs_txn_name(&txn_name, txn, pool));
   SVN_ERR(svn_repos__hooks_pre_commit(repos, txn_name, pool));
 
+  /* Remove any ephemeral transaction properties. */
+  SVN_ERR(svn_fs_txn_proplist(&props, txn, pool));
+  iterpool = svn_pool_create(pool);
+  for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi))
+    {
+      const void *key;
+      apr_hash_this(hi, &key, NULL, NULL);
+
+      svn_pool_clear(iterpool);
+
+      if (strncmp(key, SVN_PROP_TXN_PREFIX,
+                  (sizeof(SVN_PROP_TXN_PREFIX) - 1)) == 0)
+        {
+          SVN_ERR(svn_fs_change_txn_prop(txn, key, NULL, iterpool));
+        }
+    }
+  svn_pool_destroy(iterpool);
+  
   /* Commit. */
   err = svn_fs_commit_txn(conflict_p, new_rev, txn, pool);
   if (! SVN_IS_VALID_REVNUM(*new_rev))

Modified: subversion/trunk/subversion/mod_dav_svn/version.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/version.c?rev=1391638&r1=1391637&r2=1391638&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/version.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/version.c Fri Sep 28 20:26:11 2012
@@ -146,6 +146,7 @@ get_vsn_options(apr_pool_t *p, apr_text_
   apr_text_append(p, phdr, SVN_DAV_NS_DAV_SVN_LOG_REVPROPS);
   apr_text_append(p, phdr, SVN_DAV_NS_DAV_SVN_ATOMIC_REVPROPS);
   apr_text_append(p, phdr, SVN_DAV_NS_DAV_SVN_PARTIAL_REPLAY);
+  apr_text_append(p, phdr, SVN_DAV_NS_DAV_SVN_EPHEMERAL_TXNPROPS);
   /* Mergeinfo is a special case: here we merely say that the server
    * knows how to handle mergeinfo -- whether the repository does too
    * is a separate matter.

Modified: subversion/trunk/subversion/tests/cmdline/svnlook_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnlook_tests.py?rev=1391638&r1=1391637&r2=1391638&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnlook_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnlook_tests.py Fri Sep 28 20:26:11 2012
@@ -698,9 +698,17 @@ fp.close()"""
                     'bogus_rev_val\n',
                     '  bogus_prop\n',
                     '  svn:log\n', '  svn:author\n',
-                    #  internal property, not really expected
-                    '  svn:check-locks\n',
-                    '  bogus_rev_prop\n', '  svn:date\n']
+                    '  svn:check-locks\n', # internal prop, not really expected
+                    '  bogus_rev_prop\n',
+                    '  svn:date\n',
+                    ]
+  # ra_dav and ra_local add the client-compat-version ephemeral property.
+  # FIXME: ra_svn will soon, too.  cmpilato just hasn't gotten there yet.
+  if svntest.main.is_ra_type_dav() or svntest.main.is_ra_type_file():
+    expected_data.append('  svn:txn-client-compat-version\n')
+  # ra_dav adds the user-agent ephemeral property
+  if svntest.main.is_ra_type_dav():
+    expected_data.append('  svn:txn-user-agent\n')
   verify_logfile(logfilepath, svntest.verify.UnorderedOutput(expected_data))
 
 def property_delete(sbox):



Mime
View raw message