Author: ivan
Date: Fri Jan  8 23:46:01 2016
New Revision: 1723819

URL: http://svn.apache.org/viewvc?rev=1723819&view=rev
Log:
On 'fs-node-api' branch: Revv svn_fs_dir_entries() to accept FS node object
and return hash table of svn_fs_dirent2_t with references to child FS nodes.

* subversion/include/svn_fs.h
  (svn_fs_dirent2_t): New.
  (svn_fs_dir_entries2): New.

* subversion/libsvn_fs/fs-loader.c
  (svn_fs_dir_entries2): New.

* subversion/libsvn_fs/fs-loader.h
  (node_vtable_t): Add DIR_ENTRIES vtable member.

* subversion/libsvn_fs/node_compat.c
  (): Include "svn_fspath.h" and "svn_hash.h"
  (compat_fs_node_dir_entries): New.
  (compat_node_vtable): Update FS node vtable.

* subversion/libsvn_ra_local/ra_plugin.c
  (svn_ra_local__get_dir): Use svn_fs_dir_entries2(), svn_fs_file_length2()
   and svn_fs_node_has_props2().

Modified:
    subversion/branches/fs-node-api/subversion/include/svn_fs.h
    subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.c
    subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.h
    subversion/branches/fs-node-api/subversion/libsvn_fs/node_compat.c
    subversion/branches/fs-node-api/subversion/libsvn_ra_local/ra_plugin.c

