You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2010/08/04 22:45:46 UTC

svn commit: r982397 - in /subversion/trunk/subversion: include/svn_wc.h libsvn_wc/deprecated.c libsvn_wc/props.c

Author: rhuijben
Date: Wed Aug  4 20:45:46 2010
New Revision: 982397

URL: http://svn.apache.org/viewvc?rev=982397&view=rev
Log:
Reintroduce svn_wc_props_modified_p2() to allow cheap access to the wc_db
knowledge about whether properties are modified. Clients like TortoiseSVN
and AnkhSVN will use this or a similar libsvn_client api which will wrap
this api to determine if properties are changed in their status caches.

* subversion/include/svn_wc.h
  (svn_wc_props_modified_p2): New function.
  (svn_wc_props_modified_p): Refer to svn_wc_props_modified_p2 instead
    of a function that retrieves all modified property values.

* subversion/libsvn_wc/deprecated.c
  (svn_wc_props_modified_p): Use svn_wc_props_modified_p2 instead of the
    internal version.

* subversion/libsvn_wc/props.c
  (svn_wc__props_modified): Just fetch the props_modified boolean from
    svn_wc__db_read_info. No need to read the real data as properties not NULL
    in ACTUAL defines that there are property changes.
  (svn_wc_props_modified_p2): New function.

Modified:
    subversion/trunk/subversion/include/svn_wc.h
    subversion/trunk/subversion/libsvn_wc/deprecated.c
    subversion/trunk/subversion/libsvn_wc/props.c

Modified: subversion/trunk/subversion/include/svn_wc.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=982397&r1=982396&r2=982397&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Wed Aug  4 20:45:46 2010
@@ -2709,13 +2709,20 @@ svn_wc_text_modified_p(svn_boolean_t *mo
                        svn_wc_adm_access_t *adm_access,
                        apr_pool_t *pool);
 
-
 /** Set @a *modified_p to non-zero if @a path's properties are modified
  * with regard to the base revision, else set @a modified_p to zero.
  * @a adm_access must be an access baton for @a path.
  *
- * If you want to use this with a post-wc-ng working copy, just call
- * svn_wc_get_prop_diffs2() and examine the output.
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_wc_props_modified_p2(svn_boolean_t *modified_p,
+                         svn_wc_context_t* wc_ctx,
+                         const char *local_abspath,
+                          apr_pool_t *scratch_pool);
+
+/** Similar to svn_wc_props_modified_p2(), but with a relative path and
+ * adm_access baton.
  *
  * @deprecated Provided for backward compatibility with the 1.6 API.
  */

Modified: subversion/trunk/subversion/libsvn_wc/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/deprecated.c?rev=982397&r1=982396&r2=982397&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_wc/deprecated.c Wed Aug  4 20:45:46 2010
@@ -2330,12 +2330,26 @@ svn_wc_props_modified_p(svn_boolean_t *m
                         svn_wc_adm_access_t *adm_access,
                         apr_pool_t *pool)
 {
-  svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
+  svn_wc_context_t *wc_ctx;
   const char *local_abspath;
+  svn_error_t *err;
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
+  SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
+                                         svn_wc__adm_get_db(adm_access), pool));
+
+  err = svn_wc_props_modified_p2(modified_p,
+                                 wc_ctx,
+                                 local_abspath,
+                                 pool);
 
-  return svn_wc__props_modified(modified_p, db, local_abspath, pool);
+  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+    {
+      svn_error_clear(err);
+      *modified_p = FALSE;
+    }
+
+  return svn_error_return(svn_wc_context_destroy(wc_ctx));
 }
 
 

