subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r1130334 - in /subversion/trunk/subversion/libsvn_ra_serf: property.c ra_serf.h update.c
Date Wed, 01 Jun 2011 22:48:41 GMT
Author: gstein
Date: Wed Jun  1 22:48:40 2011
New Revision: 1130334

URL: http://svn.apache.org/viewvc?rev=1130334&view=rev
Log:
Unwind the callback-within-callback complexity. This will allow better
pool usage and understanding.

The svn_ra_serf__set_baton_props() is removed in favor of a function that
produce an "svn internal" name for a property. The set_baton_props() would
do the mapping, then make another call to a callback. Now, we just let the
caller do that for clarity.

* subversion/libsvn_ra_serf/ra_serf.h:
  (svn_ra_serf__prop_set_t): removed. no longer used.
  (svn_ra_serf__set_baton_props): removed
  (svn_ra_serf__svnname_from_wirename): new function, extracted from the
    set_baton_props() function.

* subversion/libsvn_ra_serf/property.c:
  (svn_ra_serf__set_baton_props): rebuilt into ...
  (svn_ra_serf__svnname_from_wirename): ... this.
  (set_hash_props): removed since we don't need the callback
  (set_flat_props): lose the set_baton_props() invocation and its use of a
    callback. just map the property name and shove it into the hash table.

* subversion/libsvn_ra_serf/update.c:
  (set_file_props, set_dir_props, remove_file_props, remove_dir_props):
    use the new propname mapping function and directly call the editor
    function with the appropriate arguments.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/property.c
    subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
    subversion/trunk/subversion/libsvn_ra_serf/update.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=1130334&r1=1130333&r2=1130334&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/property.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/property.c Wed Jun  1 22:48:40 2011
@@ -759,76 +759,69 @@ svn_ra_serf__walk_all_paths(apr_hash_t *
 }
 
 
-svn_error_t *
-svn_ra_serf__set_baton_props(svn_ra_serf__prop_set_t setprop,
-                             void *baton,
-                             const char *ns,
-                             const char *name,
-                             const svn_string_t *val,
-                             apr_pool_t *pool)
+const char *
+svn_ra_serf__svnname_from_wirename(const char *ns,
+                                   const char *name,
+                                   apr_pool_t *result_pool)
 {
-  const char *prop_name;
+  if (*ns == '\0' || strcmp(ns, SVN_DAV_PROP_NS_CUSTOM) == 0)
+    return apr_pstrdup(result_pool, name);
 
-  if (strcmp(ns, SVN_DAV_PROP_NS_CUSTOM) == 0)
-    prop_name = name;
-  else if (strcmp(ns, SVN_DAV_PROP_NS_SVN) == 0)
-    prop_name = apr_pstrcat(pool, SVN_PROP_PREFIX, name, (char *)NULL);
-  else if (strcmp(ns, SVN_PROP_PREFIX) == 0)
-    prop_name = apr_pstrcat(pool, SVN_PROP_PREFIX, name, (char *)NULL);
-  else if (strcmp(ns, "") == 0)
-    prop_name = name;
-  else if (strcmp(name, SVN_DAV__VERSION_NAME) == 0)
-    prop_name = SVN_PROP_ENTRY_COMMITTED_REV;
-  else if (strcmp(name, SVN_DAV__CREATIONDATE) == 0)
-    prop_name = SVN_PROP_ENTRY_COMMITTED_DATE;
-  else if (strcmp(name, "creator-displayname") == 0)
-    prop_name = SVN_PROP_ENTRY_LAST_AUTHOR;
-  else if (strcmp(name, "repository-uuid") == 0)
-    prop_name = SVN_PROP_ENTRY_UUID;
-  else if (strcmp(name, "lock-token") == 0)
-    prop_name = SVN_PROP_ENTRY_LOCK_TOKEN;
-  else if (strcmp(name, "checked-in") == 0)
-    prop_name = SVN_RA_SERF__WC_CHECKED_IN_URL;
-  else if (strcmp(ns, "DAV:") == 0 ||
-           strcmp(ns, SVN_DAV_PROP_NS_DAV) == 0)
+  if (strcmp(ns, SVN_DAV_PROP_NS_SVN) == 0)
+    return apr_pstrcat(result_pool, SVN_PROP_PREFIX, name, (char *)NULL);
+
+  if (strcmp(ns, SVN_PROP_PREFIX) == 0)
+    return apr_pstrcat(result_pool, SVN_PROP_PREFIX, name, (char *)NULL);
+
+  if (strcmp(name, SVN_DAV__VERSION_NAME) == 0)
+    return SVN_PROP_ENTRY_COMMITTED_REV;
+
+  if (strcmp(name, SVN_DAV__CREATIONDATE) == 0)
+    return SVN_PROP_ENTRY_COMMITTED_DATE;
+
+  if (strcmp(name, "creator-displayname") == 0)
+    return SVN_PROP_ENTRY_LAST_AUTHOR;
+
+  if (strcmp(name, "repository-uuid") == 0)
+    return SVN_PROP_ENTRY_UUID;
+
+  if (strcmp(name, "lock-token") == 0)
+    return SVN_PROP_ENTRY_LOCK_TOKEN;
+
+  if (strcmp(name, "checked-in") == 0)
+    return SVN_RA_SERF__WC_CHECKED_IN_URL;
+
+  if (strcmp(ns, "DAV:") == 0 || strcmp(ns, SVN_DAV_PROP_NS_DAV) == 0)
     {
       /* Here DAV: properties not yet converted to svn: properties should be
          ignored. */
-      return SVN_NO_ERROR;
-    }
-  else
-    {
-      /* An unknown namespace, must be a custom property. */
-      prop_name = apr_pstrcat(pool, ns, name, (char *)NULL);
+      return NULL;
     }
 
-  return setprop(baton, prop_name, val, pool);
+  /* An unknown namespace, must be a custom property. */
+  return apr_pstrcat(result_pool, ns, name, (char *)NULL);
 }
 
 
