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

[PATCH] Add a pool to the RA->get_dir() implementation.

From: <cmpilato_at_collab.net>
Date: 2003-03-07 03:52:15 CET

I really wanted to get this into 0.19, but my DAV testing setup is
hosed (and it apparently isn't because of this patch, as reversion
doesn't fix anything). Could someone please apply and test? If all
is well, let me know, and I'll commit up the change.

Thanks!
C-Mike

--------------------------------------------------------------------------
Part of Issue #1169 - RA vtable functions need to take pool arguments.

* subversion/include/svn_ra.h
  (svn_ra_plugin_t): Add 'pool' parameter to 'get_dir' vtable function.

* subversion/libsvn_ra_local/ra_plugin.c
  (get_node_props): New helper.
  (svn_ra_local__get_file): Use new get_node_props() helper.
  (svn_ra_local__get_dir): Add 'pool' parameter. Also, use new
    get_node_props() helper. Finally, I noted that the datestring was
    being alloced in the subpool -- which was being cleared!

* subversion/libsvn_ra_dav/ra_dav.h
* subversion/libsvn_ra_dav/fetch.c
  (svn_ra_dav__get_dir): Add 'pool' parameter.

* subversion/libsvn_ra_svn/client.c
  (ra_svn_get_dir): Add 'pool' parameter, and use it. (Another
    smoochie for the convenience variable).

Update calls to RA->get_dir()
* subversion/libsvn_ra_dav/session.c (svn_ra_dav__do_get_uuid):
* subversion/libsvn_client/ls.c (get_dir_contents, svn_client_ls):
* subversion/libsvn_client/prop_commands.c (remote_propget, remote_proplist):
* subversion/libsvn_client/repos_diff.c (get_dirprops_from_ra):

Index: subversion/include/svn_ra.h
===================================================================
--- subversion/include/svn_ra.h (revision 5230)
+++ subversion/include/svn_ra.h (working copy)
@@ -395,7 +395,7 @@
    * If @a dirents is non @c NULL, set @a *dirents to contain all the entries
    * of directory @a path at @a revision. The keys of @a dirents will be
    * entry names (<tt>const char *</tt>), and the values dirents
- * (<tt>@c svn_dirent_t *</tt>).
+ * (<tt>@c svn_dirent_t *</tt>). Use @a pool for all allocations.
    *
    * @a path is interpreted relative to the url in @a session_baton.
    *
@@ -416,7 +416,8 @@
                            svn_revnum_t revision,
                            apr_hash_t **dirents,
                            svn_revnum_t *fetched_rev,
- apr_hash_t **props);
+ apr_hash_t **props,
+ apr_pool_t *pool);
 
 
   /** Check out revision @a revision of the url specified in
Index: subversion/libsvn_ra_local/ra_plugin.c
===================================================================
--- subversion/libsvn_ra_local/ra_plugin.c (revision 5230)
+++ subversion/libsvn_ra_local/ra_plugin.c (working copy)
@@ -632,6 +632,48 @@
 
 
 
+static svn_error_t *
+get_node_props (apr_hash_t **props,
+ svn_ra_local__session_baton_t *sbaton,
+ svn_fs_root_t *root,
+ const char *path,
+ apr_pool_t *pool)
+{
+ svn_revnum_t cmt_rev;
+ const char *cmt_date, *cmt_author;
+
+ /* Create a hash with props attached to the fs node. */
+ SVN_ERR (svn_fs_node_proplist (props, root, path, pool));
+
+ /* Now add some non-tweakable metadata to the hash as well... */
+
+ /* The so-called 'entryprops' with info about CR & friends. */
+ SVN_ERR (svn_repos_get_committed_info (&cmt_rev, &cmt_date,
+ &cmt_author, root, path, pool));
+
+ apr_hash_set (*props,
+ SVN_PROP_ENTRY_COMMITTED_REV,
+ APR_HASH_KEY_STRING,
+ svn_string_createf (pool, "%" SVN_REVNUM_T_FMT, cmt_rev));
+ apr_hash_set (*props,
+ SVN_PROP_ENTRY_COMMITTED_DATE,
+ APR_HASH_KEY_STRING,
+ cmt_date ? svn_string_create (cmt_date, pool) : NULL);
+ apr_hash_set (*props,
+ SVN_PROP_ENTRY_LAST_AUTHOR,
+ APR_HASH_KEY_STRING,
+ cmt_author ? svn_string_create (cmt_author, pool) : NULL);
+ apr_hash_set (*props,
+ SVN_PROP_ENTRY_UUID,
+ APR_HASH_KEY_STRING,
+ svn_string_create (sbaton->uuid, pool));
+
+ /* We have no 'wcprops' in ra_local, but might someday. */
+
+ return SVN_NO_ERROR;
+}
+
+
 /* Getting just one file. */
 static svn_error_t *
 svn_ra_local__get_file (void *session_baton,
@@ -716,53 +758,16 @@
             }
         }
     }
