Author: neels
Date: Thu Aug 18 14:24:12 2011
New Revision: 1159240

URL: http://svn.apache.org/viewvc?rev=1159240&view=rev
Log:
On 'hold' branch: Block commits for files that have the 'svn:hold' prop.

* subversion/include/svn_props.h
  (SVN_PROP_HOLD): New #define.

* subversion/libsvn_client/commit_util.c
  (harvest_committables):
    Check for 'svn:hold' prop and exclude files from committables if found.

* subversion/include/private/svn_wc_private.h
  (svn_wc__node_get_commit_status),
* subversion/libsvn_wc/node.c
  (svn_wc__node_get_commit_status): 
    Also return parameter HAD_PROPS for slight optimization in
    harvest_committables().

Modified:
    subversion/branches/hold/subversion/include/private/svn_wc_private.h
    subversion/branches/hold/subversion/include/svn_props.h
    subversion/branches/hold/subversion/libsvn_client/commit_util.c
    subversion/branches/hold/subversion/libsvn_wc/node.c

Modified: subversion/branches/hold/subversion/include/private/svn_wc_private.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/hold/subversion/include/private/svn_wc_private.h?rev=1159240&r1=1159239&r2=1159240&view=diff
==============================================================================
--- subversion/branches/hold/subversion/include/private/svn_wc_private.h 
(original)
+++ subversion/branches/hold/subversion/include/private/svn_wc_private.h Thu 
Aug 18 14:24:12 2011
@@ -953,6 +953,7 @@ svn_wc__node_get_commit_status(svn_node_
                                const char **original_repos_relpath,
                                svn_boolean_t *conflicted,
                                const char **changelist,
+                               svn_boolean_t *had_props,
                                svn_boolean_t *props_mod,
                                svn_boolean_t *update_root,
                                const char **lock_token,

Modified: subversion/branches/hold/subversion/include/svn_props.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/hold/subversion/include/svn_props.h?rev=1159240&r1=1159239&r2=1159240&view=diff
==============================================================================
--- subversion/branches/hold/subversion/include/svn_props.h (original)
+++ subversion/branches/hold/subversion/include/svn_props.h Thu Aug 18 14:24:12 
2011
@@ -321,6 +321,9 @@ svn_prop_name_is_valid(const char *prop_
 /** Set if the file should be treated as a special file. */
 #define SVN_PROP_SPECIAL  SVN_PROP_PREFIX "special"
 
+/** Set if the file should be held back from a commit. */
+#define SVN_PROP_HOLD  SVN_PROP_PREFIX "hold"
+
 /** The value to force the special property to when set.
  *
  * @deprecated Provided for backward compatibility with the 1.4 API.

Modified: subversion/branches/hold/subversion/libsvn_client/commit_util.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/hold/subversion/libsvn_client/commit_util.c?rev=1159240&r1=1159239&r2=1159240&view=diff
==============================================================================
--- subversion/branches/hold/subversion/libsvn_client/commit_util.c (original)
+++ subversion/branches/hold/subversion/libsvn_client/commit_util.c Thu Aug 18 
14:24:12 2011
@@ -438,6 +438,7 @@ harvest_committables(svn_wc_context_t *w
                      apr_pool_t *scratch_pool)
 {
   svn_boolean_t text_mod = FALSE;
+  svn_boolean_t had_props = FALSE;
   svn_boolean_t prop_mod = FALSE;
   apr_byte_t state_flags = 0;
   svn_node_kind_t working_kind;
@@ -488,7 +489,8 @@ harvest_committables(svn_wc_context_t *w
                                          &original_rev, &original_relpath,
                                          &conflicted,
                                          &node_changelist,
-                                         &prop_mod, &is_update_root,
+                                         &had_props, &prop_mod,
+                                         &is_update_root,
                                          &node_lock_token,
                                          wc_ctx, local_abspath,
                                          scratch_pool, scratch_pool));
@@ -742,27 +744,46 @@ harvest_committables(svn_wc_context_t *w
     {
       if (matches_changelists)
         {
-          /* Finally, add the committable item. */
-          SVN_ERR(add_committable(committables, local_abspath, db_kind,
-                                  repos_root_url,
-                                  copy_mode
-                                      ? commit_relpath
-                                      : node_relpath,
-                                  copy_mode
-                                      ? SVN_INVALID_REVNUM
-                                      : node_rev,
-                                  cf_relpath,
-                                  cf_rev,
-                                  state_flags,
-                                  result_pool, scratch_pool));
-          if (state_flags & SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN)
-            apr_hash_set(lock_tokens,
-                         svn_path_url_add_component2(
-                             repos_root_url, node_relpath,
-                             apr_hash_pool_get(lock_tokens)),
-                         APR_HASH_KEY_STRING,
-                         apr_pstrdup(apr_hash_pool_get(lock_tokens),
-                                     node_lock_token));
+          svn_boolean_t held = FALSE;
+
+          if (db_kind != svn_node_dir
+              && (had_props || prop_mod))
+            {
+              /* Is the svn:hold property set on this file?
+               * (Determine this only for items that are committable to avoid
+               * reading in props for all files in the WC.) */
+
+              const svn_string_t *propval;
+              SVN_ERR(svn_wc_prop_get2(&propval, wc_ctx, local_abspath,
+                                       SVN_PROP_HOLD,
+                                       scratch_pool, scratch_pool));
+              held = (propval != NULL);
+            }
+
+          if (!held)
+            {
+              /* Finally, add the committable item. */
+              SVN_ERR(add_committable(committables, local_abspath, db_kind,
+                                      repos_root_url,
+                                      copy_mode
+                                          ? commit_relpath
+                                          : node_relpath,
+                                      copy_mode
+                                          ? SVN_INVALID_REVNUM
+                                          : node_rev,
+                                      cf_relpath,
+                                      cf_rev,
+                                      state_flags,
+                                      result_pool, scratch_pool));
+              if (state_flags & SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN)
+                apr_hash_set(lock_tokens,
+                             svn_path_url_add_component2(
+                                 repos_root_url, node_relpath,
+                                 apr_hash_pool_get(lock_tokens)),
+                             APR_HASH_KEY_STRING,
+                             apr_pstrdup(apr_hash_pool_get(lock_tokens),
+                                         node_lock_token));
+            }
         }
     }
 

