subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1434667 - /subversion/trunk/subversion/libsvn_client/externals.c
Date Thu, 17 Jan 2013 13:37:40 GMT
Author: rhuijben
Date: Thu Jan 17 13:37:40 2013
New Revision: 1434667

URL: http://svn.apache.org/viewvc?rev=1434667&view=rev
Log:
* subversion/libsvn_client/externals.c
  (switch_file_external): Apply some assumptions that have been valid since
    1.7. Use passed pool as scratch. Remove lock release as the code where
    we obtain it was turned into an error in 1.7.

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

Modified: subversion/trunk/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/externals.c?rev=1434667&r1=1434666&r2=1434667&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/externals.c (original)
+++ subversion/trunk/subversion/libsvn_client/externals.c Thu Jan 17 13:37:40 2013
@@ -351,7 +351,6 @@ switch_file_external(const char *local_a
                      svn_client_ctx_t *ctx,
                      apr_pool_t *scratch_pool)
 {
-  apr_pool_t *subpool = svn_pool_create(scratch_pool);
   const char *dir_abspath;
   const char *target;
   svn_config_t *cfg = ctx->config ? apr_hash_get(ctx->config,
@@ -361,8 +360,6 @@ switch_file_external(const char *local_a
   const char *diff3_cmd;
   const char *preserved_exts_str;
   const apr_array_header_t *preserved_exts;
-  svn_boolean_t locked_here;
-  svn_error_t *err = NULL;
   svn_node_kind_t kind, external_kind;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
@@ -377,32 +374,29 @@ switch_file_external(const char *local_a
                  SVN_CONFIG_OPTION_DIFF3_CMD, NULL);
 
   if (diff3_cmd != NULL)
-    SVN_ERR(svn_path_cstring_to_utf8(&diff3_cmd, diff3_cmd, subpool));
+    SVN_ERR(svn_path_cstring_to_utf8(&diff3_cmd, diff3_cmd, scratch_pool));
 
   /* See which files the user wants to preserve the extension of when
      conflict files are made. */
   svn_config_get(cfg, &preserved_exts_str, SVN_CONFIG_SECTION_MISCELLANY,
                  SVN_CONFIG_OPTION_PRESERVED_CF_EXTS, "");
   preserved_exts = *preserved_exts_str
-    ? svn_cstring_split(preserved_exts_str, "\n\r\t\v ", FALSE, subpool)
+    ? svn_cstring_split(preserved_exts_str, "\n\r\t\v ", FALSE, scratch_pool)
     : NULL;
 
-  svn_dirent_split(&dir_abspath, &target, local_abspath, subpool);
+  svn_dirent_split(&dir_abspath, &target, local_abspath, scratch_pool);
 
-  /* Try to get a access baton for the anchor using the input access
-     baton.  If this fails and returns SVN_ERR_WC_NOT_LOCKED, then try
-     to get a new access baton to support inserting a file external
-     into a directory external. */
-  SVN_ERR(svn_wc_locked2(&locked_here, NULL, ctx->wc_ctx, dir_abspath,
-                         subpool));
-  if (!locked_here)
-    {
-      const char *wcroot_abspath;
+  {
+    const char *wcroot_abspath;
 
-      SVN_ERR(svn_wc__get_wcroot(&wcroot_abspath, ctx->wc_ctx, dir_abspath,
-                                 subpool, subpool));
+    SVN_ERR(svn_wc__get_wcroot(&wcroot_abspath, ctx->wc_ctx, local_abspath,
+                               scratch_pool, scratch_pool));
 
-      if (!svn_dirent_is_ancestor(wcroot_abspath, def_dir_abspath))
+    /* File externals can only be installed inside the current working copy.
+       So verify if the working copy that contains/will contain the target
+       is the defining abspath, or one of its ancestors */
+
+    if (!svn_dirent_is_ancestor(wcroot_abspath, def_dir_abspath))
         return svn_error_createf(
                         SVN_ERR_WC_BAD_PATH, NULL,
                         _("Cannot insert a file external defined on '%s' "
@@ -411,18 +405,14 @@ switch_file_external(const char *local_a
                                                scratch_pool),
                         svn_dirent_local_style(wcroot_abspath,
                                                scratch_pool));
-    }
+  }
 
-  err = svn_wc_read_kind(&kind, ctx->wc_ctx, local_abspath, FALSE, subpool);
-  if (err)
-    goto cleanup;
-
-  err = svn_wc__read_external_info(&external_kind, NULL, NULL, NULL, NULL,
-                                   ctx->wc_ctx, local_abspath, local_abspath,
-                                   TRUE, scratch_pool, scratch_pool);
+  SVN_ERR(svn_wc_read_kind(&kind, ctx->wc_ctx, local_abspath, FALSE,
+                           scratch_pool));
 
-  if (err)
-    goto cleanup;
+  SVN_ERR(svn_wc__read_external_info(&external_kind, NULL, NULL, NULL, NULL,
+                                     ctx->wc_ctx, local_abspath, local_abspath,
+                                     TRUE, scratch_pool, scratch_pool));
 
   /* If there is a versioned item with this name, ensure it's a file
      external before working with it.  If there is no entry in the
@@ -432,35 +422,25 @@ switch_file_external(const char *local_a
     {
       if (external_kind != svn_node_file)
         {
-          if (!locked_here)
-            SVN_ERR(svn_wc__release_write_lock(ctx->wc_ctx, dir_abspath,
-                                               subpool));
-
           return svn_error_createf(
               SVN_ERR_CLIENT_FILE_EXTERNAL_OVERWRITE_VERSIONED, 0,
              _("The file external from '%s' cannot overwrite the existing "
                "versioned item at '%s'"),
-             url, svn_dirent_local_style(local_abspath, subpool));
+             url, svn_dirent_local_style(local_abspath, scratch_pool));
         }
     }
   else
     {
       svn_node_kind_t disk_kind;
 
-      err = svn_io_check_path(local_abspath, &disk_kind, subpool);
-
-      if (err)
-        goto cleanup;
+      SVN_ERR(svn_io_check_path(local_abspath, &disk_kind, scratch_pool));
 
       if (kind == svn_node_file || kind == svn_node_dir)
-        {
-          err = svn_error_createf(SVN_ERR_WC_PATH_FOUND, NULL,
-                                  _("The file external '%s' can not be "
-                                    "created because the node exists."),
-                                  svn_dirent_local_style(local_abspath,
-                                                         subpool));
-          goto cleanup;
-        }
+        return svn_error_createf(SVN_ERR_WC_PATH_FOUND, NULL,
+                                 _("The file external '%s' can not be "
+                                   "created because the node exists."),
+                                 svn_dirent_local_style(local_abspath,
+                                                        scratch_pool));
     }
 
   {
@@ -470,36 +450,32 @@ switch_file_external(const char *local_a
     void *switch_baton;
     svn_client__pathrev_t *switch_loc;
     svn_revnum_t revnum;
-    /* ### TODO: Provide the real definition path (now available in
-       ### def_dir_abspath) after switching to the new externals store.
-       ### We can't enable this now, because that would move the external
-       ### information into the wrong working copy */
-    const char *definition_abspath = svn_dirent_dirname(local_abspath,subpool);
     apr_array_header_t *inherited_props;
 
     /* Open an RA session to 'source' URL */
     SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &switch_loc,
                                               url, dir_abspath,
                                               peg_revision, revision,
-                                              ctx, subpool));
+                                              ctx, scratch_pool));
     /* Get the external file's iprops. */
     SVN_ERR(svn_ra_get_inherited_props(ra_session, &inherited_props, "",
-                                       switch_loc->rev, subpool, subpool));
+                                       switch_loc->rev,
+                                       scratch_pool, scratch_pool));
 