-
+
+ /* Handle props if requested. */
   if (props)
- {
- svn_revnum_t committed_rev;
- const char *committed_date, *last_author;
+ SVN_ERR (get_node_props (props, sbaton, root, abs_path, pool));
 
- /* Create a hash with props attached to the fs node. */
- SVN_ERR (svn_fs_node_proplist (props, root, abs_path, pool));
-
- /* Now add some non-tweakable metadata to the hash as well... */
-
- /* The so-called 'entryprops' with info about CR & friends. */
- SVN_ERR (svn_repos_get_committed_info (&committed_rev,
- &committed_date,
- &last_author,
- root, abs_path,
- pool));
-
- apr_hash_set (*props,
- SVN_PROP_ENTRY_COMMITTED_REV,
- APR_HASH_KEY_STRING,
- svn_string_createf (pool, "%" SVN_REVNUM_T_FMT,
- committed_rev));
- apr_hash_set (*props,
- SVN_PROP_ENTRY_COMMITTED_DATE,
- APR_HASH_KEY_STRING,
- committed_date ? svn_string_create (committed_date, pool)
- : NULL) ;
- apr_hash_set (*props,
- SVN_PROP_ENTRY_LAST_AUTHOR,
- APR_HASH_KEY_STRING,
- last_author ? svn_string_create (last_author, pool)
- : NULL);
- apr_hash_set (*props,
- SVN_PROP_ENTRY_UUID,
- APR_HASH_KEY_STRING,
- svn_string_create (sbaton->uuid, pool));
-
- /* We have no 'wcprops' in ra_local, but might someday. */
- }
-
   return SVN_NO_ERROR;
 }
 
 
 
-
 /* Getting a directory's entries */
 static svn_error_t *
 svn_ra_local__get_dir (void *session_baton,
@@ -770,7 +775,8 @@
                        svn_revnum_t revision,
                        apr_hash_t **dirents,
                        svn_revnum_t *fetched_rev,
- apr_hash_t **props)
+ apr_hash_t **props,
+ apr_pool_t *pool)
 {
   svn_fs_root_t *root;
   svn_revnum_t youngest_rev;
@@ -778,7 +784,7 @@
   apr_hash_index_t *hi;
   svn_ra_local__session_baton_t *sbaton = session_baton;
   const char *abs_path = sbaton->fs_path;
- apr_pool_t *subpool, *pool = sbaton->pool;
+ apr_pool_t *subpool;
 
   /* ### Not sure if this counts as a workaround or not. The
      session baton uses the empty string to mean root, and not
@@ -850,10 +856,9 @@
                                                  &(entry->last_author),
                                                  root, fullpath, subpool));
           if (datestring)
- SVN_ERR (svn_time_from_cstring(&(entry->time),
- datestring, subpool));
+ SVN_ERR (svn_time_from_cstring (&(entry->time), datestring, pool));
           if (entry->last_author)
- entry->last_author = apr_pstrdup(pool, entry->last_author);
+ entry->last_author = apr_pstrdup (pool, entry->last_author);
           
           /* Store. */
           apr_hash_set (*dirents, entryname, APR_HASH_KEY_STRING, entry);
@@ -862,51 +867,10 @@
         }
     }
 
- /* Get the dir's properties too, if requested. */
+ /* Handle props if requested. */
   if (props)
- {
- svn_revnum_t committed_rev;
- const char *committed_date, *last_author;
- svn_string_t *value;
- char *revision_str = NULL;
+ SVN_ERR (get_node_props (props, sbaton, root, abs_path, pool));
 
- /* Create a hash with props attached to the fs node. */
- SVN_ERR (svn_fs_node_proplist (props, root, abs_path, pool));
-
- /* Now add some non-tweakable metadata to the hash as well... */
-
- /* The so-called 'entryprops' with info about CR & friends. */
- SVN_ERR (svn_repos_get_committed_info (&committed_rev,
- &committed_date,
- &last_author,
- root, abs_path,
- pool));
-
- revision_str = apr_psprintf (pool, "%" SVN_REVNUM_T_FMT,
- committed_rev);
- value = svn_string_create (revision_str, sbaton->pool);
- apr_hash_set (*props, SVN_PROP_ENTRY_COMMITTED_REV,
- APR_HASH_KEY_STRING, value);
-
- value = (committed_date) ?
- svn_string_create (committed_date, pool) : NULL;
-
- apr_hash_set (*props, SVN_PROP_ENTRY_COMMITTED_DATE,
- APR_HASH_KEY_STRING, value);
-
- value = (last_author) ?
- svn_string_create (last_author, pool) : NULL;
-
- apr_hash_set (*props, SVN_PROP_ENTRY_LAST_AUTHOR,
- APR_HASH_KEY_STRING, value);
-
- value = svn_string_create (sbaton->uuid, pool);
- apr_hash_set (*props, SVN_PROP_ENTRY_UUID,
- APR_HASH_KEY_STRING, value);
-
- /* We have no 'wcprops' in ra_local, but might someday. */
- }
-
   return SVN_NO_ERROR;
 }
 
