You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2011/07/07 13:29:09 UTC

svn commit: r1143765 - in /subversion/trunk/subversion/libsvn_wc: diff_editor.c diff_local.c merge.c props.c translate.c update_editor.c upgrade.c wc_db.c

Author: julianfoad
Date: Thu Jul  7 11:29:08 2011
New Revision: 1143765

URL: http://svn.apache.org/viewvc?rev=1143765&view=rev
Log:
Use svn_prop_get_value() to simplify low-level property hash queries just a
little, throughout libsvn_wc.

* subversion/libsvn_wc/diff_editor.c
  (get_prop_mimetype): Simplify.

* subversion/libsvn_wc/diff_local.c
  (get_prop_mimetype): Simplify.

* subversion/libsvn_wc/merge.c
  (detranslate_wc_file, svn_wc__internal_merge): Simplify.

* subversion/libsvn_wc/props.c
  (maybe_generate_propconflict): Simplify.

* subversion/libsvn_wc/translate.c
  (svn_wc__get_translate_info): Simplify.

* subversion/libsvn_wc/update_editor.c
  (close_file): Simplify.

* subversion/libsvn_wc/upgrade.c
  (upgrade_externals): Simplify.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_externals_gather_definitions, svn_wc__db_upgrade_apply_props):
    Simplify.

Modified:
    subversion/trunk/subversion/libsvn_wc/diff_editor.c
    subversion/trunk/subversion/libsvn_wc/diff_local.c
    subversion/trunk/subversion/libsvn_wc/merge.c
    subversion/trunk/subversion/libsvn_wc/props.c
    subversion/trunk/subversion/libsvn_wc/translate.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/upgrade.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/libsvn_wc/diff_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/diff_editor.c?rev=1143765&r1=1143764&r2=1143765&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/diff_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/diff_editor.c Thu Jul  7 11:29:08 2011
