Author: rhuijben
Date: Tue Feb 24 17:13:02 2015
New Revision: 1662030
URL: http://svn.apache.org/r1662030
Log:
Make 'svn info' return its WC results in a stable order, by making
the db funtion that returns these paths provide an array instead
of an hash. Info is the only function using this db operation.
Found by: brane
* subversion/libsvn_wc/wc_db.h
(svn_wc__db_read_single_info): Add name.
(svn_wc__db_read_children_walker_info): Change return type.
* subversion/libsvn_wc/wc_db.c
(svn_wc__db_read_children_walker_info): Create array instead of hash.
Add name to item.
* subversion/libsvn_wc/wc-queries.sql
(STMT_SELECT_NODE_CHILDREN_WALKER_INFO): Request stable ordering,
which we get by default (as that is how the parent index works).
* subversion/libsvn_wc/node.c
(walker_helper): Update caller.
Modified:
subversion/trunk/subversion/libsvn_wc/node.c
subversion/trunk/subversion/libsvn_wc/wc-queries.sql
subversion/trunk/subversion/libsvn_wc/wc_db.c
subversion/trunk/subversion/libsvn_wc/wc_db.h
Modified: subversion/trunk/subversion/libsvn_wc/node.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/node.c?rev=1662030&r1=1662029&r2=1662030&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/node.c (original)
+++ subversion/trunk/subversion/libsvn_wc/node.c Tue Feb 24 17:13:02 2015
@@ -50,6 +50,7 @@
#include "wc_db.h"
#include "svn_private_config.h"
+#include "private/svn_sorts_private.h"
#include "private/svn_wc_private.h"
@@ -260,25 +261,24 @@ walker_helper(svn_wc__db_t *db,
void *cancel_baton,
apr_pool_t *scratch_pool)
{
- apr_hash_t *rel_children_info;
- apr_hash_index_t *hi;
apr_pool_t *iterpool;
+ apr_array_header_t *items;
+ int i;
if (depth == svn_depth_empty)
return SVN_NO_ERROR;
- SVN_ERR(svn_wc__db_read_children_walker_info(&rel_children_info, db,
- dir_abspath, scratch_pool,
- scratch_pool));
+ iterpool = svn_pool_create(scratch_pool);
+ SVN_ERR(svn_wc__db_read_children_walker_info(&items, db,
+ dir_abspath, scratch_pool,
+ iterpool));
- iterpool = svn_pool_create(scratch_pool);
- for (hi = apr_hash_first(scratch_pool, rel_children_info);
- hi;
- hi = apr_hash_next(hi))
+ for (i = 0; i < items->nelts; i++)
{
- const char *child_name = apr_hash_this_key(hi);
- struct svn_wc__db_walker_info_t *wi = apr_hash_this_val(hi);
+ struct svn_wc__db_walker_info_t *wi =
+ APR_ARRAY_IDX(items, i, struct svn_wc__db_walker_info_t *);
+ const char *child_name = wi->name;
svn_node_kind_t child_kind = wi->kind;
svn_wc__db_status_t child_status = wi->status;
const char *child_abspath;
Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1662030&r1=1662029&r2=1662030&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Tue Feb 24 17:13:02
2015
@@ -156,6 +156,7 @@ ORDER BY local_relpath DESC
SELECT local_relpath, op_depth, presence, kind
FROM nodes_current
WHERE wc_id = ?1 AND parent_relpath = ?2
+ORDER BY local_relpath
-- STMT_SELECT_ACTUAL_CHILDREN_INFO
SELECT local_relpath, changelist, properties, conflict_data
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1662030&r1=1662029&r2=1662030&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Feb 24 17:13:02 2015
@@ -9785,7 +9785,7 @@ svn_wc__db_read_pristine_info(svn_wc__db
}
svn_error_t *
-svn_wc__db_read_children_walker_info(apr_hash_t **nodes,
+svn_wc__db_read_children_walker_info(const apr_array_header_t **items,
svn_wc__db_t *db,
const char *dir_abspath,
apr_pool_t *result_pool,
@@ -9795,6 +9795,7 @@ svn_wc__db_read_children_walker_info(apr
const char *dir_relpath;
svn_sqlite__stmt_t *stmt;
svn_boolean_t have_row;
+ apr_array_header_t *nodes;
SVN_ERR_ASSERT(svn_dirent_is_absolute(dir_abspath));
@@ -9808,16 +9809,18 @@ svn_wc__db_read_children_walker_info(apr
SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, dir_relpath));
SVN_ERR(svn_sqlite__step(&have_row, stmt));
- *nodes = apr_hash_make(result_pool);
+ nodes = apr_array_make(result_pool, 16,
+ sizeof(struct svn_wc__db_walker_info_t *));
while (have_row)
{
struct svn_wc__db_walker_info_t *child;
const char *child_relpath = svn_sqlite__column_text(stmt, 0, NULL);
- const char *name = svn_relpath_basename(child_relpath, NULL);
+ const char *name = svn_relpath_basename(child_relpath, result_pool);
int op_depth = svn_sqlite__column_int(stmt, 1);
svn_error_t *err;
child = apr_palloc(result_pool, sizeof(*child));
+ child->name = name;
child->status = svn_sqlite__column_token(stmt, 2, presence_map);
if (op_depth > 0)
{
@@ -9826,13 +9829,16 @@ svn_wc__db_read_children_walker_info(apr
SVN_ERR(svn_error_compose_create(err, svn_sqlite__reset(stmt)));
}
child->kind = svn_sqlite__column_token(stmt, 3, kind_map);
- svn_hash_sets(*nodes, apr_pstrdup(result_pool, name), child);
+
+ APR_ARRAY_PUSH(nodes, struct svn_wc__db_walker_info_t *) = child;
SVN_ERR(svn_sqlite__step(&have_row, stmt));
}
SVN_ERR(svn_sqlite__reset(stmt));
+ *items = nodes;
+
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1662030&r1=1662029&r2=1662030&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Tue Feb 24 17:13:02 2015
@@ -2057,6 +2057,7 @@ svn_wc__db_read_single_info(const struct
/* Structure returned by svn_wc__db_read_walker_info. Only has the
fields needed by svn_wc__internal_walk_children(). */
struct svn_wc__db_walker_info_t {
+ const char *name;
svn_wc__db_status_t status;
svn_node_kind_t kind;
};
@@ -2117,11 +2118,10 @@ svn_wc__db_read_node_install_info(const
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
-/* Return in *NODES a hash mapping name->struct svn_wc__db_walker_info_t for
- the children of DIR_ABSPATH. "name" is the child's name relative to
- DIR_ABSPATH, not an absolute path. */
+/* Return in *ITEMS an array of struct svn_wc__db_walker_info_t* for
+ the direct children of DIR_ABSPATH. */
svn_error_t *
-svn_wc__db_read_children_walker_info(apr_hash_t **nodes,
+svn_wc__db_read_children_walker_info(const apr_array_header_t **items,
svn_wc__db_t *db,
const char *dir_abspath,
apr_pool_t *result_pool,