Index: subversion/libsvn_client/prop_commands.c
===================================================================
--- subversion/libsvn_client/prop_commands.c (revision 5230)
+++ subversion/libsvn_client/prop_commands.c (working copy)
@@ -378,7 +378,7 @@
     {
       SVN_ERR (ra_lib->get_dir (session, target_relative, revnum,
                                 (recurse ? &dirents : NULL),
- NULL, &prop_hash));
+ NULL, &prop_hash, pool));
     }
   else if (kind == svn_node_file)
     {
@@ -665,7 +665,7 @@
     {
       SVN_ERR (ra_lib->get_dir (session, target_relative, revnum,
                                 (recurse ? &dirents : NULL),
- NULL, &prop_hash));
+ NULL, &prop_hash, pool));
     }
   else if (kind == svn_node_file)
     {
Index: subversion/libsvn_client/ls.c
===================================================================
--- subversion/libsvn_client/ls.c (revision 5230)
+++ subversion/libsvn_client/ls.c (working copy)
@@ -39,7 +39,8 @@
 
   /* Get the directory's entries, but not its props. */
   if (ra_lib->get_dir)
- SVN_ERR (ra_lib->get_dir (session, dir, rev, &tmpdirents, NULL, NULL));
+ SVN_ERR (ra_lib->get_dir (session, dir, rev, &tmpdirents,
+ NULL, NULL, pool));
   else
     return svn_error_create (SVN_ERR_RA_NOT_IMPLEMENTED, NULL,
                              "No get_dir() available for url schema.");
@@ -131,7 +132,8 @@
 
       /* Get all parent's entries, no props. */
       if (ra_lib->get_dir)
- SVN_ERR (ra_lib->get_dir (session, "", rev, &parent_ents, NULL, NULL));
+ SVN_ERR (ra_lib->get_dir (session, "", rev, &parent_ents,
+ NULL, NULL, pool));
       else
         return svn_error_create (SVN_ERR_RA_NOT_IMPLEMENTED, NULL,
                                  "No get_dir() available for url schema.");
Index: subversion/libsvn_client/repos_diff.c
===================================================================
--- subversion/libsvn_client/repos_diff.c (revision 5230)
+++ subversion/libsvn_client/repos_diff.c (working copy)
@@ -309,7 +309,8 @@
                                            b->path,
                                            b->edit_baton->revision,
                                            &dirents, NULL,
- &(b->pristine_props)));
+ &(b->pristine_props),
+ b->pool));
 
   return SVN_NO_ERROR;
 }
Index: subversion/libsvn_ra_svn/client.c
===================================================================
--- subversion/libsvn_ra_svn/client.c (revision 5230)
+++ subversion/libsvn_ra_svn/client.c (working copy)
@@ -568,10 +568,10 @@
 static svn_error_t *ra_svn_get_dir(void *sess, const char *path,
                                    svn_revnum_t rev, apr_hash_t **dirents,
                                    svn_revnum_t *fetched_rev,
- apr_hash_t **props)
+ apr_hash_t **props,
+ apr_pool_t *pool)
 {
   svn_ra_svn_conn_t *conn = sess;
- apr_pool_t *pool = conn->pool;
   svn_revnum_t crev;
   apr_array_header_t *proplist, *dirlist;
   int i;
Index: subversion/libsvn_ra_dav/ra_dav.h
===================================================================
--- subversion/libsvn_ra_dav/ra_dav.h (revision 5230)
+++ subversion/libsvn_ra_dav/ra_dav.h (working copy)
@@ -115,7 +115,8 @@
   svn_revnum_t revision,
   apr_hash_t **dirents,
   svn_revnum_t *fetched_rev,
- apr_hash_t **props);
+ apr_hash_t **props,
+ apr_pool_t *pool);
 
 svn_error_t * svn_ra_dav__abort_commit(
  void *session_baton,
Index: subversion/libsvn_ra_dav/session.c
===================================================================
--- subversion/libsvn_ra_dav/session.c (revision 5230)
+++ subversion/libsvn_ra_dav/session.c (working copy)
@@ -507,7 +507,7 @@
     {
       apr_hash_t *props;
       const svn_string_t *value;
- SVN_ERR(svn_ra_dav__get_dir(ras, "", 0, NULL, NULL, &props));
+ SVN_ERR(svn_ra_dav__get_dir(ras, "", 0, NULL, NULL, &props, ras->pool));
       value = apr_hash_get(props, SVN_PROP_ENTRY_UUID, APR_HASH_KEY_STRING);
       ras->uuid = value->data;
     }
Index: subversion/libsvn_ra_dav/fetch.c
===================================================================
--- subversion/libsvn_ra_dav/fetch.c (revision 5230)
+++ subversion/libsvn_ra_dav/fetch.c (working copy)
@@ -1066,7 +1066,8 @@
                                  svn_revnum_t revision,
                                  apr_hash_t **dirents,
                                  svn_revnum_t *fetched_rev,
- apr_hash_t **props)
+ apr_hash_t **props,
+ apr_pool_t *pool)
 {
   svn_ra_dav_resource_t *rsrc;
   apr_hash_index_t *hi;
@@ -1075,7 +1076,7 @@
   const char *final_url;
   char *stripped_final_url;
   svn_ra_session_t *ras = (svn_ra_session_t *) session_baton;
- const char *url = svn_path_url_add_component (ras->url, path, ras->pool);
+ const char *url = svn_path_url_add_component (ras->url, path, pool);
 
   /* If the revision is invalid (head), then we're done. Just fetch
      the public URL, because that will always get HEAD. */
@@ -1093,10 +1094,10 @@
                                              &got_rev,
                                              ras->sess,
                                              url, revision,
- ras->pool));
+ pool));
       final_url = svn_path_url_add_component(bc_url.data,
                                              bc_relative.data,
- ras->pool);
+ pool);
       if (fetched_rev != NULL)
         *fetched_rev = got_rev;
     }
