You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2011/10/10 11:38:24 UTC
svn commit: r1180843 - in
/subversion/branches/tree-read-api/subversion/libsvn_client: tree.c tree.h
Author: julianfoad
Date: Mon Oct 10 09:38:23 2011
New Revision: 1180843
URL: http://svn.apache.org/viewvc?rev=1180843&view=rev
Log:
On the 'tree-read-api' branch: Make the 'svn_client_tree_t' API a
hidden-vtable style with public functions, and make symlinks a first-class
object in the API. Remove the ill-conceived 'push_to_delta_editor' method.
Update to use the newly introduced 'svn_kind_t' which supports symlinks
instead of 'svn_node_kind_t'.
* subversion/libsvn_client/tree.h
(svn_client_tree__vtable_t): Move the structure definition to 'tree.c',
leaving only the typedef here.
(svn_tree_get_kind, svn_tree_get_file, svn_tree_get_dir,
svn_tree_get_symlink): New functions.
* subversion/libsvn_client/tree.c
(svn_client_tree__vtable_t): Move from 'tree.h'; add symlink handling;
remove push_to_delta_editor.
(svn_tree_get_kind, svn_tree_get_file, svn_tree_get_dir,
svn_tree_get_symlink): New functions.
(disk_tree_get_kind, ra_tree_get_kind): Update to use 'svn_kind_t'.
(disk_tree_get_symlink, ra_tree_get_symlink): New functions, the latter
not implemented.
(disk_tree_vtable, ra_tree_vtable): Update.
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=1180843&r1=1180842&r2=1180843&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 09:38:23 2011
@@ -29,6 +29,89 @@
/*-----------------------------------------------------------------*/
+/* V-table for #svn_client_tree_t. */
+struct svn_client_tree__vtable_t
+{
+ /* See svn_tree_get_kind(). */
+ svn_error_t *(*get_kind)(svn_client_tree_t *tree,
+ svn_kind_t *kind,
+ const char *relpath,
+ apr_pool_t *scratch_pool);
+
+ /* See svn_tree_get_file(). */
+ svn_error_t *(*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);
+
+ /* See svn_tree_get_dir(). */
+ svn_error_t *(*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);
+
+ /* See svn_tree_get_symlink(). */
+ svn_error_t *(*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);
+};
+
+svn_error_t *
+svn_tree_get_kind(svn_client_tree_t *tree,
+ svn_kind_t *kind,
+ const char *relpath,
+ apr_pool_t *scratch_pool)
+{
+ return tree->vtable->get_kind(tree, kind, relpath, scratch_pool);
+}
+
+svn_error_t *
+svn_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)
+{
+ return tree->vtable->get_file(tree, stream, props, relpath,
+ result_pool, scratch_pool);
+}
+
+svn_error_t *
+svn_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)
+{
+ return tree->vtable->get_dir(tree, dirents, props, relpath,
+ result_pool, scratch_pool);
+}
+
+svn_error_t *
+svn_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)
+{
+ return tree->vtable->get_symlink(tree, link_target, props, relpath,
+ result_pool, scratch_pool);
+}
+
+
+/*-----------------------------------------------------------------*/
+
+
/* */
typedef struct disk_tree_baton_t
{
@@ -38,7 +121,7 @@ typedef struct disk_tree_baton_t
/* */
static svn_error_t *
disk_tree_get_kind(svn_client_tree_t *tree,
- svn_node_kind_t *kind,
+ svn_kind_t *kind,
const char *relpath,
apr_pool_t *scratch_pool)
{
@@ -46,7 +129,7 @@ disk_tree_get_kind(svn_client_tree_t *tr
const char *abspath = svn_dirent_join(baton->tree_abspath, relpath,
scratch_pool);
- SVN_ERR(svn_io_check_path(abspath, kind, scratch_pool));
+ SVN_ERR(svn_io_check_path2(abspath, kind, scratch_pool));
return SVN_NO_ERROR;
}
@@ -97,11 +180,37 @@ disk_tree_get_dir(svn_client_tree_t *tre
}
/* */
+static svn_error_t *
+disk_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)
+{
+ disk_tree_baton_t *baton = tree->priv;
+ const char *abspath = svn_dirent_join(baton->tree_abspath, relpath,
+ scratch_pool);
+
+ if (link_target)
+ {
+ svn_string_t *dest;
+ SVN_ERR(svn_io_read_link(&dest, abspath, result_pool));
+ *link_target = dest->data;
+ }
+ if (props)
+ *props = NULL;
+
+ return SVN_NO_ERROR;
+}
+
+/* */
static const svn_client_tree__vtable_t disk_tree_vtable =
{
disk_tree_get_kind,
disk_tree_get_file,
- disk_tree_get_dir
+ disk_tree_get_dir,
+ disk_tree_get_symlink
};
svn_error_t *
@@ -163,14 +272,14 @@ typedef struct ra_tree_baton_t
/* */
static svn_error_t *
ra_tree_get_kind(svn_client_tree_t *tree,
- svn_node_kind_t *kind,
+ svn_kind_t *kind,
const char *relpath,
apr_pool_t *scratch_pool)
{
ra_tree_baton_t *baton = tree->priv;
- SVN_ERR(svn_ra_check_path(baton->ra_session, relpath, baton->revnum,
- kind, scratch_pool));
+ SVN_ERR(svn_ra_check_path2(baton->ra_session, relpath, baton->revnum,
+ kind, scratch_pool));
return SVN_NO_ERROR;
}
@@ -237,11 +346,28 @@ ra_tree_get_dir(svn_client_tree_t *tree,
}
/* */
+static svn_error_t *
+ra_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)
+{
+ ra_tree_baton_t *baton = tree->priv;
+
+ /* ### ... */
+
+ return SVN_NO_ERROR;
+}
+
+/* */
static const svn_client_tree__vtable_t ra_tree_vtable =
{
ra_tree_get_kind,
ra_tree_get_file,
- ra_tree_get_dir
+ ra_tree_get_dir,
+ ra_tree_get_symlink
};
/* */
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=1180843&r1=1180842&r2=1180843&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 09:38:23 2011
@@ -43,71 +43,14 @@ typedef struct svn_client_tree_t svn_cli
/* */
typedef svn_io_dirent2_t svn_client_tree_dirent_t;
-/* V-table for #svn_client_tree_t.
- *
+/*
* Paths are relpaths, relative to the tree root.
+ *
* Revision numbers and repository ids are #SVN_INVALID_REVNUM and NULL
* for an unversioned node (including a node that is a local add/copy/move
* in a WC working tree).
*/
-typedef struct svn_client_tree__vtable_t
-{
- /* Fetch the node kind of the node at @a relpath.
- * (### and other metadata? revnum? props?)
- *
- * Set @a *kind to the node kind.
- */
- svn_error_t *(*get_kind)(svn_client_tree_t *tree,
- svn_node_kind_t *kind,
- const char *relpath,
- apr_pool_t *scratch_pool);
-
- /* Fetch the contents and properties of the file at @a relpath.
- *
- * If @a stream is non-NULL, set @a *stream to a readable stream yielding
- * the contents of the file at @a relpath. (### ? The stream
- * handlers for @a stream may not perform any operations on @a tree.)
- *
- * If @a props is non-NULL, set @a *props to contain the regular
- * versioned properties of the file (not 'wcprops', 'entryprops', etc.).
- * The hash maps (const char *) names to (#svn_string_t *) values.
- */
- svn_error_t *(*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);
-
- /* Fetch the entries and properties of the directory at @a relpath.
- *
- * If @a dirents is non-NULL, set @a *dirents to contain all the entries
- * of directory @a relpath. The keys will be (<tt>const char *</tt>)
- * entry names, and the values (#svn_client_tree_dirent_t *) dirents.
- * Only the @c kind and @c filesize fields are filled in.
- * ### @c special would be useful too.
- *
- * If @a props is non-NULL, set @a *props to contain the regular
- * versioned properties of the file (not 'wcprops', 'entryprops', etc.).
- * The hash maps (const char *) names to (#svn_string_t *) values.
- */
- svn_error_t *(*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);
-
- /* Push a sub-tree into an editor, as a delta against an empty tree.
- * This is useful for efficiency when streaming a (sub-)tree from a
- * remote source. */
- svn_error_t *(*push_as_delta_edit)(svn_client_tree_t *tree,
- const char *relpath,
- svn_delta_editor_t *editor,
- void *edit_baton,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool);
-} svn_client_tree__vtable_t;
+typedef struct svn_client_tree__vtable_t svn_client_tree__vtable_t;
/* */
struct svn_client_tree_t
@@ -121,6 +64,82 @@ struct svn_client_tree_t
void *priv;
};
+/* Fetch the node kind of the node at @a relpath.
+ * (### and other metadata? revnum? props?)
+ *
+ * The kind will be 'file', 'dir', 'symlink' or 'none'; not 'unknown'.
+ *
+ * Set @a *kind to the node kind.
+ */
+svn_error_t *
+svn_tree_get_kind(svn_client_tree_t *tree,
+ svn_kind_t *kind,
+ const char *relpath,
+ apr_pool_t *scratch_pool);
+
+/* Fetch the contents and/or properties of the file at @a relpath.
+ *
+ * If @a stream is non-NULL, set @a *stream to a readable stream yielding
+ * the contents of the file at @a relpath. (### ? The stream
+ * handlers for @a stream may not perform any operations on @a tree.)
+ *
+ * If @a props is non-NULL, set @a *props to contain the regular
+ * versioned properties of the file (not 'wcprops', 'entryprops', etc.).
+ * The hash maps (const char *) names to (#svn_string_t *) values.
+ *
+ * If the node at @a relpath is not a symlink, return a
+ * #SVN_ERR_WRONG_KIND error.
+ */
+svn_error_t *
+svn_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);
+
+/* Fetch the entries and/or properties of the directory at @a relpath.
+ *
+ * If @a dirents is non-NULL, set @a *dirents to contain all the entries
+ * of directory @a relpath. The keys will be (<tt>const char *</tt>)
+ * entry names, and the values (#svn_client_tree_dirent_t *) dirents.
+ * Only the @c kind and @c filesize fields are filled in.
+ * ### @c special would be useful too.
+ *
+ * If @a props is non-NULL, set @a *props to contain the regular
+ * versioned properties of the file (not 'wcprops', 'entryprops', etc.).
+ * The hash maps (const char *) names to (#svn_string_t *) values.
+ *
+ * If the node at @a relpath is not a symlink, return a
+ * #SVN_ERR_WRONG_KIND error.
+ */
+svn_error_t *
+svn_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);
+
+/* Fetch the target and/or properties of the symlink at @a relpath.
+ *
+ * If @a link_target is non-NULL, set @a *link_target to the target of
+ * the symbolic link.
+ *
+ * If @a props is non-NULL, set @a *props to contain the regular
+ * versioned properties of the file (not 'wcprops', 'entryprops', etc.).
+ * The hash maps (const char *) names to (#svn_string_t *) values.
+ *
+ * If the node at @a relpath is not a symlink, return a
+ * #SVN_ERR_WRONG_KIND error.
+ */
+svn_error_t *
+svn_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);
/*-----------------------------------------------------------------*/