Modified: subversion/branches/fs-node-api/subversion/include/svn_fs.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/fs-node-api/subversion/include/svn_fs.h?rev=1723819&r1=1723818&r2=1723819&view=diff
==============================================================================
--- subversion/branches/fs-node-api/subversion/include/svn_fs.h (original)
+++ subversion/branches/fs-node-api/subversion/include/svn_fs.h Fri Jan  8 
23:46:01 2016
@@ -2162,7 +2162,25 @@ svn_fs_merge(const char **conflict_p,
 /* Directories.  */
 
 
-/** The type of a Subversion directory entry.  */
+/** The type of a Subversion directory entry.
+ *
+ * @since New in 1.10.
+ */
+typedef struct svn_fs_dirent2_t
+{
+
+  /** The name of this directory entry.  */
+  const char *name;
+
+  /** The node kind. */
+  svn_node_kind_t kind;
+
+  /** The node it names.  */
+  svn_fs_node_t *node;
+
+} svn_fs_dirent2_t;
+
+/* Similar to #svn_fs_dirent2_t but without reference to FS node.*/
 typedef struct svn_fs_dirent_t
 {
 
@@ -2181,8 +2199,20 @@ typedef struct svn_fs_dirent_t
 /** Set @a *entries_p to a newly allocated APR hash table containing the
  * entries of the directory at @a path in @a root.  The keys of the table
  * are entry names, as byte strings, excluding the final NULL
- * character; the table's values are pointers to #svn_fs_dirent_t
- * structures.  Allocate the table and its contents in @a pool.
+ * character; the table's values are pointers to #svn_fs_dirent2_t
+ * structures.  Allocate the table and its contents in @a result_pool. Use
+ * @a scratch_pool for temporary allocations.
+ *
+ * @since New in 1.10.
+ */
+svn_error_t *
+svn_fs_dir_entries2(apr_hash_t **entries_p,
+                    svn_fs_node_t *node,
+                    apr_pool_t *result_pool,
+                    apr_pool_t *scratch_pool);
+
+/** Same as svn_fs_dir_entries2(), only with #svn_fs_dirent_t* values
+ * in the hash (and thus no FS node objects).
  */
 svn_error_t *
 svn_fs_dir_entries(apr_hash_t **entries_p,

Modified: subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.c?rev=1723819&r1=1723818&r2=1723819&view=diff
==============================================================================
--- subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.c Fri Jan  8 
23:46:01 2016
@@ -1320,6 +1320,17 @@ svn_fs_dir_entries(apr_hash_t **entries_
 }
 
 svn_error_t *
+svn_fs_dir_entries2(apr_hash_t **entries_p,
+                    svn_fs_node_t *node,
+                    apr_pool_t *result_pool,
+                    apr_pool_t *scratch_pool)
+{
+  return svn_error_trace(node->vtable->dir_entries(entries_p, node,
+                                                   result_pool,
+                                                   scratch_pool));
+}
+
+svn_error_t *
 svn_fs_dir_optimal_order(apr_array_header_t **ordered_p,
                          svn_fs_root_t *root,
                          apr_hash_t *entries,

Modified: subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.h?rev=1723819&r1=1723818&r2=1723819&view=diff
==============================================================================
--- subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.h (original)
+++ subversion/branches/fs-node-api/subversion/libsvn_fs/fs-loader.h Fri Jan  8 
23:46:01 2016
@@ -457,6 +457,11 @@ typedef struct node_vtable_t
   svn_error_t *(*file_length)(svn_filesize_t *length_p,
                               svn_fs_node_t *node,
                               apr_pool_t *pool);
+  /* Directories */
+  svn_error_t *(*dir_entries)(apr_hash_t **entries_p,
+                              svn_fs_node_t *node,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool);
 } node_vtable_t;
 
 

Modified: subversion/branches/fs-node-api/subversion/libsvn_fs/node_compat.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fs-node-api/subversion/libsvn_fs/node_compat.c?rev=1723819&r1=1723818&r2=1723819&view=diff
==============================================================================
--- subversion/branches/fs-node-api/subversion/libsvn_fs/node_compat.c 
(original)
+++ subversion/branches/fs-node-api/subversion/libsvn_fs/node_compat.c Fri Jan  
8 23:46:01 2016
@@ -20,6 +20,8 @@
  *    under the License.
  * ====================================================================
  */
+#include "private/svn_fspath.h"
+#include "svn_hash.h"
 #include "fs-loader.h"
 #include "node_compat.h"
 
@@ -92,11 +94,49 @@ compat_fs_node_file_length(svn_filesize_
                                                    pool));
 }
 
+static svn_error_t *
+compat_fs_node_dir_entries(apr_hash_t **entries_p,
+                           svn_fs_node_t *node,
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool)
+{
+  compat_node_data_t *fnd = node->fsap_data;
+  svn_fs_root_t *root;
+  apr_hash_t *entries_v1;
+  apr_hash_t *entries_v2;
+
+  SVN_ERR(get_root(&root, fnd, scratch_pool));
+
+  SVN_ERR(svn_fs_dir_entries(&entries_v1, root, fnd->path, scratch_pool));
+
+  entries_v2 = apr_hash_make(result_pool);
+  for (apr_hash_index_t *hi = apr_hash_first(scratch_pool, entries_v1); hi;
+       hi = apr_hash_next(hi))
+    {
+      svn_fs_dirent_t *dirent_v1 = apr_hash_this_val(hi);
+      svn_fs_dirent2_t *dirent_v2 = apr_pcalloc(result_pool,
+                                                sizeof(*dirent_v2));
+      const char *path = svn_fspath__join(fnd->path, dirent_v1->name,
+                                          result_pool);
+
+      dirent_v2->name = apr_pstrdup(result_pool, dirent_v1->name);
+      dirent_v2->kind = dirent_v1->kind;
+      dirent_v2->node = svn_fs__create_node_shim(root, path,
+                                                 dirent_v1->kind,
+                                                 result_pool);
+      svn_hash_sets(entries_v2, dirent_v2->name, dirent_v2);
+    }
+
+  *entries_p = entries_v2;
+  return SVN_NO_ERROR;
+}
+
 static const node_vtable_t compat_node_vtable = 
 {
   compat_fs_node_kind,
   compat_fs_node_has_props,
-  compat_fs_node_file_length
+  compat_fs_node_file_length,
+  compat_fs_node_dir_entries
 };
 
 svn_fs_node_t *

Modified: subversion/branches/fs-node-api/subversion/libsvn_ra_local/ra_plugin.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fs-node-api/subversion/libsvn_ra_local/ra_plugin.c?rev=1723819&r1=1723818&r2=1723819&view=diff
==============================================================================
--- subversion/branches/fs-node-api/subversion/libsvn_ra_local/ra_plugin.c 
(original)
+++ subversion/branches/fs-node-api/subversion/libsvn_ra_local/ra_plugin.c Fri 
Jan  8 23:46:01 2016
@@ -1330,9 +1330,11 @@ svn_ra_local__get_dir(svn_ra_session_t *
 
   if (dirents)
     {
+      svn_fs_node_t *node;
       apr_pool_t *iterpool = svn_pool_create(pool);
       /* Get the dir's entries. */
-      SVN_ERR(svn_fs_dir_entries(&entries, root, abs_path, pool));
+      SVN_ERR(svn_fs_open_node(&node, root, abs_path, FALSE, pool, iterpool));
+      SVN_ERR(svn_fs_dir_entries2(&entries, node, pool, iterpool));
 
       /* Loop over the fs dirents, and build a hash of general
          svn_dirent_t's. */
@@ -1342,14 +1344,14 @@ svn_ra_local__get_dir(svn_ra_session_t *
           const void *key;
           void *val;
           const char *datestring, *entryname, *fullpath;
-          svn_fs_dirent_t *fs_entry;
+          svn_fs_dirent2_t *fs_entry;
           svn_dirent_t *entry = svn_dirent_create(pool);
 
           svn_pool_clear(iterpool);
 
           apr_hash_this(hi, &key, NULL, &val);
           entryname = (const char *) key;
-          fs_entry = (svn_fs_dirent_t *) val;
+          fs_entry = (svn_fs_dirent2_t *) val;
 
           fullpath = svn_dirent_join(abs_path, entryname, iterpool);
 
@@ -1365,16 +1367,16 @@ svn_ra_local__get_dir(svn_ra_session_t *
               if (entry->kind == svn_node_dir)
                 entry->size = 0;
               else
-                SVN_ERR(svn_fs_file_length(&(entry->size), root,
-                                           fullpath, iterpool));
+                SVN_ERR(svn_fs_file_length2(&(entry->size), fs_entry->node,
+                                            iterpool));
             }
 
           if (dirent_fields & SVN_DIRENT_HAS_PROPS)
             {
               /* has_props? */
-              SVN_ERR(svn_fs_node_has_props(&entry->has_props,
-                                            root, fullpath,
-                                            iterpool));
+              SVN_ERR(svn_fs_node_has_props2(&entry->has_props,
+                                             fs_entry->node,
+                                             iterpool));
             }
 
           if ((dirent_fields & SVN_DIRENT_TIME)


Reply via email to