Author: julianfoad
Date: Mon Oct 10 13:08:39 2011
New Revision: 1180936
URL: http://svn.apache.org/viewvc?rev=1180936&view=rev
Log:
On the 'tree-read-api' branch: Tweak the tree API, and implement the WC-base
and WC-working implementations of it (incompletely).
* subversion/libsvn_client/tree.h
(svn_client__disk_tree): Remove the unused 'editor' parameter.
(svn_client__wc_base_tree, svn_client__wc_working_tree): Remove the
unused 'editor' parameter, require an abspath, add a client context
parameter.
* subversion/libsvn_client/tree.c
(disk_tree_get_file, disk_tree_get_dir, disk_tree_get_symlink): Create an
empty hash if props are requested, as NULL is not allowed.
(wc_tree_baton_t, wc_tree_vtable): New structs.
(wc_tree_get_kind, wc_tree_get_file, wc_tree_get_dir, wc_tree_get_symlink):
New functions.
(svn_client__wc_base_tree, svn_client__wc_working_tree): Implement.
(read_ra_tree, svn_client__repository_tree): Remove an unused parameter.
Modified:
subversion/branches/tree-read-api/subversion/libsvn_client/tree.c
subversion/branches/tree-read-api/subversion/libsvn_client/tree.h
Modified: subversion/branches/tree-read-api/subversion/libsvn_client/tree.c
URL:
http://svn.apache.org/viewvc/subversion/branches/tree-read-api/subversion/libsvn_client/tree.c?rev=1180936&r1=1180935&r2=1180936&view=diff
==============================================================================
--- subversion/branches/tree-read-api/subversion/libsvn_client/tree.c (original)
+++ subversion/branches/tree-read-api/subversion/libsvn_client/tree.c Mon Oct
10 13:08:39 2011
@@ -150,7 +150,7 @@ disk_tree_get_file(svn_client_tree_t *tr
SVN_ERR(svn_stream_open_readonly(stream, abspath,
result_pool, scratch_pool));
if (props)
- *props = NULL;
+ *props = apr_hash_make(result_pool);
return SVN_NO_ERROR;
}
@@ -174,7 +174,7 @@ disk_tree_get_dir(svn_client_tree_t *tre
result_pool, scratch_pool));
}
if (props)
- *props = NULL;
+ *props = apr_hash_make(result_pool);
return SVN_NO_ERROR;
}
@@ -199,7 +199,7 @@ disk_tree_get_symlink(svn_client_tree_t
*link_target = dest->data;
}
if (props)
- *props = NULL;
+ *props = apr_hash_make(result_pool);
return SVN_NO_ERROR;
}
@@ -216,7 +216,6 @@ static const svn_client_tree__vtable_t d
svn_error_t *
svn_client__disk_tree(svn_client_tree_t **tree_p,
const char *abspath,
- svn_delta_editor_t *editor,
apr_pool_t *result_pool)
{
svn_client_tree_t *tree = apr_palloc(result_pool, sizeof(*tree));
@@ -235,13 +234,158 @@ svn_client__disk_tree(svn_client_tree_t
/*-----------------------------------------------------------------*/
+/* */
+typedef struct wc_tree_baton_t
+{
+ const char *tree_abspath;
+ svn_wc_context_t *wc_ctx;
+ svn_boolean_t is_base; /* true -> base, false -> working */
+} wc_tree_baton_t;
+
+/* */
+static svn_error_t *
+wc_tree_get_kind(svn_client_tree_t *tree,
+ svn_kind_t *kind,
+ const char *relpath,
+ apr_pool_t *scratch_pool)
+{
+ wc_tree_baton_t *baton = tree->priv;
+ const char *abspath = svn_dirent_join(baton->tree_abspath, relpath,
+ scratch_pool);
+
+ if (baton->is_base)
+ {
+ /* ###
+ * SVN_ERR(svn_wc_read_base_kind(kind, baton->wc_ctx, abspath,
+ * scratch_pool));
+ */
+ }
+ else
+ SVN_ERR(svn_wc_read_kind2(kind, baton->wc_ctx, abspath,
+ FALSE /* show_hidden */, scratch_pool));
+ return SVN_NO_ERROR;
+}
+
+/* */
+static svn_error_t *
+wc_tree_get_file(svn_client_tree_t *tree,
+ svn_stream_t **stream,
+ apr_hash_t **props,
+ const char *relpath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ wc_tree_baton_t *baton = tree->priv;
+ const char *abspath = svn_dirent_join(baton->tree_abspath, relpath,
+ scratch_pool);
+
+ if (stream)
+ {
+ if (baton->is_base)
+ SVN_ERR(svn_wc_get_pristine_contents2(stream, baton->wc_ctx, abspath,
+ result_pool, scratch_pool));
+ else
+ SVN_ERR(svn_stream_open_readonly(stream, abspath,
+ result_pool, scratch_pool));
+ }
+ if (props)
+ {
+ if (baton->is_base)
+ SVN_ERR(svn_wc_get_pristine_props(props, baton->wc_ctx, abspath,
+ result_pool, scratch_pool));
+ else
+ SVN_ERR(svn_wc_prop_list2(props, baton->wc_ctx, abspath,
+ result_pool, scratch_pool));
+ }
+
+ return SVN_NO_ERROR;
+}
+
+/* */
+static svn_error_t *
+wc_tree_get_dir(svn_client_tree_t *tree,
+ apr_hash_t **dirents,
+ apr_hash_t **props,
+ const char *relpath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ wc_tree_baton_t *baton = tree->priv;
+ const char *abspath = svn_dirent_join(baton->tree_abspath, relpath,
+ scratch_pool);
+
+ if (dirents)
+ {
+ *dirents = apr_hash_make(result_pool); /* ### */
+ }
+ if (props)
+ {
+ if (baton->is_base)
+ SVN_ERR(svn_wc_get_pristine_props(props, baton->wc_ctx, abspath,
+ result_pool, scratch_pool));
+ else
+ SVN_ERR(svn_wc_prop_list2(props, baton->wc_ctx, abspath,
+ result_pool, scratch_pool));
+ }
+
+ return SVN_NO_ERROR;
+}
+
+/* */
+static svn_error_t *
+wc_tree_get_symlink(svn_client_tree_t *tree,
+ const char **link_target,
+ apr_hash_t **props,
+ const char *relpath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ wc_tree_baton_t *baton = tree->priv;
+ const char *abspath = svn_dirent_join(baton->tree_abspath, relpath,
+ scratch_pool);
+
+ if (link_target)
+ {
+ *link_target = ""; /* ### */
+ }
+ if (props)
+ {
+ if (baton->is_base)
+ SVN_ERR(svn_wc_get_pristine_props(props, baton->wc_ctx, abspath,
+ result_pool, scratch_pool));
+ else
+ SVN_ERR(svn_wc_prop_list2(props, baton->wc_ctx, abspath,
+ result_pool, scratch_pool));
+ }
+
+ return SVN_NO_ERROR;
+}
+
+/* */
+static const svn_client_tree__vtable_t wc_tree_vtable =
+{
+ wc_tree_get_kind,
+ wc_tree_get_file,
+ wc_tree_get_dir,
+ wc_tree_get_symlink
+};
+
svn_error_t *
svn_client__wc_base_tree(svn_client_tree_t **tree_p,
- const char *path,
- svn_delta_editor_t *editor,
+ const char *abspath,
+ svn_client_ctx_t *ctx,
apr_pool_t *result_pool)
{
svn_client_tree_t *tree = apr_pcalloc(result_pool, sizeof(*tree));
+ wc_tree_baton_t *baton = apr_palloc(result_pool, sizeof(*baton));
+
+ baton->tree_abspath = abspath;
+ baton->wc_ctx = ctx->wc_ctx;
+ baton->is_base = TRUE;
+
+ tree->vtable = &wc_tree_vtable;
+ tree->pool = result_pool;
+ tree->priv = baton;
*tree_p = tree;
return SVN_NO_ERROR;
@@ -249,11 +393,20 @@ svn_client__wc_base_tree(svn_client_tree
svn_error_t *
svn_client__wc_working_tree(svn_client_tree_t **tree_p,
- const char *path,
- svn_delta_editor_t *editor,
+ const char *abspath,
+ svn_client_ctx_t *ctx,
apr_pool_t *result_pool)
{
svn_client_tree_t *tree = apr_pcalloc(result_pool, sizeof(*tree));
+ wc_tree_baton_t *baton = apr_palloc(result_pool, sizeof(*baton));
+
+ baton->tree_abspath = abspath;
+ baton->wc_ctx = ctx->wc_ctx;
+ baton->is_base = FALSE;
+
+ tree->vtable = &wc_tree_vtable;
+ tree->pool = result_pool;
+ tree->priv = baton;
*tree_p = tree;
return SVN_NO_ERROR;
@@ -375,7 +528,6 @@ static svn_error_t *
read_ra_tree(svn_client_tree_t **tree_p,
svn_ra_session_t *ra_session,
svn_revnum_t revnum,
- svn_client_ctx_t *ctx,
apr_pool_t *result_pool)
{
svn_client_tree_t *tree = apr_pcalloc(result_pool, sizeof(*tree));
@@ -410,8 +562,7 @@ svn_client__repository_tree(svn_client_t
peg_revision, revision,
ctx, result_pool));
- SVN_ERR(read_ra_tree(tree_p, ra_session, revnum,
- ctx, result_pool));
+ SVN_ERR(read_ra_tree(tree_p, ra_session, revnum, result_pool));
return SVN_NO_ERROR;
}
Modified: subversion/branches/tree-read-api/subversion/libsvn_client/tree.h
URL:
http://svn.apache.org/viewvc/subversion/branches/tree-read-api/subversion/libsvn_client/tree.h?rev=1180936&r1=1180935&r2=1180936&view=diff
==============================================================================
--- subversion/branches/tree-read-api/subversion/libsvn_client/tree.h (original)
+++ subversion/branches/tree-read-api/subversion/libsvn_client/tree.h Mon Oct
10 13:08:39 2011
@@ -148,21 +148,20 @@ svn_tree_get_symlink(svn_client_tree_t *
svn_error_t *
svn_client__disk_tree(svn_client_tree_t **tree_p,
const char *abspath,
- svn_delta_editor_t *editor,
apr_pool_t *result_pool);
/* */
svn_error_t *
svn_client__wc_base_tree(svn_client_tree_t **tree_p,
- const char *path,
- svn_delta_editor_t *editor,
+ const char *abspath,
+ svn_client_ctx_t *ctx,
apr_pool_t *result_pool);
/* */
svn_error_t *
svn_client__wc_working_tree(svn_client_tree_t **tree_p,
- const char *path,
- svn_delta_editor_t *editor,
+ const char *abspath,
+ svn_client_ctx_t *ctx,
apr_pool_t *result_pool);
/* */