> -----Original Message-----
> From: dan...@apache.org [mailto:dan...@apache.org]
> Sent: vrijdag 12 maart 2010 9:22
> To: comm...@subversion.apache.org
> Subject: svn commit: r922176 - in /subversion/trunk/subversion:
> include/svn_wc.h libsvn_wc/revision_status.c svnversion/main.c
> 
> Author: dannas
> Date: Fri Mar 12 08:21:45 2010
> New Revision: 922176
> 
> URL: http://svn.apache.org/viewvc?rev=922176&view=rev
> Log:
> As part of WC-NG, remove some uses of svn_wc_entry_t.
> 
> * subversion/include/svn_wc.h
>   (svn_wc_revision_status2): Add note about us returning
>     SVN_ERR_WC_PATH_NOT_FOUND.
> * subversion/libsvn_wc/revision_status.c
>    (status_baton): Rename this...
>    (walk_baton): .. to this.
>    (analyze_status): Change this to implement svn_wc__node_func_t and use
>      WC-NG funcs instead of information in svn_wc_entry_t.
>    (svn_wc_revision_status2): Use svn_wc__node_walk_children() instead of
>      svn_wc_walk_status() to spare us from the overhead of invoking an
>      editor.
> * subversion/svnversion/main.c
>   (main): Determine if a path is unversioned by checking for
>     SVN_ERR_WC_PATH_NOT_FOUND.
> 
> Approved by: gstein
> 
> Modified:
>     subversion/trunk/subversion/include/svn_wc.h
>     subversion/trunk/subversion/libsvn_wc/revision_status.c
>     subversion/trunk/subversion/svnversion/main.c
> 
> Modified: subversion/trunk/subversion/include/svn_wc.h
> URL:
> http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc
> .h?rev=922176&r1=922175&r2=922176&view=diff
> ==========================================================
> ====================
> --- subversion/trunk/subversion/include/svn_wc.h (original)
> +++ subversion/trunk/subversion/include/svn_wc.h Fri Mar 12 08:21:45 2010
> @@ -7192,7 +7192,8 @@ typedef struct svn_wc_revision_status_t
>  /** Set @a *result_p to point to a new #svn_wc_revision_status_t structure
>   * containing a summary of the revision range and status of the working copy
>   * at @a local_abspath (not including "externals").  @a local_abspath must
> - * be absolute.
> + * be absolute. Return SVN_ERR_WC_PATH_NOT_FOUND if @a
> local_abspath is not
> + * a working copy path.
>   *
>   * Set @a (*result_p)->min_rev and @a (*result_p)->max_rev respectively
> to the
>   * lowest and highest revision numbers in the working copy.  If @a
> committed
> 
> Modified: subversion/trunk/subversion/libsvn_wc/revision_status.c
> URL:
> http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/revis
> ion_status.c?rev=922176&r1=922175&r2=922176&view=diff
> ==========================================================
> ====================
> --- subversion/trunk/subversion/libsvn_wc/revision_status.c (original)
> +++ subversion/trunk/subversion/libsvn_wc/revision_status.c Fri Mar 12
> 08:21:45 2010
> @@ -23,65 +23,100 @@
> 
>  #include "svn_wc.h"
>  #include "svn_dirent_uri.h"
> +#include "wc_db.h"
> +#include "wc.h"
> +#include "props.h"
> 
>  #include "private/svn_wc_private.h"
> 
>  #include "svn_private_config.h"
> 
>  /* A baton for analyze_status(). */
> -struct status_baton
> +struct walk_baton
>  {
>    svn_wc_revision_status_t *result;           /* where to put the result */
>    svn_boolean_t committed;           /* examine last committed revisions */
>    const char *local_abspath;         /* path whose URL we're looking for */
> -  const char *wc_url;    /* URL for the path whose URL we're looking for */
> -  apr_pool_t *pool;         /* pool in which to store alloc-needy things */
> +  svn_wc__db_t *db;
>  };
> 
> -/* An svn_wc_status_func4_t callback function for analyzing status
> -   structures. */
> +/* An svn_wc__node_found_func_t callback function for analyzing the
> status
> + * of nodes */
>  static svn_error_t *
> -analyze_status(void *baton,
> -               const char *local_abspath,
> -               const svn_wc_status2_t *status,
> -               apr_pool_t *pool)
> +analyze_status(const char *local_abspath,
> +               void *baton,
> +               apr_pool_t *scratch_pool)
>  {
> -  struct status_baton *sb = baton;
> +  struct walk_baton *wb = baton;
> +  svn_revnum_t changed_rev;
> +  svn_revnum_t revision;
> +  svn_depth_t depth;
> +  svn_wc__db_status_t status;
> +  svn_boolean_t wc_root;
> +  svn_boolean_t switched;
> +
> +  SVN_ERR(svn_wc__db_read_info(&status, NULL, &revision, NULL,
> +                               NULL, NULL, &changed_rev,
> +                               NULL, NULL, NULL, &depth, NULL, NULL, NULL,
> +                               NULL, NULL, NULL, NULL, NULL, NULL,
> +                               NULL, NULL, NULL, NULL, wb->db,
> +                               local_abspath, scratch_pool, scratch_pool));
> +
> +  /* We need the excluded and absent paths when checking for sparse
> +   * checkouts. But only for that. To collect those we're walking all the
> +   * hidden nodes. */
> +  if (status == svn_wc__db_status_excluded
> +      || status == svn_wc__db_status_absent)
> +    {
> +      wb->result->sparse_checkout = TRUE;
> +      return SVN_NO_ERROR;
> +    }
> 
> -  if (! status->entry)
> +  if (status == svn_wc__db_status_not_present)
>      return SVN_NO_ERROR;
> 
> -  /* Added files have a revision of no interest */
> -  if (status->text_status != svn_wc_status_added)
> +  if (! wb->result->switched)
>      {
> -      svn_revnum_t item_rev = (sb->committed
> -                               ? status->entry->cmt_rev
> -                               : status->entry->revision);
> -
> -      if (sb->result->min_rev == SVN_INVALID_REVNUM
> -          || item_rev < sb->result->min_rev)
> -        sb->result->min_rev = item_rev;
> -
> -      if (sb->result->max_rev == SVN_INVALID_REVNUM
> -          || item_rev > sb->result->max_rev)
> -        sb->result->max_rev = item_rev;
> +      SVN_ERR(svn_wc__check_wc_root(&wc_root, NULL, &switched, wb-
> >db,
> +                                    local_abspath, scratch_pool));
> +
> +      wb->result->switched |= switched;
>      }
> 
> -  if (status->entry->depth != svn_depth_exclude)
> +  /* Added files have a revision of no interest */
> +  if (revision != SVN_INVALID_REVNUM)
>      {
> -      sb->result->switched |= status->switched;
> -      sb->result->modified |= (status->text_status != svn_wc_status_normal);
> -      sb->result->modified |= (status->prop_status != svn_wc_status_normal
> -                               && status->prop_status != svn_wc_status_none);
> +      svn_revnum_t item_rev = (wb->committed
> +                               ? changed_rev
> +                               : revision);
> +
> +      if (wb->result->min_rev == SVN_INVALID_REVNUM
> +          || item_rev < wb->result->min_rev)
> +        wb->result->min_rev = item_rev;
> +
> +      if (wb->result->max_rev == SVN_INVALID_REVNUM
> +          || item_rev > wb->result->max_rev)
> +        wb->result->max_rev = item_rev;
>      }

Added files imply that there is some modification, so you can just set 
wb->result->modified to TRUE as an else clause.

> -  sb->result->sparse_checkout |= (status->entry->depth !=
> svn_depth_infinity);
> 
> -  if (sb->local_abspath
> -      && (! sb->wc_url)
> -      && (strcmp(local_abspath, sb->local_abspath) == 0)
> -      && (status->entry))
> -    sb->wc_url = apr_pstrdup(sb->pool, status->entry->url);
> +  if (! wb->result->modified)
> +    {
> +      svn_boolean_t text_mod;
> +      svn_boolean_t props_mod;
> 
> +      SVN_ERR(svn_wc__props_modified(&props_mod, wb->db,
> local_abspath,
> +                                     scratch_pool));
> +
> +      SVN_ERR(svn_wc__internal_text_modified_p(&text_mod, wb->db,
> +                                               local_abspath,
> +                                               FALSE,
> +                                               TRUE,
> +                                               scratch_pool));
> +      wb->result->modified |= (text_mod || props_mod);
> +    }

With the risk of over optimizing: no need to perform a text check when you 
already see a property modification.

Note that '|=' is a bitwise or and '||' is a logical or. I usually recommend 
not to use both of them in one expression.

But further: nice cleanup :)

        Bert

Reply via email to