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 15:01:40 UTC

svn commit: r1180932 - in /subversion/branches/tree-read-api/subversion: include/svn_wc.h libsvn_wc/node.c

Author: julianfoad
Date: Mon Oct 10 13:01:39 2011
New Revision: 1180932

URL: http://svn.apache.org/viewvc?rev=1180932&view=rev
Log:
On the 'tree-read-api' branch: Implement an svn_kind_t (symlink-supporting)
version of svn_wc_read_kind().

* subversion/include/svn_wc.h
  (svn_wc_read_kind2): New, revved version of svn_wc_read_kind().

* subversion/libsvn_wc/node.c
  (convert_db_kind_to_node_kind2): New function.
  (svn_wc_read_kind2): New, revved version of svn_wc_read_kind().

Modified:
    subversion/branches/tree-read-api/subversion/include/svn_wc.h
    subversion/branches/tree-read-api/subversion/libsvn_wc/node.c

Modified: subversion/branches/tree-read-api/subversion/include/svn_wc.h
URL: http://svn.apache.org/viewvc/subversion/branches/tree-read-api/subversion/include/svn_wc.h?rev=1180932&r1=1180931&r2=1180932&view=diff
==============================================================================
--- subversion/branches/tree-read-api/subversion/include/svn_wc.h (original)
+++ subversion/branches/tree-read-api/subversion/include/svn_wc.h Mon Oct 10 13:01:39 2011
@@ -7857,7 +7857,7 @@ svn_wc_exclude(svn_wc_context_t *wc_ctx,
 /** @} */
 
 /**
- * Set @a kind to the #svn_node_kind_t of @a abspath.  Use @a wc_ctx
+ * Set @a kind to the node kind of @a abspath.  Use @a wc_ctx
  * to access the working copy, and @a scratch_pool for all temporary
  * allocations.
  *
@@ -7869,9 +7869,19 @@ svn_wc_exclude(svn_wc_context_t *wc_ctx,
  * ### What happens when show_hidden is TRUE?
  *
  * If the node's info is incomplete, it may or may not have a known node kind
- * set. If the kind is not known (yet), set @a kind to #svn_node_unknown.
+ * set. If the kind is not known (yet), set @a kind to #svn_kind_unknown.
  * Otherwise return the node kind even though the node is marked incomplete.
  *
+ * @since New in 1.8.
+ */
+svn_error_t *
+svn_wc_read_kind2(svn_kind_t *kind,
+                  svn_wc_context_t *wc_ctx,
+                  const char *abspath,
+                  svn_boolean_t show_hidden,
+                  apr_pool_t *scratch_pool);
+
+/* @deprecated
  * @since New in 1.7.
  */
 svn_error_t *

Modified: subversion/branches/tree-read-api/subversion/libsvn_wc/node.c
URL: http://svn.apache.org/viewvc/subversion/branches/tree-read-api/subversion/libsvn_wc/node.c?rev=1180932&r1=1180931&r2=1180932&view=diff
==============================================================================
--- subversion/branches/tree-read-api/subversion/libsvn_wc/node.c (original)
+++ subversion/branches/tree-read-api/subversion/libsvn_wc/node.c Mon Oct 10 13:01:39 2011
@@ -279,6 +279,78 @@ convert_db_kind_to_node_kind(svn_node_ki
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+convert_db_kind_to_node_kind2(svn_kind_t *kind,
+                              svn_wc__db_kind_t db_kind,
+                              svn_wc__db_status_t db_status,
+                              svn_boolean_t show_hidden)
+{
+  switch (db_kind)
+    {
+      case svn_wc__db_kind_file:
+        *kind = svn_kind_file;
+        break;
+      case svn_wc__db_kind_dir:
+        *kind = svn_kind_dir;
+        break;
+      case svn_wc__db_kind_symlink:
+        *kind = svn_kind_symlink;
+        break;
+      case svn_wc__db_kind_unknown:
+        *kind = svn_kind_unknown;
+        break;
+      default:
+        SVN_ERR_MALFUNCTION();
+    }
+
+  /* Make sure hidden nodes return svn_node_none. */
+  if (! show_hidden)
+    switch (db_status)
+      {
+        case svn_wc__db_status_not_present:
+        case svn_wc__db_status_server_excluded:
+        case svn_wc__db_status_excluded:
+          *kind = svn_kind_none;
+
+        default:
+          break;
+      }
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc_read_kind2(svn_kind_t *kind,
+                  svn_wc_context_t *wc_ctx,
+                  const char *local_abspath,
+                  svn_boolean_t show_hidden,
+                  apr_pool_t *scratch_pool)
+{
+  svn_wc__db_status_t db_status;
+  svn_wc__db_kind_t db_kind;
+  svn_error_t *err;
+
+  err = svn_wc__db_read_info(&db_status, &db_kind, NULL, NULL, NULL, NULL,
+                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                             NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                             NULL, NULL, NULL, NULL, NULL, NULL,
+                             wc_ctx->db, local_abspath,
+                             scratch_pool, scratch_pool);
+
+  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+    {
+      svn_error_clear(err);
+      *kind = svn_node_none;
+      return SVN_NO_ERROR;
+    }
+  else
+    SVN_ERR(err);
+
+  SVN_ERR(convert_db_kind_to_node_kind2(kind, db_kind, db_status, show_hidden));
+
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_wc_read_kind(svn_node_kind_t *kind,
                  svn_wc_context_t *wc_ctx,