-    SVN_ERR(svn_ra_reparent(ra_session, svn_uri_dirname(url, subpool),
-                            subpool));
+    SVN_ERR(svn_ra_reparent(ra_session, svn_uri_dirname(url, scratch_pool),
+                            scratch_pool));
 
     SVN_ERR(svn_wc__get_file_external_editor(&switch_editor, &switch_baton,
                                              &revnum, ctx->wc_ctx,
                                              local_abspath,
-                                             definition_abspath /* wri */,
+                                             def_dir_abspath,
                                              switch_loc->url,
                                              switch_loc->repos_root_url,
                                              switch_loc->repos_uuid,
                                              inherited_props,
                                              use_commit_times,
                                              diff3_cmd, preserved_exts,
-                                             definition_abspath /* def */,
+                                             def_dir_abspath,
                                              url, peg_revision, revision,
                                              ctx->conflict_func2,
                                              ctx->conflict_baton2,
@@ -507,43 +483,37 @@ switch_file_external(const char *local_a
                                              ctx->cancel_baton,
                                              ctx->notify_func2,
                                              ctx->notify_baton2,
-                                             subpool, subpool));
+                                             scratch_pool, scratch_pool));
 
     /* Tell RA to do an update of URL+TARGET to REVISION; if we pass an
      invalid revnum, that means RA will use the latest revision. */
     SVN_ERR(svn_ra_do_switch2(ra_session, &reporter, &report_baton,
                               switch_loc->rev,
                               target, svn_depth_unknown, url,
-                              switch_editor, switch_baton, subpool));
+                              switch_editor, switch_baton, scratch_pool));
 
     SVN_ERR(svn_wc__crawl_file_external(ctx->wc_ctx, local_abspath,
                                         reporter, report_baton,
                                         TRUE,  use_commit_times,
                                         ctx->cancel_func, ctx->cancel_baton,
                                         ctx->notify_func2, ctx->notify_baton2,
-                                        subpool));
+                                        scratch_pool));
 
     if (ctx->notify_func2)
       {
         svn_wc_notify_t *notify
           = svn_wc_create_notify(local_abspath, svn_wc_notify_update_completed,
-                                 subpool);
+                                 scratch_pool);
         notify->kind = svn_node_none;
         notify->content_state = notify->prop_state
           = svn_wc_notify_state_inapplicable;
         notify->lock_state = svn_wc_notify_lock_state_inapplicable;
         notify->revision = revnum;
-        (*ctx->notify_func2)(ctx->notify_baton2, notify, subpool);
+        (*ctx->notify_func2)(ctx->notify_baton2, notify, scratch_pool);
       }
   }
 
-cleanup:
-  if (!locked_here)
-    err = svn_error_compose_create(err,
-             svn_wc__release_write_lock(ctx->wc_ctx, dir_abspath, subpool));
-
-  svn_pool_destroy(subpool);
-  return svn_error_trace(err);
+  return SVN_NO_ERROR;
 }
 
 static svn_error_t *



Mime
View raw message