-/* Conforms to delta_editor.change_*_prop  */
+/* Conforms to svn_ra_serf__walker_visitor_t  */
 static svn_error_t *
-set_hash_props(void *baton,
+set_flat_props(void *baton,
+               const char *ns,
                const char *name,
                const svn_string_t *value,
                apr_pool_t *pool)
 {
   apr_hash_t *props = baton;
+  apr_pool_t *result_pool = apr_hash_pool_get(props);
+  const char *prop_name;
 
-  apr_hash_set(props, name, APR_HASH_KEY_STRING, value);
+  /* ### is VAL in the proper pool?  */
 
-  return SVN_NO_ERROR;
-}
+  prop_name = svn_ra_serf__svnname_from_wirename(ns, name, result_pool);
+  if (prop_name != NULL)
+    apr_hash_set(props, prop_name, APR_HASH_KEY_STRING, value);
 
-static svn_error_t *
-set_flat_props(void *baton,
-               const char *ns,
-               const char *name,
-               const svn_string_t *val,
-               apr_pool_t *pool)
-{
-  return svn_ra_serf__set_baton_props(set_hash_props, baton,
-                                      ns, name, val, pool);
+  return SVN_NO_ERROR;
 }
 
 

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=1130334&r1=1130333&r2=1130334&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Wed Jun  1 22:48:40 2011
@@ -953,19 +953,17 @@ svn_ra_serf__walk_all_paths(apr_hash_t *
                             void *baton,
                             apr_pool_t *pool);
 
-/* Higher-level variants on the walker. */
-typedef svn_error_t * (*svn_ra_serf__prop_set_t)(void *baton,
-                                                 const char *name,
-                                                 const svn_string_t *value,
-                                                 apr_pool_t *pool);
 
-svn_error_t *
-svn_ra_serf__set_baton_props(svn_ra_serf__prop_set_t setprop,
-                             void *baton,
-                             const char *ns,
-                             const char *name,
-                             const svn_string_t *val,
-                             apr_pool_t *pool);
+/* Map a property name, as passed over the wire, into its corresponding
+   Subversion-internal name. The returned name will be a static value,
+   or allocated within RESULT_POOL.
+
+   If the property should be ignored (eg. some DAV properties), then NULL
+   will be returned.  */
+const char *
+svn_ra_serf__svnname_from_wirename(const char *ns,
+                                   const char *name,
+                                   apr_pool_t *result_pool);
 
 
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1130334&r1=1130333&r2=1130334&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Wed Jun  1 22:48:40 2011
@@ -445,16 +445,23 @@ set_file_props(void *baton,
 {
   report_info_t *info = baton;
   const svn_delta_editor_t *editor = info->dir->update_editor;
+  apr_pool_t *scratch_pool = pool;  /* ### fix this  */
+  const char *prop_name;
 
   if (strcmp(name, "md5-checksum") == 0
       && strcmp(ns, SVN_DAV_PROP_NS_DAV) == 0)
     info->final_checksum = apr_pstrdup(info->pool, val->data);
 
-  return svn_ra_serf__set_baton_props(editor->change_file_prop,
-                                      info->file_baton,
-                                      ns, name, val, pool);
+  prop_name = svn_ra_serf__svnname_from_wirename(ns, name, scratch_pool);
+  if (prop_name != NULL)
+    return svn_error_return(editor->change_file_prop(info->file_baton,
+                                                     prop_name,
+                                                     val,
+                                                     scratch_pool));
+  return SVN_NO_ERROR;
 }
 
+
 static svn_error_t *
 set_dir_props(void *baton,
               const char *ns,
@@ -463,12 +470,20 @@ set_dir_props(void *baton,
               apr_pool_t *pool)
 {
   report_dir_t *dir = baton;
-
-  return svn_ra_serf__set_baton_props(dir->update_editor->change_dir_prop,
-                                      dir->dir_baton,
-                                      ns, name, val, pool);
+  const svn_delta_editor_t *editor = dir->update_editor;
+  apr_pool_t *scratch_pool = pool;  /* ### fix this  */
+  const char *prop_name;
+
+  prop_name = svn_ra_serf__svnname_from_wirename(ns, name, scratch_pool);
+  if (prop_name != NULL)
+    return svn_error_return(editor->change_dir_prop(dir->dir_baton,
+                                                    prop_name,
+                                                    val,
+                                                    scratch_pool));
+  return SVN_NO_ERROR;
 }
 
+
 static svn_error_t *
 remove_file_props(void *baton,
                   const char *ns,
@@ -478,12 +493,19 @@ remove_file_props(void *baton,
 {
   report_info_t *info = baton;
   const svn_delta_editor_t *editor = info->dir->update_editor;
+  apr_pool_t *scratch_pool = pool;  /* ### fix this  */
+  const char *prop_name;
 
-  return svn_ra_serf__set_baton_props(editor->change_file_prop,
-                                      info->file_baton,
-                                      ns, name, NULL, pool);
+  prop_name = svn_ra_serf__svnname_from_wirename(ns, name, scratch_pool);
+  if (prop_name != NULL)
+    return svn_error_return(editor->change_file_prop(info->file_baton,
+                                                     prop_name,
+                                                     NULL,
+                                                     scratch_pool));
+  return SVN_NO_ERROR;
 }
 
+
 static svn_error_t *
 remove_dir_props(void *baton,
                  const char *ns,
@@ -492,10 +514,17 @@ remove_dir_props(void *baton,
                  apr_pool_t *pool)
 {
   report_dir_t *dir = baton;
-
-  return svn_ra_serf__set_baton_props(dir->update_editor->change_dir_prop,
-                                      dir->dir_baton,
-                                      ns, name, NULL, pool);
+  const svn_delta_editor_t *editor = dir->update_editor;
+  apr_pool_t *scratch_pool = pool;  /* ### fix this  */
+  const char *prop_name;
+
+  prop_name = svn_ra_serf__svnname_from_wirename(ns, name, scratch_pool);
+  if (prop_name != NULL)
+    return svn_error_return(editor->change_dir_prop(dir->dir_baton,
+                                                    prop_name,
+                                                    NULL,
+                                                    scratch_pool));
+  return SVN_NO_ERROR;
 }
 
 



Mime
View raw message