subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r881933 - /subversion/trunk/subversion/libsvn_client/add.c
Date Wed, 18 Nov 2009 20:50:57 GMT
Author: hwright
Date: Wed Nov 18 20:50:57 2009
New Revision: 881933

URL: http://svn.apache.org/viewvc?rev=881933&view=rev
Log:
Remove the use of a couple of access batons.

* subversion/libsvn_client/add.c
  (add_parent_dirs): Use svn_wc_check_wc2() for its intended purpose, rather
    than attemping to open a access baton.  Also, use absolute paths
    throughout.
  (svn_client_add4): Use absolute paths, and drop the access baton usage when
    adding parent paths.

Modified:
    subversion/trunk/subversion/libsvn_client/add.c

Modified: subversion/trunk/subversion/libsvn_client/add.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/add.c?rev=881933&r1=881932&r2=881933&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/add.c (original)
+++ subversion/trunk/subversion/libsvn_client/add.c Wed Nov 18 20:50:57 2009
@@ -532,55 +532,36 @@
    add all the intermediate directories.  Otherwise, return
    SVN_ERR_CLIENT_NO_VERSIONED_PARENT. */
 static svn_error_t *
-add_parent_dirs(const char *path,
-                svn_wc_adm_access_t **parent_access,
-                svn_client_ctx_t *ctx,
-                apr_pool_t *pool)
+add_parent_dirs(svn_client_ctx_t *ctx,
+                const char *local_abspath,
+                apr_pool_t *scratch_pool)
 {
-  svn_wc_adm_access_t *adm_access;
-  svn_error_t *err = NULL;
-  const char *local_abspath;
+  int format;
+  const char *parent_abspath;
 
-  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
-
-  err = svn_wc__adm_open_in_context(&adm_access, ctx->wc_ctx, path, TRUE, 0,
-                                    ctx->cancel_func, ctx->cancel_baton, pool);
+  SVN_ERR(svn_wc_check_wc2(&format, ctx->wc_ctx, local_abspath, scratch_pool));
 
-  if (err && err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY)
-    {
-      svn_error_clear(err);
-      if (svn_dirent_is_root(path, strlen(path)))
-        {
-          return svn_error_create
-            (SVN_ERR_CLIENT_NO_VERSIONED_PARENT, NULL, NULL);
-        }
-      else if (svn_wc_is_adm_dir(svn_dirent_basename(path, pool), pool))
-        {
-          return svn_error_createf
-            (SVN_ERR_RESERVED_FILENAME_SPECIFIED, NULL,
-             _("'%s' ends in a reserved name"),
-             svn_dirent_local_style(path, pool));
-        }
-      else
-        {
-          const char *parent_path = svn_dirent_dirname(path, pool);
+  if (format > 0)
+    return SVN_NO_ERROR;
 
-          SVN_ERR(add_parent_dirs(parent_path, &adm_access, ctx, pool));
-          SVN_ERR(svn_wc_adm_retrieve(&adm_access, adm_access, parent_path,
-                                      pool));
-          SVN_ERR(svn_wc_add4(ctx->wc_ctx, local_abspath, svn_depth_infinity,
-                              NULL, SVN_INVALID_REVNUM,
-                              ctx->cancel_func, ctx->cancel_baton,
-                              ctx->notify_func2, ctx->notify_baton2, pool));
-        }
-    }
-  else if (err)
-    {
-      return svn_error_return(err);
-    }
+  if (svn_dirent_is_root(local_abspath, strlen(local_abspath)))
+    return svn_error_create(SVN_ERR_CLIENT_NO_VERSIONED_PARENT, NULL, NULL);
 
-  if (parent_access)
-    *parent_access = adm_access;
+  if (svn_wc_is_adm_dir(svn_dirent_basename(local_abspath, scratch_pool),
+                        scratch_pool))
+    return svn_error_createf(SVN_ERR_RESERVED_FILENAME_SPECIFIED, NULL,
+                             _("'%s' ends in a reserved name"),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+
+  parent_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
+
+  SVN_ERR(add_parent_dirs(ctx, parent_abspath, scratch_pool));
+  SVN_ERR(svn_wc_add4(ctx->wc_ctx, local_abspath, svn_depth_infinity,
+                      NULL, SVN_INVALID_REVNUM,
+                      ctx->cancel_func, ctx->cancel_baton,
+                      ctx->notify_func2, ctx->notify_baton2,
+                      scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -598,32 +579,36 @@
 {
   svn_error_t *err;
   svn_wc_adm_access_t *adm_access;
-  const char *parent_dir;
+  const char *parent_abspath;
   const char *local_abspath;
 
+  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
+
+  /* ### this is a hack.
+     ### before we switched to absolute paths, if a user tried to do
+     ### 'svn add .', PATH would be "" and PARENT_PATH would also be "",
+     ### thus emulating the behavior below.  Now that we are using
+     ### absolute paths, svn_dirent_dirname() doesn't behave the same way
+     ### w.r.t. '.', so we need to include the following hack.  This
+     ### behavior is tested in schedule_tests-11. */
+  if (path[0] == 0)
+    parent_abspath = local_abspath;
+  else
+    parent_abspath = svn_dirent_dirname(local_abspath, pool);
+
   if (add_parents)
     {
       apr_pool_t *subpool;
 
-      SVN_ERR(svn_dirent_get_absolute(&path, path, pool));
-      parent_dir = svn_dirent_dirname(path, pool);
-
       subpool = svn_pool_create(pool);
-      SVN_ERR(add_parent_dirs(parent_dir, &adm_access, ctx, subpool));
-      SVN_ERR(svn_wc_adm_close2(adm_access, subpool));
+      SVN_ERR(add_parent_dirs(ctx, parent_abspath, subpool));
       svn_pool_destroy(subpool);
     }
-  else
-    {
-      parent_dir = svn_dirent_dirname(path, pool);
-    }
 
-  SVN_ERR(svn_wc__adm_open_in_context(&adm_access, ctx->wc_ctx, parent_dir,
+  SVN_ERR(svn_wc__adm_open_in_context(&adm_access, ctx->wc_ctx, parent_abspath,
                                       TRUE, 0, ctx->cancel_func,
                                       ctx->cancel_baton, pool));
 
-  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
-
   err = add(local_abspath, depth, force, no_ignore, ctx, pool);
 
   /* ### Currently we rely on the fact that this close (like all other access



Mime
View raw message