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