[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Remove svn_node_special from svn_node_kind_t?

From: Josh Pieper <jjp_at_pobox.com>
Date: 2004-08-06 04:43:44 CEST

After sitting on the svn:special feature for a while, and after some
conversations on IRC with sussman, ghudson, and breser, I discovered
that there really wasn't too good of a reason to export the
svn_node_special type as part of our public API.

I prepared a patch that does just that, but I don't have a strong
preference either way. I know some people have expressed a strong
desire to get rid of that definition. Is this patch acceptable? It
passes all tests and should have no functional changes whatsoever.

-Josh

=================

Remove the svn_node_special type from the svn_node_kind_t enum.
There's no reason to export an implementation detail in the public
API. Instead, have svn_io_check_special_path return a simple boolean
describing whether a path is a normal file or directory, or some
platform specific special file. Change all the callers to use this
new method of determining if an on-disk path needs svn:special
handling.

* subversion/include/svn_types.h
  (svn_node_kind_t): Remove svn_node_special.

* subversion/include/svn_io.h
  (svn_io_check_special_path): Document the new is_special argument.

* subversion/libsvn_subr/io.c
  (io_check_path): Instead of accepting a parameter to expand special
    files, accept a pointer to boolean so we can tell the caller
    whether the given path was a special file.
  (svn_io_check_resolved_path, svn_io_check_path): Ignore the new
    boolean returned from io_check_path.
  (svn_io_check_special_path): Implement the new API and pass the
    boolean pointer through to io_check_path. All callers updated.

* subversion/libsvn_wc/log.c
* subversion/libsvn_wc/status.c
* subversion/libsvn_subr/subst.c
* subversion/libsvn_client/commit_util.c
* subversion/libsvn_client/add.c
* subversion/libsvn_client/commit.c
  Update callers of svn_io_check_special_path.

Index: subversion/include/svn_types.h
===================================================================
--- subversion/include/svn_types.h (revision 10503)
+++ subversion/include/svn_types.h (working copy)
@@ -86,11 +86,7 @@
   svn_node_dir,
 
   /* something's here, but we don't know what */
- svn_node_unknown,
-
- /* a special file */
- svn_node_special
-
+ svn_node_unknown
 } svn_node_kind_t;
 
 /** About Special Files in Subversion
Index: subversion/include/svn_io.h
===================================================================
--- subversion/include/svn_io.h (revision 10503)
+++ subversion/include/svn_io.h (working copy)
@@ -62,11 +62,12 @@
 /**
  * @since New in 1.1.
  *
- * Like svn_io_check_path(), but return the actual node type for any
- * special files.
+ * Like svn_io_check_path(), but also set *is_special to @c TRUE if
+ * the path is not a normal file.
  */
 svn_error_t *svn_io_check_special_path (const char *path,
                                         svn_node_kind_t *kind,
+ svn_boolean_t *is_special,
                                         apr_pool_t *pool);
 
 /** Like svn_io_check_path(), but resolve symlinks. This returns the
Index: subversion/libsvn_wc/log.c
===================================================================
--- subversion/libsvn_wc/log.c (revision 10503)
+++ subversion/libsvn_wc/log.c (working copy)
@@ -437,15 +437,18 @@
 
   const char *timestamp_string
     = svn_xml_get_attr_value (SVN_WC__LOG_ATTR_TIMESTAMP, atts);
+ svn_boolean_t is_special;
+
   if (! timestamp_string)
     return svn_error_createf (pick_error_code (loggy), NULL,
                               _("Missing 'timestamp' attribute in '%s'"),
                               svn_wc_adm_access_path (loggy->adm_access));
 
   /* Do not set the timestamp on special files. */
- SVN_ERR (svn_io_check_special_path (full_path, &kind, loggy->pool));
+ SVN_ERR (svn_io_check_special_path (full_path, &kind, &is_special,
+ loggy->pool));
   
