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 2011/05/27 15:42:56 UTC
svn commit: r1128303 - in /subversion/trunk/subversion:
include/private/svn_wc_private.h libsvn_client/externals.c
libsvn_wc/externals.c libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c
libsvn_wc/wc_db.h
Author: rhuijben
Date: Fri May 27 13:42:56 2011
New Revision: 1128303
URL: http://svn.apache.org/viewvc?rev=1128303&view=rev
Log:
Make libsvn_client call the necessary functions to register externals in the
soon to be enabled externals store.
* subversion/include/private/svn_wc_private.h
(svn_wc__externals_defined_below): New function.
(svn_wc__external_register): New function.
* subversion/libsvn_client/externals.c
(svn_wc__externals_defined_below): New function.
(svn_wc__external_register): New function.
* subversion/libsvn_wc/externals.c
(header): Document a temporary define.
(switch_dir_external): Add defining_abspath argument. Register
directory externals after a successfull checkout or switch.
(handle_external_item_change): Use switch_dir_external for checkout
scenarios.
(svn_client__handle_externals): Add test code for using the store instead
of walking the old information. Resolve variable shadowing.
* subversion/libsvn_wc/wc-queries.sql
(STMT_SELECT_EXTERNALS_DEFINED): Redefine as recursive query.
* subversion/libsvn_wc/wc_db.c
(svn_wc__db_external_read): Add missing newline.
(svn_wc__db_externals_defined_below): New function.
* subversion/libsvn_wc/wc_db.h
(svn_wc__db_externals_defined_below): New function.
Modified:
subversion/trunk/subversion/include/private/svn_wc_private.h
subversion/trunk/subversion/libsvn_client/externals.c
subversion/trunk/subversion/libsvn_wc/externals.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/include/private/svn_wc_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_wc_private.h?rev=1128303&r1=1128302&r2=1128303&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Fri May 27 13:42:56 2011
@@ -123,6 +123,51 @@ svn_wc__read_external_info(svn_node_kind
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
+/* Gets a mapping from const char * local abspaths of externals to the const
+ char * local abspath of where they are defined for all externals defined
+ at or below LOCAL_ABSPATH.
+
+ ### Returns NULL in *EXTERNALS until we bumped to format 29.
+
+ Allocate the result in RESULT_POOL and perform temporary allocations in
+ SCRATCH_POOL. */
+svn_error_t *
+svn_wc__externals_defined_below(apr_hash_t **externals,
+ svn_wc_context_t *wc_ctx,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
+
+/* Registers a new external at LOCAL_ABSPATH in the working copy containing
+ DEFINING_ABSPATH.
+
+ The node is registered as defined on DEFINING_ABSPATH (must be an ancestor
+ of LOCAL_ABSPATH) of kind KIND.
+
+ The external is registered as from repository REPOS_ROOT_URL with uuid
+ REPOS_UUID and the defining relative path REPOS_RELPATH.
+
+ If the revision of the node is locked OPERATIONAL_REVISION and REVISION
+ are the peg and normal revision; otherwise their value is
+ SVN_INVALID_REVNUM.
+
+ ### Only KIND svn_node_dir is supported.
+
+ Perform temporary allocations in SCRATCH_POOL.
+ */
+svn_error_t *
+svn_wc__external_register(svn_wc_context_t *wc_ctx,
+ const char *defining_abspath,
+ const char *local_abspath,
+ svn_node_kind_t kind,
+ const char *repos_root_url,
+ const char *repos_uuid,
+ const char *repos_relpath,
+ svn_revnum_t operational_revision,
+ svn_revnum_t revision,
+ apr_pool_t *scratch_pool);
+
/** Set @a *tree_conflict to a newly allocated @c
* svn_wc_conflict_description_t structure describing the tree
Modified: subversion/trunk/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/externals.c?rev=1128303&r1=1128302&r2=1128303&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/externals.c (original)
+++ subversion/trunk/subversion/libsvn_client/externals.c Fri May 27 13:42:56 2011
@@ -42,6 +42,7 @@
#include "svn_private_config.h"
#include "private/svn_wc_private.h"
+/* #define USE_EXTERNALS_STORE */
/* Closure for handle_external_item_change. */
struct external_change_baton_t
@@ -134,6 +135,7 @@ switch_dir_external(const char *local_ab
const char *url,
const svn_opt_revision_t *revision,
const svn_opt_revision_t *peg_revision,
+ const char *defining_abspath,
svn_boolean_t *timestamp_sleep,
svn_client_ctx_t *ctx,
apr_pool_t *pool)
@@ -227,6 +229,31 @@ switch_dir_external(const char *local_ab
timestamp_sleep,
ctx, subpool));
+ {
+ const char *repos_root_url;
+ const char *repos_uuid;
+ const char *repos_relpath;
+
+ SVN_ERR(svn_wc__node_get_repos_info(&repos_root_url,
+ &repos_uuid,
+ ctx->wc_ctx, local_abspath,
+ subpool, subpool));
+
+ SVN_ERR(svn_wc__node_get_repos_relpath(&repos_relpath,
+ ctx->wc_ctx,
+ local_abspath,
+ subpool, subpool));
+
+ SVN_ERR(svn_wc__external_register(ctx->wc_ctx,
+ defining_abspath,
+ local_abspath, svn_node_dir,
+ repos_root_url, repos_uuid,
+ repos_relpath,
+ SVN_INVALID_REVNUM,
+ SVN_INVALID_REVNUM,
+ subpool));
+ }
+
svn_pool_destroy(subpool);
return SVN_NO_ERROR;
}
@@ -260,10 +287,37 @@ switch_dir_external(const char *local_ab
}
/* ... Hello, new hotness. */
- return svn_client__checkout_internal(NULL, url, local_abspath, peg_revision,
- revision, NULL, svn_depth_infinity,
- FALSE, FALSE, TRUE, timestamp_sleep,
- ctx, pool);
+ SVN_ERR(svn_client__checkout_internal(NULL, url, local_abspath, peg_revision,
+ revision, NULL, svn_depth_infinity,
+ FALSE, FALSE, TRUE, timestamp_sleep,
+ ctx, pool));
+
+ {
+ const char *repos_root_url;
+ const char *repos_uuid;
+ const char *repos_relpath;
+
+ SVN_ERR(svn_wc__node_get_repos_info(&repos_root_url,
+ &repos_uuid,
+ ctx->wc_ctx, local_abspath,
+ pool, pool));
+
+ SVN_ERR(svn_wc__node_get_repos_relpath(&repos_relpath,
+ ctx->wc_ctx,
+ local_abspath,
+ pool, pool));
+
+ SVN_ERR(svn_wc__external_register(ctx->wc_ctx,
+ defining_abspath,
+ local_abspath, svn_node_dir,
+ repos_root_url, repos_uuid,
+ repos_relpath,
+ SVN_INVALID_REVNUM,
+ SVN_INVALID_REVNUM,
+ pool));
+ }
+
+ return SVN_NO_ERROR;
}
/* Try to update a file external at LOCAL_ABSPATH to URL at REVISION using a
@@ -904,11 +958,11 @@ handle_external_item_change(const struct
eb->native_eol,
eb->ctx, scratch_pool));
else
- SVN_ERR(svn_client__checkout_internal(
- NULL, new_url, local_abspath,
+ SVN_ERR(switch_dir_external(
+ local_abspath, new_url,
&(new_item->peg_revision), &(new_item->revision),
- &ra_cache, svn_depth_infinity, FALSE, FALSE, TRUE,
- eb->timestamp_sleep, eb->ctx, scratch_pool));
+ parent_abspath, eb->timestamp_sleep, eb->ctx,
+ scratch_pool));
break;
case svn_node_file:
if (eb->is_export)
@@ -965,6 +1019,7 @@ handle_external_item_change(const struct
SVN_ERR(switch_dir_external(local_abspath, new_url,
&(new_item->revision),
&(new_item->peg_revision),
+ parent_dir_abspath,
eb->timestamp_sleep, eb->ctx,
scratch_pool));
break;
@@ -1134,6 +1189,32 @@ svn_client__handle_externals(apr_hash_t
/* Parse the old externals. This part will be replaced by reading EXTERNALS
from the DB. */
+#ifdef USE_EXTERNALS_STORE
+ {
+ apr_hash_t *external_defs;
+ SVN_ERR(svn_wc__externals_defined_below(&external_defs,
+ ctx->wc_ctx, target_abspath,
+ scratch_pool, iterpool));
+
+ for (hi = apr_hash_first(scratch_pool, external_defs);
+ hi;
+ hi = apr_hash_next(hi))
+ {
+ const char *old_url;
+ const char *item_abspath = svn__apr_hash_index_key(hi);
+
+ /* This should be moved into the external processing code once
+ the EXTERNALS store is in place */
+ SVN_ERR(svn_wc__read_external_info(NULL, NULL, &old_url, NULL, NULL,
+ ctx->wc_ctx, target_abspath,
+ item_abspath, FALSE,
+ scratch_pool, iterpool));
+
+ apr_hash_set(old_external_urls, item_abspath,
+ APR_HASH_KEY_STRING, old_url);
+ }
+ }
+#else
if (externals_old)
{
for (hi = apr_hash_first(scratch_pool, externals_old);
@@ -1163,11 +1244,11 @@ svn_client__handle_externals(apr_hash_t
for (i = 0; old_desc && (i < old_desc->nelts); i++)
{
svn_wc_external_item2_t *item;
- const char *target_abspath;
+ const char *item_abspath;
const char *old_url;
item = APR_ARRAY_IDX(old_desc, i, svn_wc_external_item2_t *);
- target_abspath = svn_dirent_join(def_abspath, item->target_dir,
+ item_abspath = svn_dirent_join(def_abspath, item->target_dir,
scratch_pool);
SVN_ERR(resolve_relative_external_url(&old_url, item,
@@ -1175,11 +1256,12 @@ svn_client__handle_externals(apr_hash_t
url, scratch_pool,
iterpool));
- apr_hash_set(old_external_urls, target_abspath,
+ apr_hash_set(old_external_urls, item_abspath,
APR_HASH_KEY_STRING, old_url);
}
}
}
+#endif
for (hi = apr_hash_first(scratch_pool, combined);
hi;
@@ -1225,17 +1307,17 @@ svn_client__handle_externals(apr_hash_t
hi;
hi = apr_hash_next(hi))
{
- const char *target_abspath;
+ const char *item_abspath;
const char *old_url;
svn_pool_clear(iterpool);
- target_abspath = svn__apr_hash_index_key(hi);
+ item_abspath = svn__apr_hash_index_key(hi);
old_url = svn__apr_hash_index_val(hi);
SVN_ERR(wrap_external_error(
- &eb, target_abspath,
- handle_external_item_removal(&eb, target_abspath,
+ &eb, item_abspath,
+ handle_external_item_removal(&eb, item_abspath,
old_url, iterpool),
iterpool));
}
Modified: subversion/trunk/subversion/libsvn_wc/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/externals.c?rev=1128303&r1=1128302&r2=1128303&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/externals.c (original)
+++ subversion/trunk/subversion/libsvn_wc/externals.c Fri May 27 13:42:56 2011
@@ -1070,7 +1070,7 @@ svn_wc__read_external_info(svn_node_kind
if (err)
{
- if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
+ if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND || !ignore_enoent)
return svn_error_return(err);
svn_error_clear(err);
@@ -1145,3 +1145,45 @@ svn_wc__read_external_info(svn_node_kind
return SVN_NO_ERROR;
}
+svn_error_t *
+svn_wc__externals_defined_below(apr_hash_t **externals,
+ svn_wc_context_t *wc_ctx,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ return svn_error_return(
+ svn_wc__db_externals_defined_below(externals,
+ wc_ctx->db, local_abspath,
+ result_pool, scratch_pool));
+}
+
+svn_error_t *
+svn_wc__external_register(svn_wc_context_t *wc_ctx,
+ const char *defining_abspath,
+ const char *local_abspath,
+ svn_node_kind_t kind,
+ const char *repos_root_url,
+ const char *repos_uuid,
+ const char *repos_relpath,
+ svn_revnum_t operational_revision,
+ svn_revnum_t revision,
+ apr_pool_t *scratch_pool)
+{
+ SVN_ERR_ASSERT(kind == svn_node_dir);
+#if SVN_WC__VERSION >= SVN_WC__HAS_EXTERNALS_STORE
+ return svn_error_return(
+ svn_wc__db_external_add_dir(wc_ctx->db, local_abspath,
+ defining_abspath,
+ repos_root_url,
+ repos_uuid,
+ defining_abspath,
+ repos_relpath,
+ operational_revision,
+ revision,
+ NULL,
+ scratch_pool));
+#else
+ return SVN_NO_ERROR;
+#endif
+}
Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1128303&r1=1128302&r2=1128303&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Fri May 27 13:42:56 2011
@@ -904,8 +904,12 @@ SELECT local_relpath
FROM externals WHERE wc_id = ?1 AND parent_relpath = ?2
-- STMT_SELECT_EXTERNALS_DEFINED
-SELECT local_relpath
-FROM externals WHERE wc_id = ?1 AND def_local_relpath = ?2
+SELECT local_relpath, def_local_relpath
+FROM externals
+WHERE wc_id = ?1
+ AND (?2 = ''
+ OR def_local_relpath = ?2
+ OR (def_local_relpath > ?2 || '/' AND def_local_relpath < ?2 || '0'))
-- STMT_UPDATE_EXTERNAL_FILEINFO
UPDATE externals SET recorded_size = ?3, recorded_mod_time = ?4
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1128303&r1=1128302&r2=1128303&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri May 27 13:42:56 2011
@@ -3029,7 +3029,8 @@ svn_wc__db_external_read(svn_wc__db_stat
const char *local_abspath,
const char *wri_abspath,
apr_pool_t *result_pool,
- apr_pool_t *scratch_pool){
+ apr_pool_t *scratch_pool)
+{
svn_wc__db_wcroot_t *wcroot;
const char *local_relpath;
#if SVN_WC__VERSION >= SVN_WC__HAS_EXTERNALS_STORE
@@ -3167,7 +3168,56 @@ svn_wc__db_external_read(svn_wc__db_stat
#endif
}
+svn_error_t *
+svn_wc__db_externals_defined_below(apr_hash_t **externals,
+ svn_wc__db_t *db,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ svn_wc__db_wcroot_t *wcroot;
+ svn_sqlite__stmt_t *stmt;
+ const char *local_relpath;
+#if SVN_WC__VERSION >= SVN_WC__HAS_EXTERNALS_STORE
+ svn_boolean_t have_row;
+#endif
+
+ SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+ SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
+ local_abspath, scratch_pool, scratch_pool));
+ VERIFY_USABLE_WCROOT(wcroot);
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+ STMT_SELECT_EXTERNALS_DEFINED));
+
+ SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+
+#if SVN_WC__VERSION < SVN_WC__HAS_EXTERNALS_STORE
+ *externals = NULL;
+#else
+ *externals = apr_hash_make(result_pool);
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+ while (have_row)
+ {
+ const char *def_local_relpath;
+
+ local_relpath = svn_sqlite__column_text(stmt, 0, NULL);
+ def_local_relpath = svn_sqlite__column_text(stmt, 1, NULL);
+ apr_hash_set(*externals,
+ svn_dirent_join(wcroot->abspath, local_relpath,
+ result_pool),
+ APR_HASH_KEY_STRING,
+ svn_dirent_join(wcroot->abspath, def_local_relpath,
+ result_pool));
+
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+ }
+#endif
+ return svn_error_return(svn_sqlite__reset(stmt));
+}
/* Helper for svn_wc__db_op_copy to handle copying from one db to
another */
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1128303&r1=1128302&r2=1128303&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Fri May 27 13:42:56 2011
@@ -1170,6 +1170,21 @@ svn_wc__db_external_read(svn_wc__db_stat
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
+/* Gets a mapping from const char * local abspaths of externals to the const
+ char * local abspath of where they are defined for all externals defined
+ at or below LOCAL_ABSPATH.
+
+ ### Returns NULL in *EXTERNALS until we bumped to format 29.
+
+ Allocate the result in RESULT_POOL and perform temporary allocations in
+ SCRATCH_POOL. */
+svn_error_t *
+svn_wc__db_externals_defined_below(apr_hash_t **externals,
+ svn_wc__db_t *db,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
/* @} */
/* @defgroup svn_wc__db_op Operations on WORKING tree