@@ -481,12 +481,7 @@ get_empty_file(struct edit_baton *b,
 static const char *
 get_prop_mimetype(apr_hash_t *props)
 {
-  const svn_string_t *mimetype_val;
-
-  mimetype_val = apr_hash_get(props,
-                              SVN_PROP_MIME_TYPE,
-                              strlen(SVN_PROP_MIME_TYPE));
-  return (mimetype_val) ? mimetype_val->data : NULL;
+  return svn_prop_get_value(props, SVN_PROP_MIME_TYPE);
 }
 
 

Modified: subversion/trunk/subversion/libsvn_wc/diff_local.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/diff_local.c?rev=1143765&r1=1143764&r2=1143765&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/diff_local.c (original)
+++ subversion/trunk/subversion/libsvn_wc/diff_local.c Thu Jul  7 11:29:08 2011
@@ -113,12 +113,7 @@ get_empty_file(struct diff_baton *eb,
 static const char *
 get_prop_mimetype(apr_hash_t *props)
 {
-  const svn_string_t *mimetype_val;
-
-  mimetype_val = apr_hash_get(props,
-                              SVN_PROP_MIME_TYPE,
-                              strlen(SVN_PROP_MIME_TYPE));
-  return (mimetype_val) ? mimetype_val->data : NULL;
+  return svn_prop_get_value(props, SVN_PROP_MIME_TYPE);
 }
 
 

Modified: subversion/trunk/subversion/libsvn_wc/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/merge.c?rev=1143765&r1=1143764&r2=1143765&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/merge.c (original)
+++ subversion/trunk/subversion/libsvn_wc/merge.c Thu Jul  7 11:29:08 2011
@@ -161,11 +161,10 @@ detranslate_wc_file(const char **detrans
   const char *eol;
   apr_hash_t *keywords;
   svn_boolean_t special;
-  const svn_string_t *mime_value;
-  mime_value = apr_hash_get(mt->actual_props, SVN_PROP_MIME_TYPE,
-                            APR_HASH_KEY_STRING);
+  const char *mime_value = svn_prop_get_value(mt->actual_props,
+                                              SVN_PROP_MIME_TYPE);
 
-  is_binary = (mime_value && svn_mime_type_is_binary(mime_value->data));
+  is_binary = (mime_value && svn_mime_type_is_binary(mime_value));
 
   /* See if we need to do a straight copy:
      - old and new mime-types are binary, or
@@ -1349,11 +1348,10 @@ svn_wc__internal_merge(svn_skel_t **work
     is_binary = svn_mime_type_is_binary(mimeprop->value->data);
   else
     {
-      const svn_string_t *value = apr_hash_get(mt.actual_props,
-                                               SVN_PROP_MIME_TYPE,
-                                               APR_HASH_KEY_STRING);
+      const char *value = svn_prop_get_value(mt.actual_props,
+                                             SVN_PROP_MIME_TYPE);
 
-      is_binary = value && svn_mime_type_is_binary(value->data);
+      is_binary = value && svn_mime_type_is_binary(value);
     }
 
   SVN_ERR(detranslate_wc_file(&detranslated_target_abspath, &mt,

Modified: subversion/trunk/subversion/libsvn_wc/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.c?rev=1143765&r1=1143764&r2=1143765&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Thu Jul  7 11:29:08 2011
@@ -803,7 +803,6 @@ maybe_generate_propconflict(svn_boolean_
                             apr_pool_t *scratch_pool)
 {
   svn_wc_conflict_result_t *result = NULL;
-  svn_string_t *mime_propval = NULL;
   apr_pool_t *filepool = svn_pool_create(scratch_pool);
   svn_wc_conflict_description2_t *cdesc;
   const char *dirpath = svn_dirent_dirname(local_abspath, filepool);
@@ -930,12 +929,10 @@ maybe_generate_propconflict(svn_boolean_
     }
 
   /* Build the rest of the description object: */
-  if (!is_dir && working_props)
-    mime_propval = apr_hash_get(working_props, SVN_PROP_MIME_TYPE,
-                                APR_HASH_KEY_STRING);
-  cdesc->mime_type = mime_propval ? mime_propval->data : NULL;
-  cdesc->is_binary = mime_propval ?
-      svn_mime_type_is_binary(mime_propval->data) : FALSE;
+  cdesc->mime_type = (is_dir ? NULL : svn_prop_get_value(working_props,
+                                                         SVN_PROP_MIME_TYPE));
+  cdesc->is_binary = (cdesc->mime_type
+                      && svn_mime_type_is_binary(cdesc->mime_type));
 
   if (!incoming_old_val && incoming_new_val)
     cdesc->action = svn_wc_conflict_action_add;

Modified: subversion/trunk/subversion/libsvn_wc/translate.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/translate.c?rev=1143765&r1=1143764&r2=1143765&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/translate.c (original)
+++ subversion/trunk/subversion/libsvn_wc/translate.c Thu Jul  7 11:29:08 2011
@@ -263,7 +263,7 @@ svn_wc__get_translate_info(svn_subst_eol
                            apr_pool_t *result_pool,
                            apr_pool_t *scratch_pool)
 {
-  svn_string_t *propval;
+  const char *propval;
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
   if (props == NULL)
@@ -272,29 +272,26 @@ svn_wc__get_translate_info(svn_subst_eol
 
   if (eol)
     {
-      propval = props ? apr_hash_get(props, SVN_PROP_EOL_STYLE,
-                                     APR_HASH_KEY_STRING) : NULL;
+      propval = svn_prop_get_value(props, SVN_PROP_EOL_STYLE);
 
-      svn_subst_eol_style_from_value(style, eol, propval ? propval->data : NULL);
+      svn_subst_eol_style_from_value(style, eol, propval);
     }
 
   if (keywords)
     {
-      propval = props ? apr_hash_get(props, SVN_PROP_KEYWORDS,
-                                     APR_HASH_KEY_STRING) : NULL;
+      propval = svn_prop_get_value(props, SVN_PROP_KEYWORDS);
 
-      if (!propval || propval->len == 0)
+      if (!propval || *propval == '\0')
         *keywords = NULL;
       else
         SVN_ERR(svn_wc__expand_keywords(keywords,
                                         db, local_abspath, NULL,
-                                        propval->data, for_normalization,
+                                        propval, for_normalization,
                                         result_pool, scratch_pool));
     }
   if (special)
     {
-      propval = props ? apr_hash_get(props, SVN_PROP_SPECIAL,
-                                     APR_HASH_KEY_STRING) : NULL;
+      propval = svn_prop_get_value(props, SVN_PROP_SPECIAL);
 
       *special = (propval != NULL);
     }

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1143765&r1=1143764&r2=1143765&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Thu Jul  7 11:29:08 2011
@@ -4331,7 +4331,6 @@ close_file(void *file_baton,
      about files which were already notified for another reason.) */
   if (eb->notify_func && !fb->already_notified && fb->edited)
     {
-      const svn_string_t *mime_type;
       svn_wc_notify_t *notify;
       svn_wc_notify_action_t action = svn_wc_notify_update_update;
 
@@ -4358,12 +4357,8 @@ close_file(void *file_baton,
       notify->old_revision = fb->old_revision;
 
       /* Fetch the mimetype from the actual properties */
-      mime_type = (new_actual_props != NULL)
-                        ? apr_hash_get(new_actual_props, SVN_PROP_MIME_TYPE,
-                                       APR_HASH_KEY_STRING)
-                        : NULL;
-
-      notify->mime_type = mime_type == NULL ? NULL : mime_type->data;
+      notify->mime_type = svn_prop_get_value(new_actual_props,
+                                             SVN_PROP_MIME_TYPE);
 
       eb->notify_func(eb->notify_baton, notify, scratch_pool);
     }

Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=1143765&r1=1143764&r2=1143765&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Thu Jul  7 11:29:08 2011
@@ -1273,16 +1273,14 @@ upgrade_externals(struct bump_baton *bb,
   while (have_row)
     {
       apr_hash_t *props;
-      const svn_string_t *externals = NULL;
+      const char *externals;
 
       svn_pool_clear(iterpool);
 
       SVN_ERR(svn_sqlite__column_properties(&props, stmt, 0,
                                             iterpool, iterpool));
 
-      if (props)
-        externals = apr_hash_get(props, SVN_PROP_EXTERNALS,
-                                 APR_HASH_KEY_STRING);
+      externals = svn_prop_get_value(props, SVN_PROP_EXTERNALS);
 
       if (externals)
         {
@@ -1296,7 +1294,7 @@ upgrade_externals(struct bump_baton *bb,
                                           iterpool);
 
           SVN_ERR(svn_wc_parse_externals_description3(&ext, local_abspath,
-                                                      externals->data, FALSE,
+                                                      externals, FALSE,
                                                       iterpool));
 
           for (i = 0; i < ext->nelts; i++)

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1143765&r1=1143764&r2=1143765&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Jul  7 11:29:08 2011
@@ -3128,7 +3128,7 @@ svn_wc__db_externals_gather_definitions(
   while (have_row)
     {
       apr_hash_t *node_props;
-      const svn_string_t *external_value;
+      const char *external_value;
 
       svn_pool_clear(iterpool);
       err = svn_sqlite__column_properties(&node_props, stmt, 0, iterpool,
@@ -3137,10 +3137,7 @@ svn_wc__db_externals_gather_definitions(
       if (err)
         break;
 
-      external_value = node_props
-                            ? apr_hash_get(node_props, SVN_PROP_EXTERNALS,
-                                           APR_HASH_KEY_STRING)
-                            : NULL;
+      external_value = svn_prop_get_value(node_props, SVN_PROP_EXTERNALS);
 
       if (external_value)
         {
@@ -3150,9 +3147,8 @@ svn_wc__db_externals_gather_definitions(
           node_abspath = svn_dirent_join(wcroot->abspath, node_relpath,
                                          result_pool);
 
-          apr_hash_set(*externals, node_abspath,
-                       APR_HASH_KEY_STRING,
-                       apr_pstrdup(result_pool, external_value->data));
+          apr_hash_set(*externals, node_abspath, APR_HASH_KEY_STRING,
+                       apr_pstrdup(result_pool, external_value));
 
           if (depths)
             {
@@ -9735,15 +9731,13 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
 
   if (kind == svn_wc__db_kind_dir)
     {
-      const svn_string_t *externals = NULL;
+      const char *externals;
       apr_hash_t *props = working_props;
 
       if (props == NULL)
         props = base_props;
 
-      if (props != NULL)
-        externals = apr_hash_get(props, SVN_PROP_EXTERNALS,
-                                 APR_HASH_KEY_STRING);
+      externals = svn_prop_get_value(props, SVN_PROP_EXTERNALS);
 
       if (externals != NULL)
         {
@@ -9755,7 +9749,7 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
           SVN_ERR(svn_wc_parse_externals_description3(
                             &ext, svn_dirent_join(dir_abspath, local_relpath,
                                                   scratch_pool),
-                            externals->data, FALSE, scratch_pool));
+                            externals, FALSE, scratch_pool));
           for (i = 0; i < ext->nelts; i++)
             {
               const svn_wc_external_item2_t *item;