- if (kind != svn_node_special)
+ if (! is_special)
     {
       SVN_ERR (svn_time_from_cstring (&timestamp, timestamp_string,
                                       loggy->pool));
Index: subversion/libsvn_wc/status.c
===================================================================
--- subversion/libsvn_wc/status.c (revision 10503)
+++ subversion/libsvn_wc/status.c (working copy)
@@ -212,8 +212,9 @@
   svn_boolean_t prop_modified_p = FALSE;
   svn_boolean_t locked_p = FALSE;
   svn_boolean_t switched_p = FALSE;
- svn_boolean_t special;
- svn_node_kind_t special_kind;
+ svn_boolean_t wc_special;
+ svn_boolean_t node_special;
+ svn_node_kind_t kind;
 
   /* Defaults for two main variables. */
   enum svn_wc_status_kind final_text_status = svn_wc_status_normal;
@@ -222,7 +223,7 @@
   /* Check the path kind for PATH. */
   if (path_kind == svn_node_unknown)
     SVN_ERR (svn_io_check_path (path, &path_kind, pool));
- SVN_ERR (svn_io_check_special_path (path, &special_kind, pool));
+ SVN_ERR (svn_io_check_special_path (path, &kind, &node_special, pool));
   
   if (! entry)
     {
@@ -304,11 +305,10 @@
       SVN_ERR (svn_wc_props_modified_p (&prop_modified_p, path, adm_access,
                                         pool));
 
- SVN_ERR (svn_wc__get_special (&special, path, adm_access, pool));
+ SVN_ERR (svn_wc__get_special (&wc_special, path, adm_access, pool));
 
       /* If the entry is a file, check for textual modifications */
- if ((entry->kind == svn_node_file) &&
- ((special ? svn_node_special : svn_node_file) == special_kind))
+ if ((entry->kind == svn_node_file) && (wc_special == node_special))
         SVN_ERR (svn_wc_text_modified_p (&text_modified_p, path, FALSE,
                                          adm_access, pool));
 
@@ -388,8 +388,8 @@
         }
       else if (path_kind != entry->kind)
         final_text_status = svn_wc_status_obstructed;
- else if ((special && (special_kind != svn_node_special))
- || ((! special) && (special_kind == svn_node_special)))
+ else if ((wc_special && (! node_special))
+ || ((! wc_special) && (node_special)))
         final_text_status = svn_wc_status_obstructed;
 
       if (path_kind == svn_node_dir && entry->kind == svn_node_dir)
Index: subversion/libsvn_subr/subst.c
===================================================================
--- subversion/libsvn_subr/subst.c (revision 10503)
+++ subversion/libsvn_subr/subst.c (working copy)
@@ -785,13 +785,14 @@
   const char *dst_tmp, *src_tmp = NULL;
   svn_error_t *err;
   svn_node_kind_t kind;
+ svn_boolean_t is_special;
 
   /* Check to see if we are being asked to create a special file from
      a special file. If so, do a temporary detranslation and work
      from there. */
- SVN_ERR (svn_io_check_special_path (src, &kind, pool));
+ SVN_ERR (svn_io_check_special_path (src, &kind, &is_special, pool));
 
- if (kind == svn_node_special)
+ if (is_special)
     {
       apr_file_t *fp;
       
@@ -880,12 +881,13 @@
   svn_error_t *err;
   apr_pool_t *subpool;
   svn_node_kind_t kind;
+ svn_boolean_t path_special;
 
- SVN_ERR (svn_io_check_special_path (src, &kind, pool));
+ SVN_ERR (svn_io_check_special_path (src, &kind, &path_special, pool));
 
   /* If this is a 'special' file, we may need to create it or
      detranslate it. */
- if (special || (kind == svn_node_special))
+ if (special || path_special)
     {
       if (expand)
         SVN_ERR (create_special_file (src, dst, pool));
Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c (revision 10503)
+++ subversion/libsvn_subr/io.c (working copy)
@@ -99,7 +99,7 @@
 static svn_error_t *
 io_check_path (const char *path,
                svn_boolean_t resolve_symlinks,
- svn_boolean_t expand_special,
+ svn_boolean_t *is_special_p,
                svn_node_kind_t *kind,
                apr_pool_t *pool)
 {
@@ -107,6 +107,7 @@
   apr_finfo_t finfo;
   apr_status_t apr_err;
   const char *path_apr;
+ svn_boolean_t is_special = FALSE;
 
   /* Make path appropriate for error messages in advance. */
   path = svn_path_local_style (path, pool);
@@ -117,7 +118,7 @@
 
   flags = resolve_symlinks ? APR_FINFO_MIN : (APR_FINFO_MIN | APR_FINFO_LINK);
   apr_err = apr_stat (&finfo, path_apr, flags, pool);
-
+
   if (APR_STATUS_IS_ENOENT (apr_err))
     *kind = svn_node_none;
   else if (APR_STATUS_IS_ENOTDIR (apr_err))
@@ -131,10 +132,15 @@
   else if (finfo.filetype == APR_DIR)
     *kind = svn_node_dir;
   else if (finfo.filetype == APR_LNK)
- *kind = expand_special ? svn_node_special : svn_node_file;
+ {
+ is_special = TRUE;
+ *kind = svn_node_file;
+ }
   else
     *kind = svn_node_unknown;
 
+ *is_special_p = is_special;
+
   return SVN_NO_ERROR;
 }
 
@@ -144,7 +150,8 @@
                             svn_node_kind_t *kind,
                             apr_pool_t *pool)
 {
- return io_check_path (path, TRUE, FALSE, kind, pool);
+ svn_boolean_t ignored;
+ return io_check_path (path, TRUE, &ignored, kind, pool);
 }
 
 svn_error_t *
@@ -152,15 +159,17 @@
                    svn_node_kind_t *kind,
                    apr_pool_t *pool)
 {
- return io_check_path (path, FALSE, FALSE, kind, pool);
+ svn_boolean_t ignored;
+ return io_check_path (path, FALSE, &ignored, kind, pool);
 }
 
 svn_error_t *
 svn_io_check_special_path (const char *path,
                            svn_node_kind_t *kind,
+ svn_boolean_t *is_special,
                            apr_pool_t *pool)
 {
- return io_check_path (path, FALSE, TRUE, kind, pool);
+ return io_check_path (path, FALSE, is_special, kind, pool);
 }
 
 svn_error_t *
Index: subversion/libsvn_client/commit_util.c
===================================================================
--- subversion/libsvn_client/commit_util.c (revision 10503)
+++ subversion/libsvn_client/commit_util.c (working copy)
@@ -190,6 +190,7 @@
   const char *cf_url = NULL;
   svn_revnum_t cf_rev = entry->copyfrom_rev;
   const svn_string_t *propval;
+ svn_boolean_t is_special;
 
   /* Early out if the item is already marked as committable. */
   if (look_up_committable (committables, path, pool))
@@ -211,12 +212,11 @@
     return svn_error_createf
       (SVN_ERR_NODE_UNKNOWN_KIND, NULL, _("Unknown entry kind for '%s'"), path);
 
- SVN_ERR (svn_io_check_special_path (path, &kind, pool));
+ SVN_ERR (svn_io_check_special_path (path, &kind, &is_special, pool));
 
   if ((kind != svn_node_file)
       && (kind != svn_node_dir)
- && (kind != svn_node_none)
- && (kind != svn_node_special))
+ && (kind != svn_node_none))
     {
       return svn_error_createf
         (SVN_ERR_NODE_UNKNOWN_KIND, NULL,
@@ -230,7 +230,7 @@
 
   if ((entry->kind == svn_node_file)
       && (! propval)
- && (kind == svn_node_special))
+ && (is_special))
     {
       return svn_error_createf
         (SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
Index: subversion/libsvn_client/add.c
===================================================================
--- subversion/libsvn_client/add.c (revision 10503)
+++ subversion/libsvn_client/add.c (working copy)
@@ -206,6 +206,7 @@
   apr_hash_index_t *hi;
   const char *mimetype;
   svn_node_kind_t kind;
+ svn_boolean_t is_special;
 
   /* add the file */
   SVN_ERR (svn_wc_add (path, adm_access, NULL, SVN_INVALID_REVNUM,
@@ -213,9 +214,9 @@
                        NULL, NULL, pool));
 
   /* Check to see if this is a special file. */
- SVN_ERR (svn_io_check_special_path (path, &kind, pool));
+ SVN_ERR (svn_io_check_special_path (path, &kind, &is_special, pool));
 
- if (kind == svn_node_special)
+ if (is_special)
     {
       /* This must be a special file. */
       SVN_ERR (svn_wc_prop_set (SVN_PROP_SPECIAL,
Index: subversion/libsvn_client/commit.c
===================================================================
--- subversion/libsvn_client/commit.c (revision 10503)
+++ subversion/libsvn_client/commit.c (working copy)
@@ -173,14 +173,15 @@
   apr_hash_t* properties;
   apr_hash_index_t *hi;
   svn_node_kind_t kind;
+ svn_boolean_t is_special;
 
   /* Add the file, using the pool from the FILES hash. */
   SVN_ERR (editor->add_file (edit_path, dir_baton, NULL, SVN_INVALID_REVNUM,
                              pool, &file_baton));
 
- SVN_ERR (svn_io_check_special_path (path, &kind, pool));
+ SVN_ERR (svn_io_check_special_path (path, &kind, &is_special, pool));
 
- if (kind != svn_node_special)
+ if (! is_special)
     {
       /* add automatic properties */
       SVN_ERR (svn_client__get_auto_props (&properties, &mimetype, path, ctx,
@@ -214,7 +215,7 @@
   /* If this is a special file, we need to set the svn:special
      property and create a temporary detranslated version in order to
      send to the server. */
- if (kind == svn_node_special)
+ if (is_special)
     {
       apr_hash_set (properties, SVN_PROP_SPECIAL, APR_HASH_KEY_STRING,
                     svn_string_create (SVN_PROP_SPECIAL_VALUE, pool));

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Aug 6 04:45:02 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.