@@ -1107,11 +1108,11 @@
          PROPFIND on the directory of depth 1. */
       SVN_ERR( svn_ra_dav__get_props(&resources, ras->sess,
                                      final_url, NE_DEPTH_ONE,
- NULL, NULL /* all props */, ras->pool) );
+ NULL, NULL /* all props */, pool) );
       
       /* Clean up any trailing slashes on final_url, creating
          stripped_final_url */
- stripped_final_url = apr_pstrdup(ras->pool, final_url);
+ stripped_final_url = apr_pstrdup(pool, final_url);
       len = strlen(final_url);
       if (len > 1 && final_url[len - 1] == '/')
         stripped_final_url[len - 1] = '\0';
@@ -1119,8 +1120,8 @@
       /* Now we have a hash that maps a bunch of url children to resource
          objects. Each resource object contains the properties of the
          child. Parse these resources into svn_dirent_t structs. */
- *dirents = apr_hash_make (ras->pool);
- for (hi = apr_hash_first (ras->pool, resources);
+ *dirents = apr_hash_make (pool);
+ for (hi = apr_hash_first (pool, resources);
            hi;
            hi = apr_hash_next (hi))
         {
@@ -1140,7 +1141,7 @@
           if (strcmp(resource->url, stripped_final_url) == 0)
             continue;
           
- entry = apr_pcalloc (ras->pool, sizeof(*entry));
+ entry = apr_pcalloc (pool, sizeof(*entry));
           
           /* node kind */
           entry->kind = resource->is_collection ? svn_node_dir : svn_node_file;
@@ -1156,7 +1157,7 @@
           
           /* does this resource contain any 'svn' or 'custom' properties,
              i.e. ones actually created and set by the user? */
- for (h = apr_hash_first (ras->pool, resource->propset);
+ for (h = apr_hash_first (pool, resource->propset);
                h; h = apr_hash_next (h))
             {
               const void *kkey;
@@ -1196,7 +1197,7 @@
                                  APR_HASH_KEY_STRING);
           if (propval != NULL)
             SVN_ERR( svn_time_from_cstring(&(entry->time),
- propval, ras->pool) );
+ propval, pool) );
           
           propval = apr_hash_get(resource->propset,
                                  SVN_RA_DAV__PROP_CREATOR_DISPLAYNAME,
@@ -1204,7 +1205,7 @@
           if (propval != NULL)
             entry->last_author = propval;
           
- apr_hash_set(*dirents, svn_path_basename(childname, ras->pool),
+ apr_hash_set(*dirents, svn_path_basename(childname, pool),
                        APR_HASH_KEY_STRING, entry);
         }
     }
@@ -1213,10 +1214,10 @@
     {
       SVN_ERR( svn_ra_dav__get_props_resource(&rsrc, ras->sess, final_url,
                                               NULL, NULL /* all props */,
- ras->pool) );
+ pool) );
 
- *props = apr_hash_make(ras->pool);
- SVN_ERR (filter_props (*props, rsrc, TRUE, ras->pool));
+ *props = apr_hash_make(pool);
+ SVN_ERR (filter_props (*props, rsrc, TRUE, pool));
     }
 
   return SVN_NO_ERROR;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Mar 7 03:54:11 2003

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.