[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: new experimental branch: dir-auto-props (issue 1989)

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2005-03-18 18:57:19 CET

"Ph. Marek" <philipp.marek@bmlv.gv.at> writes:

> --- subversion/libsvn_client/client.h (revision 231)
> +++ subversion/libsvn_client/client.h (revision 232)
> @@ -286,6 +286,18 @@
> const char *path,
> svn_client_ctx_t *ctx,
> apr_pool_t *pool);
> +
> +
> +/* Read automatic properties matching PATH from CTX->config.
> + Set *PROPERTIES to a hash containing propname/value pairs
> + (const char * keys mapping to svn_string_t * values), or if
> + auto-props are disabled, set *PROPERTIES to NULL.

Your implementation never sets *PROPERTIES to NULL. I don't know
whether you made a mistake with the comment or the implementation.

> + Allocate the hash table, keys, values, and mimetype in POOL. */
> +svn_error_t *svn_client__get_dir_auto_props (apr_hash_t **properties,
> + const char *path,
> + svn_client_ctx_t *ctx,
> + apr_pool_t *pool);
> +
>
>
> /* The main logic for client deletion from a working copy. Deletes PATH
> === subversion/libsvn_client/add.c
> ==================================================================
> --- subversion/libsvn_client/add.c (revision 231)
> +++ subversion/libsvn_client/add.c (revision 232)
> @@ -197,6 +197,40 @@
> return SVN_NO_ERROR;
> }
>
> +svn_error_t *
> +svn_client__get_dir_auto_props (apr_hash_t **properties,
> + const char *path,
> + svn_client_ctx_t *ctx,
> + apr_pool_t *pool)
> +{
> + svn_config_t *cfg;
> + svn_boolean_t use_autoprops;
> + auto_props_baton_t autoprops;
> +
> + /* initialisation */

A pointless comment.

> + autoprops.properties = apr_hash_make (pool);
> + autoprops.filename = svn_path_basename (path, pool);
> + autoprops.pool = pool;
> + autoprops.mimetype = NULL;
> + autoprops.have_executable = FALSE;
> + *properties = autoprops.properties;
> +
> + cfg = ctx->config ? apr_hash_get (ctx->config, SVN_CONFIG_CATEGORY_CONFIG,
> + APR_HASH_KEY_STRING) : NULL;
> +
> + /* check that auto props is enabled */
> + SVN_ERR (svn_config_get_bool (cfg, &use_autoprops,
> + SVN_CONFIG_SECTION_MISCELLANY,
> + SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, FALSE));
> +
> + /* search for directory auto props */
> + if (use_autoprops)
> + svn_config_enumerate (cfg, SVN_CONFIG_SECTION_DIR_AUTO_PROPS,
> + auto_props_enumerator, &autoprops);
> +
> + return SVN_NO_ERROR;
> +}
> +
> static svn_error_t *
> add_file (const char *path,
> svn_client_ctx_t *ctx,
> @@ -389,6 +423,6 @@
> {
> svn_node_kind_t kind;
> svn_error_t *err;
> + apr_hash_t* properties;
> + apr_hash_index_t *hi;
>
> SVN_ERR (svn_io_check_path (path, &kind, pool));
> if ((kind == svn_node_dir) && recursive)
> @@ -400,6 +436,31 @@
> ctx->cancel_func, ctx->cancel_baton,
> ctx->notify_func, ctx->notify_baton, pool);
>
> + if (kind == svn_node_dir)
> + {
> + /* Now that the .svn-directories exist, do the directories auto-props */
> + SVN_ERR (svn_client__get_dir_auto_props (&properties, path, ctx,
> + pool));
> + if (properties)

That test makes sense if one believes the documentation, but with the
current implementation properties can never be NULL.

> + {
> + /* loop through the hashtable and add the properties */
> + for (hi = apr_hash_first (pool, properties);
> + hi != NULL; hi = apr_hash_next (hi))
> + {
> + const void *pname;
> + void *pval;
> +
> + apr_hash_this (hi, &pname, NULL, &pval);
> + /* It's probably best to pass 0 for force, so that if
> + the autoprops say to set some weird combination,
> + we just error and let the user sort it out. */
> + SVN_ERR (svn_wc_prop_set2 (pname, pval, path,
> + adm_access, FALSE, pool));
> + }
> + }
> + }
> +
> +
> /* Ignore SVN_ERR_ENTRY_EXISTS when FORCE is set. */
> if (err && err->apr_err == SVN_ERR_ENTRY_EXISTS && force)
> {
> === subversion/libsvn_client/commit.c
> ==================================================================
> --- subversion/libsvn_client/commit.c (revision 231)
> +++ subversion/libsvn_client/commit.c (revision 232)
> @@ -277,11 +277,27 @@
> apr_hash_t *dirents;
> apr_hash_index_t *hi;
> apr_array_header_t *ignores;
> + apr_hash_t* properties;
>
> SVN_ERR (svn_path_check_valid (path, pool));
>
> SVN_ERR (svn_wc_get_default_ignores (&ignores, ctx->config, pool));
>
> + SVN_ERR (svn_client__get_dir_auto_props (&properties, path, ctx,
> + pool));
> + if (properties)

Again, properties can never be null with the current implementation.

> + {
> + for (hi = apr_hash_first (pool, properties); hi; hi = apr_hash_next (hi))
> + {
> + const void *pname;
> + void *pval;
> +
> + apr_hash_this (hi, &pname, NULL, &pval);
> + SVN_ERR (editor->change_dir_prop (dir_baton, pname, pval, pool));
> + }
> + }
> +
> +
> SVN_ERR (svn_io_get_dirents (&dirents, path, pool));
>
> for (hi = apr_hash_first (pool, dirents); hi; hi = apr_hash_next (hi))

New functionality like this should have some regression tests.

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Mar 18 18:58:32 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.