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 2010/11/12 17:33:09 UTC
svn commit: r1034455 - in /subversion/trunk/subversion/libsvn_client:
client.h externals.c status.c
Author: cmpilato
Date: Fri Nov 12 16:33:09 2010
New Revision: 1034455
URL: http://svn.apache.org/viewvc?rev=1034455&view=rev
Log:
Reduce overlap by merging two nearly-identical private interfaces and
implementations into a single one.
* subversion/libsvn_client/client.h
(struct svn_cl__externals_store, svn_cl__store_externals): Remove as
completely redundant with svn_client__external_func_baton_t and
svn_client__external_info_gatherer(). Besides, they used the
wrong namespace (shoulda been "svn_client__...")!
(svn_client__external_func_baton_t, svn_client__external_info_gatherer):
Rewrite docstrings for clarity.
* subversion/libsvn_client/externals.c
(svn_cl__store_externals): Removed as unused (and redundant).
(svn_client__external_info_gatherer): Rework this to allow for NULL
destination hashes.
* subversion/libsvn_client/status.c
(svn_client_status5): Use svn_client__external_func_baton_t and
svn_client__external_info_gatherer() instead of struct
svn_cl__externals_store and svn_cl__externals_store(), respectively.
Modified:
subversion/trunk/subversion/libsvn_client/client.h
subversion/trunk/subversion/libsvn_client/externals.c
subversion/trunk/subversion/libsvn_client/status.c
Modified: subversion/trunk/subversion/libsvn_client/client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1034455&r1=1034454&r2=1034455&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Fri Nov 12 16:33:09 2010
@@ -898,27 +898,6 @@ svn_client__do_commit(const char *base_u
/*** Externals (Modules) ***/
-struct svn_cl__externals_store
-{
- apr_pool_t *pool;
- apr_hash_t *externals_old;
- apr_hash_t *externals_new;
- apr_hash_t *depths;
-};
-
-/* Implements svn_wc_external_update_t handler, storing the received
- data in a svn_cl__externals_store instance, which must be passed as
- BATON. Ignore (and don't try to update) any of the BATON's hash
- members when they are NULL. */
-svn_error_t *
-svn_cl__store_externals(void *baton,
- const char *local_abspath,
- const svn_string_t *old_value,
- const svn_string_t *new_value,
- svn_depth_t depth,
- apr_pool_t *scratch_pool);
-
-
/* Handle changes to the svn:externals property described by EXTERNALS_OLD,
EXTERNALS_NEW, and AMBIENT_DEPTHS. The tree's top level directory
is at TO_ABSPATH and corresponds to FROM_URL URL in the repository,
@@ -1022,20 +1001,24 @@ svn_client__crawl_for_externals(apr_hash
apr_pool_t *scratch_pool,
apr_pool_t *result_pool);
-/* Baton type for svn_wc__external_info_gatherer(). All fields must be
- populated before use. */
+/* Baton type for svn_wc__external_info_gatherer(). */
typedef struct svn_client__external_func_baton_t
{
- apr_hash_t *externals_old;
- apr_hash_t *externals_new;
- apr_hash_t *ambient_depths;
- apr_pool_t *result_pool;
+ apr_hash_t *externals_old; /* Hash of old externals property values,
+ or NULL if the caller doesn't care. */
+ apr_hash_t *externals_new; /* Hash of new externals property values,
+ or NULL if the caller doesn't care. */
+ apr_hash_t *ambient_depths; /* Hash of ambient depth values, or NULL
+ if the caller doesn't care. */
+ apr_pool_t *result_pool; /* Pool to use for all stored values. */
} svn_client__external_func_baton_t;
/* This function gets invoked whenever external changes are encountered.
- This implements svn_wc_external_update_t */
+ This implements the `svn_wc_external_update_t' interface, and can
+ be used with an svn_client__external_func_baton_t BATON to gather
+ information about changes to externals definitions. */
svn_error_t *
svn_client__external_info_gatherer(void *baton,
const char *local_abspath,
Modified: subversion/trunk/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/externals.c?rev=1034455&r1=1034454&r2=1034455&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/externals.c (original)
+++ subversion/trunk/subversion/libsvn_client/externals.c Fri Nov 12 16:33:09 2010
@@ -1392,69 +1392,33 @@ svn_client__do_external_status(svn_clien
return SVN_NO_ERROR;
}
-/* Implements svn_wc_externals_update_t */
-svn_error_t *
-svn_cl__store_externals(void *baton,
- const char *local_abspath,
- const svn_string_t *old_value,
- const svn_string_t *new_value,
- svn_depth_t depth,
- apr_pool_t *scratch_pool)
-{
- struct svn_cl__externals_store *eb = baton;
- apr_pool_t *dup_pool = eb->pool;
-
- local_abspath = apr_pstrdup(dup_pool, local_abspath);
-
- if (eb->externals_old != NULL && old_value != NULL)
- apr_hash_set(eb->externals_new,
- local_abspath, APR_HASH_KEY_STRING,
- apr_pstrndup(dup_pool, old_value->data, old_value->len));
-
- if (eb->externals_new != NULL && new_value != NULL)
- apr_hash_set(eb->externals_new,
- local_abspath, APR_HASH_KEY_STRING,
- apr_pstrndup(dup_pool, new_value->data, new_value->len));
-
- if (eb->depths != NULL)
- apr_hash_set(eb->depths,
- local_abspath, APR_HASH_KEY_STRING,
- svn_depth_to_word(depth));
-
- return SVN_NO_ERROR;
-}
-
+/* Implements the `svn_wc_externals_update_t' interface. */
svn_error_t *
svn_client__external_info_gatherer(void *baton,
const char *local_abspath,
- const svn_string_t *old_val,
- const svn_string_t *new_val,
+ const svn_string_t *old_value,
+ const svn_string_t *new_value,
svn_depth_t depth,
apr_pool_t *scratch_pool)
{
svn_client__external_func_baton_t *efb = baton;
- const char *dup_val = NULL;
- const char *dup_path = apr_pstrdup(efb->result_pool, local_abspath);
- if (old_val)
- {
- dup_val = apr_pstrmemdup(efb->result_pool, old_val->data, old_val->len);
-
- apr_hash_set(efb->externals_old, dup_path, APR_HASH_KEY_STRING, dup_val);
- }
-
- if (new_val)
- {
- /* In most cases the value is identical */
- if (old_val != new_val)
- dup_val = apr_pstrmemdup(efb->result_pool, new_val->data, new_val->len);
+ local_abspath = apr_pstrdup(efb->result_pool, local_abspath);
- apr_hash_set(efb->externals_new, dup_path, APR_HASH_KEY_STRING, dup_val);
- }
+ if (efb->externals_old != NULL && old_value != NULL)
+ apr_hash_set(efb->externals_old, local_abspath, APR_HASH_KEY_STRING,
+ apr_pstrndup(efb->result_pool,
+ old_value->data, old_value->len));
+
+ if (efb->externals_new != NULL && new_value != NULL)
+ apr_hash_set(efb->externals_new, local_abspath, APR_HASH_KEY_STRING,
+ apr_pstrndup(efb->result_pool,
+ new_value->data, new_value->len));
- apr_hash_set(efb->ambient_depths, dup_path, APR_HASH_KEY_STRING,
- svn_depth_to_word(depth));
+ if (efb->ambient_depths != NULL)
+ apr_hash_set(efb->ambient_depths, local_abspath, APR_HASH_KEY_STRING,
+ svn_depth_to_word(depth));
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_client/status.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/status.c?rev=1034455&r1=1034454&r2=1034455&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/status.c (original)
+++ subversion/trunk/subversion/libsvn_client/status.c Fri Nov 12 16:33:09 2010
@@ -267,7 +267,7 @@ svn_client_status5(svn_revnum_t *result_
apr_array_header_t *ignores;
svn_error_t *err;
apr_hash_t *changelist_hash = NULL;
- struct svn_cl__externals_store externals_store = { NULL };
+ struct svn_client__external_func_baton_t externals_store = { NULL };
if (svn_path_is_url(path))
return svn_error_return(svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
@@ -357,7 +357,7 @@ svn_client_status5(svn_revnum_t *result_
if (!ignore_externals)
{
- externals_store.pool = pool;
+ externals_store.result_pool = pool;
externals_store.externals_new = apr_hash_make(pool);
}
@@ -393,10 +393,10 @@ svn_client_status5(svn_revnum_t *result_
dir_abspath, target_basename,
depth, get_all,
no_ignore, ignores, tweak_status, &sb,
- ignore_externals ? NULL
- : svn_cl__store_externals,
- ignore_externals ? NULL
- : &externals_store,
+ ignore_externals
+ ? NULL
+ : svn_client__external_info_gatherer,
+ ignore_externals ? NULL : &externals_store,
ctx->cancel_func, ctx->cancel_baton,
pool, pool));
@@ -517,10 +517,10 @@ svn_client_status5(svn_revnum_t *result_
err = svn_wc_walk_status(ctx->wc_ctx, target_abspath,
depth, get_all, no_ignore, ignores,
tweak_status, &sb,
- ignore_externals ? NULL
- : svn_cl__store_externals,
- ignore_externals ? NULL
- : &externals_store,
+ ignore_externals
+ ? NULL
+ : svn_client__external_info_gatherer,
+ ignore_externals ? NULL : &externals_store,
ctx->cancel_func, ctx->cancel_baton,
pool);