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

Re: svn commit: r39542 - trunk/subversion/libsvn_wc

From: Greg Stein <gstein_at_gmail.com>
Date: Thu, 24 Sep 2009 09:13:52 -0400

Does this obsolete svn_wc__db_op_read_tree_conflict ?

On Wed, Sep 23, 2009 at 10:49, Bert Huijben <rhuijben_at_sharpsvn.net> wrote:
> Author: rhuijben
> Date: Wed Sep 23 07:49:47 2009
> New Revision: 39542
>
> Log:
> Add a few db helper functions to work with 'conflict victims'.
>
> * subversion/libsvn_wc/status.c
>  (get_dir_status): Retrieve the list of conflict victims, instead of
>    the tree conflicts.
>
> * subversion/libsvn_wc/wc-queries.sql
>  (STMT_SELECT_ACTUAL_CONFLICT_VICTIMS,
>   STMT_SELECT_ACTUAL_TREE_CONFLICT,
>   STMT_SELECT_CONFLICT_DETAILS): New queries.
>
> * subversion/libsvn_wc/wc_db.c
>  (svn_wc__db_read_conflict_victims): New function.
>  (svn_wc__db_read_conflicts): New function.
>
> * subversion/libsvn_wc/wc_db.h
>  (svn_wc__db_read_conflict_victims): New function.
>  (svn_wc__db_read_conflicts): New function.
>
> Modified:
>   trunk/subversion/libsvn_wc/status.c
>   trunk/subversion/libsvn_wc/wc-queries.sql
>   trunk/subversion/libsvn_wc/wc_db.c
>   trunk/subversion/libsvn_wc/wc_db.h
>
> Modified: trunk/subversion/libsvn_wc/status.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/status.c?pathrev=39542&r1=39541&r2=39542
> ==============================================================================
> --- trunk/subversion/libsvn_wc/status.c Wed Sep 23 05:54:00 2009        (r39541)
> +++ trunk/subversion/libsvn_wc/status.c Wed Sep 23 07:49:47 2009        (r39542)
> @@ -945,7 +945,7 @@ get_dir_status(const struct walk_status_
>  {
>   apr_hash_index_t *hi;
>   const svn_wc_entry_t *dir_entry;
> -  apr_hash_t *dirents, *nodes, *tree_conflicts, *all_children;
> +  apr_hash_t *dirents, *nodes, *conflicts, *all_children;
>   apr_array_header_t *patterns = NULL;
>   apr_pool_t *iterpool, *subpool = svn_pool_create(scratch_pool);
>
> @@ -978,22 +978,20 @@ get_dir_status(const struct walk_status_
>       /* Create a hash containing all children */
>       all_children = apr_hash_overlay(subpool, nodes, dirents);
>
> -      /* ### This creates the tree conflicts with bogus paths.
> -             We can't just push these in the status result! */
> -      SVN_ERR(svn_wc__read_tree_conflicts(&tree_conflicts,
> -                                          dir_entry->tree_conflict_data,
> -                                          "" /* Used for path */, subpool));
> +      SVN_ERR(svn_wc__db_read_conflict_victims(&conflicts,
> +                                               wb->db, local_abspath,
> +                                               subpool, iterpool));
>
>       /* Optimize for the no-tree-conflict case */
> -      if (apr_hash_count(tree_conflicts) > 0)
> -        all_children = apr_hash_overlay(subpool, tree_conflicts, all_children);
> +      if (apr_hash_count(conflicts) > 0)
> +        all_children = apr_hash_overlay(subpool, conflicts, all_children);
>     }
>   else
>     {
>       svn_wc_conflict_description2_t *tc;
>       const char *selected_abspath;
>
> -      tree_conflicts = apr_hash_make(subpool);
> +      conflicts = apr_hash_make(subpool);
>       all_children = apr_hash_make(subpool);
>
>       apr_hash_set(all_children, selected, APR_HASH_KEY_STRING, selected);
> @@ -1005,7 +1003,7 @@ get_dir_status(const struct walk_status_
>
>       /* Note this path if a tree conflict is present.  */
>       if (tc != NULL)
> -        apr_hash_set(tree_conflicts, selected, APR_HASH_KEY_STRING, "");
> +        apr_hash_set(conflicts, selected, APR_HASH_KEY_STRING, "");
>     }
>
>   /* If "this dir" has "svn:externals" property set on it, store the
> @@ -1109,7 +1107,7 @@ get_dir_status(const struct walk_status_
>             }
>         }
>
> -      if (apr_hash_get(tree_conflicts, key, klen))
> +      if (apr_hash_get(conflicts, key, klen))
>         {
>           /* Tree conflict */
>
>
> Modified: trunk/subversion/libsvn_wc/wc-queries.sql
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/wc-queries.sql?pathrev=39542&r1=39541&r2=39542
> ==============================================================================
> --- trunk/subversion/libsvn_wc/wc-queries.sql   Wed Sep 23 05:54:00 2009        (r39541)
> +++ trunk/subversion/libsvn_wc/wc-queries.sql   Wed Sep 23 07:49:47 2009        (r39542)
> @@ -237,6 +237,22 @@ DELETE FROM WORK_QUEUE WHERE id = ?1;
>  INSERT OR IGNORE INTO PRISTINE (checksum, size, refcount)
>  VALUES (?1, ?2, 1);
>
> +-- STMT_SELECT_ACTUAL_CONFLICT_VICTIMS
> +SELECT local_relpath
> +FROM actual_node
> +WHERE wc_id = ?1 AND parent_relpath = ?2 AND
> +NOT((prop_reject IS NULL) AND (conflict_old IS NULL)
> +    AND (conflict_new IS NULL) AND (conflict_working IS NULL))
> +
> +-- STMT_SELECT_ACTUAL_TREE_CONFLICT
> +SELECT tree_conflict_data
> +FROM actual_node
> +WHERE wc_id = ?1 AND local_relpath = ?2;
> +
> +-- STMT_SELECT_CONFLICT_DETAILS
> +SELECT prop_reject, conflict_old, conflict_new, conflict_working
> +FROM actual_node
> +WHERE wc_id = ?1 AND local_relpath = ?2;
>
>  /* ------------------------------------------------------------------------- */
>
>
> Modified: trunk/subversion/libsvn_wc/wc_db.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/wc_db.c?pathrev=39542&r1=39541&r2=39542
> ==============================================================================
> --- trunk/subversion/libsvn_wc/wc_db.c  Wed Sep 23 05:54:00 2009        (r39541)
> +++ trunk/subversion/libsvn_wc/wc_db.c  Wed Sep 23 07:49:47 2009        (r39542)
> @@ -4740,6 +4740,172 @@ svn_wc__db_temp_is_dir_deleted(svn_boole
>   return svn_error_return(svn_sqlite__reset(stmt));
>  }
>
> +svn_error_t *
> +svn_wc__db_read_conflict_victims(apr_hash_t **victims,
> +                                 svn_wc__db_t *db,
> +                                 const char *local_abspath,
> +                                 apr_pool_t *result_pool,
> +                                 apr_pool_t *scratch_pool)
> +{
> +  svn_wc__db_pdh_t *pdh;
> +  const char *local_relpath;
> +  svn_sqlite__stmt_t *stmt;
> +  const char *tree_conflict_data;
> +  svn_boolean_t have_row;
> +
> +  /* The parent should be a working copy directory. */
> +  SVN_ERR(parse_local_abspath(&pdh, &local_relpath, db, local_abspath,
> +                              svn_sqlite__mode_readonly,
> +                              scratch_pool, scratch_pool));
> +  VERIFY_USABLE_PDH(pdh);
> +
> +  /* ### This will be much easier once we have all conflicts in one
> +         field of actual*/
> +
> +  /* First look for text and property conflicts in ACTUAL */
> +  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> +                                    STMT_SELECT_ACTUAL_CONFLICT_VICTIMS));
> +  SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, local_relpath));
> +
> +  *victims = apr_hash_make(result_pool);
> +
> +  SVN_ERR(svn_sqlite__step(&have_row, stmt));
> +  while (have_row)
> +    {
> +      const char *child_relpath = svn_sqlite__column_text(stmt, 0, NULL);
> +      const char *child_name = svn_dirent_basename(child_relpath, result_pool);
> +
> +      apr_hash_set(*victims, child_name, APR_HASH_KEY_STRING, child_name);
> +
> +      SVN_ERR(svn_sqlite__step(&have_row, stmt));
> +    }
> +
> +  SVN_ERR(svn_sqlite__reset(stmt));
> +
> +  /* And add tree conflicts */
> +  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> +                                    STMT_SELECT_ACTUAL_TREE_CONFLICT));
> +  SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, local_relpath));
> +
> +  SVN_ERR(svn_sqlite__step(&have_row, stmt));
> +  if (have_row)
> +    tree_conflict_data = svn_sqlite__column_text(stmt, 0, scratch_pool);
> +  else
> +    tree_conflict_data = NULL;
> +
> +  SVN_ERR(svn_sqlite__reset(stmt));
> +
> +  if (tree_conflict_data)
> +    {
> +      apr_hash_t *conflict_items;
> +      apr_hash_index_t *hi;
> +      SVN_ERR(svn_wc__read_tree_conflicts(&conflict_items, tree_conflict_data,
> +                                          local_abspath, scratch_pool));
> +
> +      for(hi = apr_hash_first(scratch_pool, conflict_items);
> +          hi;
> +          hi = apr_hash_next(hi))
> +        {
> +          const char *child_name =
> +              svn_dirent_basename(svn_apr_hash_index_key(hi), result_pool);
> +
> +          /* Using a hash avoids duplicates */
> +          apr_hash_set(*victims, child_name, APR_HASH_KEY_STRING, child_name);
> +        }
> +    }
> +
> +  return SVN_NO_ERROR;
> +}
> +
> +svn_error_t *
> +svn_wc__db_read_conflicts(const apr_array_header_t **conflicts,
> +                          svn_wc__db_t *db,
> +                          const char *local_abspath,
> +                          apr_pool_t *result_pool,
> +                          apr_pool_t *scratch_pool)
> +{
> +  svn_wc__db_pdh_t *pdh;
> +  const char *local_relpath;
> +  svn_sqlite__stmt_t *stmt;
> +  svn_boolean_t have_row;
> +  apr_array_header_t *cflcts;
> +
> +  /* The parent should be a working copy directory. */
> +  SVN_ERR(parse_local_abspath(&pdh, &local_relpath, db, local_abspath,
> +                              svn_sqlite__mode_readonly,
> +                              scratch_pool, scratch_pool));
> +  VERIFY_USABLE_PDH(pdh);
> +
> +  /* ### This will be much easier once we have all conflicts in one
> +         field of actual.*/
> +
> +  /* First look for text and property conflicts in ACTUAL */
> +  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> +                                    STMT_SELECT_CONFLICT_DETAILS));
> +  SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, local_relpath));
> +
> +  cflcts = apr_array_make(result_pool, 4,
> +                           sizeof(svn_wc_conflict_description2_t*));
> +
> +  SVN_ERR(svn_sqlite__step(&have_row, stmt));
> +
> +  if (have_row)
> +    {
> +      const char *prop_reject;
> +      const char *conflict_old;
> +      const char *conflict_new;
> +      const char *conflict_working;
> +
> +      /* ### Store in description! */
> +      prop_reject = svn_sqlite__column_text(stmt, 0, result_pool);
> +      if (prop_reject)
> +        {
> +          svn_wc_conflict_description2_t *desc;
> +
> +          desc  = svn_wc_conflict_description_create_prop2(local_abspath,
> +                                                           svn_node_unknown,
> +                                                       "svn:pre-WC-NG-Compat",
> +                                                           result_pool);
> +
> +          APR_ARRAY_PUSH(cflcts, svn_wc_conflict_description2_t*) = desc;
> +        }
> +
> +      conflict_old = svn_sqlite__column_text(stmt, 1, result_pool);
> +      conflict_new = svn_sqlite__column_text(stmt, 2, result_pool);
> +      conflict_working = svn_sqlite__column_text(stmt, 3, result_pool);
> +
> +      if (conflict_old || conflict_new || conflict_working)
> +        {
> +          svn_wc_conflict_description2_t *desc
> +              = svn_wc_conflict_description_create_text2(local_abspath,
> +                                                         result_pool);
> +
> +          desc->base_file = conflict_old;
> +          desc->their_file = conflict_new;
> +          desc->my_file = conflict_working;
> +          desc->merged_file = svn_dirent_basename(local_abspath, result_pool);
> +
> +          APR_ARRAY_PUSH(cflcts, svn_wc_conflict_description2_t*) = desc;
> +        }
> +    }
> +
> +  /* ### Tree conflicts are still stored on the directory */
> +  {
> +    svn_wc_conflict_description2_t *desc;
> +
> +    SVN_ERR(svn_wc__db_op_read_tree_conflict(&desc,
> +                                             db, local_abspath,
> +                                             result_pool, scratch_pool));
> +
> +    if (desc)
> +      APR_ARRAY_PUSH(cflcts, svn_wc_conflict_description2_t*) = desc;
> +  }
> +
> +  *conflicts = cflcts;
> +
> +  return SVN_NO_ERROR;
> +}
> +
>
>  svn_error_t *
>  svn_wc__db_read_kind(svn_wc__db_kind_t *kind,
>
> Modified: trunk/subversion/libsvn_wc/wc_db.h
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/wc_db.h?pathrev=39542&r1=39541&r2=39542
> ==============================================================================
> --- trunk/subversion/libsvn_wc/wc_db.h  Wed Sep 23 05:54:00 2009        (r39541)
> +++ trunk/subversion/libsvn_wc/wc_db.h  Wed Sep 23 07:49:47 2009        (r39542)
> @@ -1267,6 +1267,38 @@ svn_wc__db_read_children(const apr_array
>                          apr_pool_t *result_pool,
>                          apr_pool_t *scratch_pool);
>
> +/* Read into *VICTIMS the basenames of the immediate children of
> +   LOCAL_ABSPATH in DB that are conflicted.
> +
> +   In case of tree conflicts a victim doesn't have to be in the
> +   working copy.
> +
> +   Allocate *VICTIMS in RESULT_POOL and do temporary allocations in
> +   SCRATCH_POOL */
> +/* ### Use apr_array_header_t? */
> +svn_error_t *
> +svn_wc__db_read_conflict_victims(apr_hash_t **victims,
> +                                 svn_wc__db_t *db,
> +                                 const char *local_abspath,
> +                                 apr_pool_t *result_pool,
> +                                 apr_pool_t *scratch_pool);
> +
> +/* Read into CONFLICTS svn_wc_conflict_description2_t* structs
> +   for all conflicts that have LOCAL_ABSPATH as victim.
> +
> +   Victim must be versioned or be part of a tree conflict.
> +
> +   Allocate *VICTIMS in RESULT_POOL and do temporary allocations in
> +   SCRATCH_POOL */
> +/* ### Currently there can be just one property conflict recorded
> +       per victim */
> +svn_error_t *
> +svn_wc__db_read_conflicts(const apr_array_header_t **conflicts,
> +                          svn_wc__db_t *db,
> +                          const char *local_abspath,
> +                          apr_pool_t *result_pool,
> +                          apr_pool_t *scratch_pool);
> +
>
>  /* Return the kind of the node in DB at LOCAL_ABSPATH. The WORKING tree will
>    be examined first, then the BASE tree. If the node is not present in either
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=2398924
>

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2399277
Received on 2009-09-24 15:14:15 CEST

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.