subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r1130385 - in /subversion/trunk/subversion/libsvn_ra_serf: property.c ra_serf.h replay.c serf.c
Date Thu, 02 Jun 2011 02:49:13 GMT
Author: gstein
Date: Thu Jun  2 02:49:13 2011
New Revision: 1130385

URL: http://svn.apache.org/viewvc?rev=1130385&view=rev
Log:
Trade a library-public callback function for a basic function call that
uses the walker and callback internally. This clarifies what is happening,
and provides better control of pool lifetimes (and usage).

* subversion/libsvn_ra_serf/ra_serf.h:
  (svn_ra_serf__set_bare_props): removed in favor of ...
  (svn_ra_serf__select_revprops): ... this. new declaration

* subversion/libsvn_ra_serf/property.c:
  (svn_ra_serf__set_bare_props): renamed to ...
  (select_revprops): ... this, and made static. rename local REVPROPS.
  (svn_ra_serf__select_revprops): new function that wraps the walker and
    the callback (select_revprops) internally.

* subversion/libsvn_ra_serf/serf.c:
  (svn_ra_serf__rev_proplist): switch from the walker and callback to the
    direct svn_ra_serf__select_revprops() call.

* subversion/libsvn_ra_serf/replay.c:
  (start_replay): switch from the walker and callback to the direct
    svn_ra_serf__select_revprops() call.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/property.c
    subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
    subversion/trunk/subversion/libsvn_ra_serf/replay.c
    subversion/trunk/subversion/libsvn_ra_serf/serf.c

Modified: subversion/trunk/subversion/libsvn_ra_serf/property.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/property.c?rev=1130385&r1=1130384&r2=1130385&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/property.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/property.c Thu Jun  2 02:49:13 2011
@@ -854,15 +854,15 @@ svn_ra_serf__flatten_props(apr_hash_t **
 }
 
 
-svn_error_t *
-svn_ra_serf__set_bare_props(void *baton,
-                            const char *ns,
-                            const char *name,
-                            const svn_string_t *val,
-                            apr_pool_t *scratch_pool)
+static svn_error_t *
+select_revprops(void *baton,
+                const char *ns,
+                const char *name,
+                const svn_string_t *val,
+                apr_pool_t *scratch_pool)
 {
-  apr_hash_t *props = baton;
-  apr_pool_t *result_pool = apr_hash_pool_get(props);
+  apr_hash_t *revprops = baton;
+  apr_pool_t *result_pool = apr_hash_pool_get(revprops);
   const char *prop_name;
 
   /* ### copy NAME into the RESULT_POOL?  */
@@ -882,12 +882,29 @@ svn_ra_serf__set_bare_props(void *baton,
       return SVN_NO_ERROR;
     }
 
-  apr_hash_set(props, prop_name, APR_HASH_KEY_STRING, val);
+  apr_hash_set(revprops, prop_name, APR_HASH_KEY_STRING, val);
 
   return SVN_NO_ERROR;
 }
 
 
+svn_error_t *
+svn_ra_serf__select_revprops(apr_hash_t **revprops,
+                             const char *name,
+                             svn_revnum_t rev,
+                             apr_hash_t *all_revprops,
+                             apr_pool_t *result_pool,
+                             apr_pool_t *scratch_pool)
+{
+  *revprops = apr_hash_make(result_pool);
+
+  return svn_error_return(svn_ra_serf__walk_all_props(
+                            all_revprops, name, rev,
+                            select_revprops, *revprops,
+                            scratch_pool));
+}
+
+
 /*
  * Contact the server (using SESSION and CONN) to calculate baseline
  * information for BASELINE_URL at REVISION (which may be

Modified: subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h?rev=1130385&r1=1130384&r2=1130385&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Thu Jun  2 02:49:13 2011
@@ -966,12 +966,15 @@ svn_ra_serf__svnname_from_wirename(const
                                    apr_pool_t *result_pool);
 
 
+/* Select the basic revision properties from the set of "all" properties.
+   Return these in *REVPROPS, allocated from RESULT_POOL.  */
 svn_error_t *
-svn_ra_serf__set_bare_props(void *baton,
-                            const char *ns,
-                            const char *name,
-                            const svn_string_t *val,
-                            apr_pool_t *pool);
+svn_ra_serf__select_revprops(apr_hash_t **revprops,
+                             const char *name,
+                             svn_revnum_t rev,
+                             apr_hash_t *all_revprops,
+                             apr_pool_t *result_pool,
+                             apr_pool_t *scratch_pool);
 
 
 /* PROPS is nested hash tables mapping REV -> PATH -> NS -> NAME -> VALUE.

Modified: subversion/trunk/subversion/libsvn_ra_serf/replay.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/replay.c?rev=1130385&r1=1130384&r2=1130385&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/replay.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/replay.c Thu Jun  2 02:49:13 2011
@@ -195,11 +195,15 @@ start_replay(svn_ra_serf__xml_parser_t *
 
       /* Create a pool for the commit editor. */
       ctx->dst_rev_pool = svn_pool_create(ctx->src_rev_pool);
-      ctx->props = apr_hash_make(ctx->dst_rev_pool);
-      SVN_ERR(svn_ra_serf__walk_all_props(ctx->revs_props, ctx->revprop_target,
-                                          ctx->revprop_rev,
-                                          svn_ra_serf__set_bare_props,
-                                          ctx->props, ctx->dst_rev_pool));
+
+      /* ### it would be nice to have a proper scratch_pool.  */
+      SVN_ERR(svn_ra_serf__select_revprops(&ctx->props,
+                                           ctx->revprop_target,
+                                           ctx->revprop_rev,
+                                           ctx->revs_props,
+                                           ctx->dst_rev_pool,
+                                           ctx->dst_rev_pool));
+
       if (ctx->revstart_func)
         {
           SVN_ERR(ctx->revstart_func(ctx->revision, ctx->replay_baton,

Modified: subversion/trunk/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/serf.c?rev=1130385&r1=1130384&r2=1130385&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/serf.c Thu Jun  2 02:49:13 2011
@@ -537,11 +537,8 @@ svn_ra_serf__rev_proplist(svn_ra_session
                                       propfind_path, rev, "0", all_props,
                                       pool, pool));
 
-  *ret_props = apr_hash_make(pool);
-
-  SVN_ERR(svn_ra_serf__walk_all_props(props, propfind_path, rev,
-                                      svn_ra_serf__set_bare_props, *ret_props,
-                                      pool));
+  SVN_ERR(svn_ra_serf__select_revprops(ret_props, propfind_path, rev, props,
+                                       pool, pool));
 
   return SVN_NO_ERROR;
 }



Mime
View raw message