Modified: subversion/branches/hold/subversion/libsvn_wc/node.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/hold/subversion/libsvn_wc/node.c?rev=1159240&r1=1159239&r2=1159240&view=diff
==============================================================================
--- subversion/branches/hold/subversion/libsvn_wc/node.c (original)
+++ subversion/branches/hold/subversion/libsvn_wc/node.c Thu Aug 18 14:24:12 
2011
@@ -1484,6 +1484,7 @@ svn_wc__node_get_commit_status(svn_node_
                                const char **original_repos_relpath,
                                svn_boolean_t *conflicted,
                                const char **changelist,
+                               svn_boolean_t *had_props,
                                svn_boolean_t *props_mod,
                                svn_boolean_t *update_root,
                                const char **lock_token,
@@ -1495,12 +1496,16 @@ svn_wc__node_get_commit_status(svn_node_
   svn_wc__db_status_t status;
   svn_wc__db_kind_t db_kind;
   svn_wc__db_lock_t *lock;
-  svn_boolean_t had_props;
+  svn_boolean_t had_props_tmp;
   svn_boolean_t props_mod_tmp;
   svn_boolean_t have_base;
   svn_boolean_t have_more_work;
   svn_boolean_t op_root;
 
+  /* ### Since there is only one caller, checking out-parameters for NULL is
+   * actually an exercise in futility. Just going with the flow here. */
+  if (!had_props)
+    had_props = &had_props_tmp;
   if (!props_mod)
     props_mod = &props_mod_tmp;
 
@@ -1510,7 +1515,7 @@ svn_wc__node_get_commit_status(svn_node_
                                original_repos_relpath, NULL, NULL,
                                original_revision, &lock, NULL, NULL,
                                changelist, conflicted,
-                               &op_root, &had_props, props_mod,
+                               &op_root, had_props, props_mod,
                                &have_base, &have_more_work, NULL,
                                wc_ctx->db, local_abspath,
                                result_pool, scratch_pool));
@@ -1553,7 +1558,7 @@ svn_wc__node_get_commit_status(svn_node_
       *symlink = FALSE;
 
       if (db_kind == svn_wc__db_kind_file
-          && (had_props || *props_mod))
+          && (*had_props || *props_mod))
         {
           SVN_ERR(svn_wc__db_read_props(&props, wc_ctx->db, local_abspath,
                                         scratch_pool, scratch_pool));


Reply via email to