Modified: subversion/trunk/subversion/libsvn_wc/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.c?rev=982397&r1=982396&r2=982397&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Wed Aug  4 20:45:46 2010
@@ -2458,77 +2458,28 @@ svn_wc__props_modified(svn_boolean_t *mo
                        const char *local_abspath,
                        apr_pool_t *scratch_pool)
 {
-  apr_array_header_t *local_propchanges;
-  apr_hash_t *localprops;
-  apr_hash_t *baseprops;
-  svn_wc__db_status_t status;
-  svn_error_t *err;
-
-  err = svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL,
-                             db, local_abspath,
-                             scratch_pool, scratch_pool);
-
-  /* If we have no entry, we can't have any prop mods. */
-  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
-    {
-      *modified_p = FALSE;
-      svn_error_clear(err);
-      return SVN_NO_ERROR;
-    }
-  else if (err)
-    return err;
-
-  SVN_ERR(load_actual_props(&localprops, db, local_abspath,
-                            scratch_pool, scratch_pool));
-  SVN_ERR_ASSERT(localprops != NULL);
-
-  /* ### this should not apply nowadays. especially if
-                            (SVN_WC__VERSION >= SVN_WC__PROPS_IN_DB)  */
-#if 0
-  {
-    svn_boolean_t replaced;
-
-    /* If something is scheduled for replacement, we do *not* want to
-       pay attention to any base-props;  they might be residual from the
-       old deleted file. */
-    /* ### in modern WC formats, they should be the replaced file's
-       ### base props. hard to know on old WCs tho? (given the above
-       ### comment). just declare propmods if the node has any working
-       ### properties. */
-    SVN_ERR(svn_wc__internal_is_replaced(&replaced, db, local_abspath,
-                                         scratch_pool));
-    if (replaced)
-      {
-        *modified_p = apr_hash_count(localprops) > 0;
-        return SVN_NO_ERROR;
-      }
-  }
-#endif
-
-  /* The WORKING props are present, so let's dig in and see what the
-     differences are. On really old WCs, they might be the same. On
-     newer WCs, the file would have been removed if there was no delta. */
-  SVN_ERR(load_pristine_props(&baseprops, db, local_abspath,
-                              scratch_pool, scratch_pool));
-  if (baseprops == NULL)
-    {
-      /* No pristines are defined. Let's say mods exist if there are any
-         ACTUAL props on this node.  */
-      *modified_p = apr_hash_count(localprops) > 0;
-      return SVN_NO_ERROR;
-    }
-
-  SVN_ERR(svn_prop_diffs(&local_propchanges, localprops, baseprops,
-                         scratch_pool));
-
-  *modified_p = (local_propchanges->nelts > 0);
+  SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL, NULL, modified_p,
+                               NULL, NULL, NULL, NULL,
+                               db, local_abspath,
+                               scratch_pool, scratch_pool));
 
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc_props_modified_p2(svn_boolean_t *modified_p,
+                         svn_wc_context_t* wc_ctx,
+                         const char *local_abspath,
+                         apr_pool_t *scratch_pool)
+{
+  return svn_error_return(
+             svn_wc__props_modified(modified_p,
+                                    wc_ctx->db,
+                                    local_abspath,
+                                    scratch_pool));
+}
 
 svn_error_t *
 svn_wc__internal_propdiff(apr_array_header_t **propchanges,



Re: svn commit: r982397 - in /subversion/trunk/subversion: include/svn_wc.h libsvn_wc/deprecated.c libsvn_wc/props.c

Posted by Greg Stein <gs...@gmail.com>.
On Wed, Aug 4, 2010 at 16:45,  <rh...@apache.org> wrote:
>...
> +++ subversion/trunk/subversion/libsvn_wc/deprecated.c Wed Aug  4 20:45:46 2010
> @@ -2330,12 +2330,26 @@ svn_wc_props_modified_p(svn_boolean_t *m
>                         svn_wc_adm_access_t *adm_access,
>                         apr_pool_t *pool)
>  {
> -  svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
> +  svn_wc_context_t *wc_ctx;
>   const char *local_abspath;
> +  svn_error_t *err;
>
>   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
> +  SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
> +                                         svn_wc__adm_get_db(adm_access), pool));
> +
> +  err = svn_wc_props_modified_p2(modified_p,
> +                                 wc_ctx,
> +                                 local_abspath,
> +                                 pool);
>
> -  return svn_wc__props_modified(modified_p, db, local_abspath, pool);
> +  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
> +    {
> +      svn_error_clear(err);
> +      *modified_p = FALSE;
> +    }
> +
> +  return svn_error_return(svn_wc_context_destroy(wc_ctx));

You leak an error here, if it isn't PATH_NOT_FOUND.

This is one of the reasons that I prefer the following pattern:

if (err)
  {
    if (!possible-to-handle)
      return svn_error_return(err);
    handle_error();
    svn_error_clear(err);
  }

The error is always returned or cleared. And quite visibly/readable.

>...

Cheers,
-g