subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r1232614 - /subversion/branches/ev2-export/subversion/libsvn_client/export.c
Date Tue, 17 Jan 2012 22:32:54 GMT
Author: hwright
Date: Tue Jan 17 22:32:53 2012
New Revision: 1232614

URL: http://svn.apache.org/viewvc?rev=1232614&view=rev
Log:
On the ev2-export branch:
Implement export with an Ev2 editor, and use that inplace of the delta editor.
Most of the content was just copied over, and I'm opptomistic the memory usage
will be better (no more long-lived file batons).

I'll remove the excess dead code in a subsequent commit.

* subversion/libsvn_client/export.c
  (add_file_ev2, set_props_ev2, complete_ev2, add_directory_ev2): New.
  (get_editor): Instantiate an Ev2 editor, and set up the proper callbacks.

Modified:
    subversion/branches/ev2-export/subversion/libsvn_client/export.c

Modified: subversion/branches/ev2-export/subversion/libsvn_client/export.c
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_client/export.c?rev=1232614&r1=1232613&r2=1232614&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/libsvn_client/export.c (original)
+++ subversion/branches/ev2-export/subversion/libsvn_client/export.c Tue Jan 17 22:32:53 2012
@@ -1070,6 +1070,185 @@ fetch_base_func(const char **filename,
 }
 
 static svn_error_t *
+add_file_ev2(void *baton,
+             const char *relpath,
+             const svn_checksum_t *checksum,
+             svn_stream_t *contents,
+             apr_hash_t *props,
+             svn_revnum_t replaces_rev,
+             apr_pool_t *scratch_pool)
+{
+  struct edit_baton *eb = baton;
+  const char *full_path = svn_dirent_join(eb->root_path, relpath,
+                                          scratch_pool);
+  /* PATH is not canonicalized, i.e. it may still contain spaces etc.
+   * but EB->root_url is. */
+  const char *full_url = svn_path_url_add_component2(eb->root_url,
+                                                     relpath,
+                                                     scratch_pool);
+  svn_stream_t *tmp_stream;
+  const char *tmppath;
+  const svn_string_t *val;
+  /* The three svn: properties we might actually care about. */
+  const svn_string_t *eol_style_val = NULL;
+  const svn_string_t *keywords_val = NULL;
+  const svn_string_t *executable_val = NULL;
+  svn_boolean_t special = FALSE;
+  /* Any keyword vals to be substituted */
+  const char *revision = NULL;
+  const char *author = NULL;
+  apr_time_t date = 0; 
+
+  /* Create a temporary file in the same directory as the file. We're going
+     to rename the thing into place when we're done. */
+  SVN_ERR(svn_stream_open_unique(&tmp_stream, &tmppath,
+                                 svn_dirent_dirname(full_path, scratch_pool),
+                                 svn_io_file_del_none,
+                                 scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_stream_copy3(contents, tmp_stream,
+                           eb->cancel_func, eb->cancel_baton, scratch_pool));
+
+  /* Look at any properties for additional information. */
+  if ( (val = apr_hash_get(props, SVN_PROP_EOL_STYLE, APR_HASH_KEY_STRING)) )
+    eol_style_val = val;
+
+  if ( !eb->ignore_keywords && (val = apr_hash_get(props, SVN_PROP_KEYWORDS,
+                                                   APR_HASH_KEY_STRING)) )
+    keywords_val = val;
+
+  if ( (val = apr_hash_get(props, SVN_PROP_EXECUTABLE, APR_HASH_KEY_STRING)) )
+    executable_val = val;
+  
+  /* Try to fill out the baton's keywords-structure too. */
+  if ( (val = apr_hash_get(props, SVN_PROP_ENTRY_COMMITTED_REV,
+                           APR_HASH_KEY_STRING)) )
+    revision = val->data;
+
+  if ( (val = apr_hash_get(props, SVN_PROP_ENTRY_COMMITTED_DATE,
+                           APR_HASH_KEY_STRING)) )
+    SVN_ERR(svn_time_from_cstring(&date, val->data, scratch_pool));
+  
+  if ( (val = apr_hash_get(props, SVN_PROP_ENTRY_LAST_AUTHOR,
+                           APR_HASH_KEY_STRING)) )
+    author = val->data;
+
+  if ( (val = apr_hash_get(props, SVN_PROP_SPECIAL, APR_HASH_KEY_STRING)) )
+    special = TRUE;
+
+  /* Move the file into place and tweak it as dictated by the props. */
+  if ((! eol_style_val) && (! keywords_val) && (! special))
+    {
+      SVN_ERR(svn_io_file_rename(tmppath, full_path, scratch_pool));
+    }
+  else
+    {
+      svn_subst_eol_style_t style;
+      const char *eol = NULL;
+      svn_boolean_t repair = FALSE;
+      apr_hash_t *final_kw = NULL;
+
+      if (eol_style_val)
+        {
+          SVN_ERR(get_eol_style(&style, &eol, eol_style_val->data,
+                                eb->native_eol));
+          repair = TRUE;
+        }
+
+      if (keywords_val)
+        SVN_ERR(svn_subst_build_keywords2(&final_kw, keywords_val->data,
+                                          revision, full_url, date,
+                                          author, scratch_pool));
+
+      SVN_ERR(svn_subst_copy_and_translate4(tmppath, full_path,
+                                            eol, repair, final_kw,
+                                            TRUE, /* expand */
+                                            special,
+                                            eb->cancel_func, eb->cancel_baton,
+                                            scratch_pool));
+
+      SVN_ERR(svn_io_remove_file2(tmppath, FALSE, scratch_pool));
+    }
+
+  if (executable_val)
+    SVN_ERR(svn_io_set_file_executable(full_path, TRUE, FALSE, scratch_pool));
+
+  if (date && (! special))
+    SVN_ERR(svn_io_set_file_affected_time(date, full_path, scratch_pool));
+
+  if (eb->notify_func)
+    {
+      svn_wc_notify_t *notify = svn_wc_create_notify(full_path,
+                                                     svn_wc_notify_update_add,
+                                                     scratch_pool);
+      notify->kind = svn_node_file;
+      (*eb->notify_func)(eb->notify_baton, notify, scratch_pool);
+    }
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+set_props_ev2(void *baton,
+              const char *relpath,
+              svn_revnum_t revision,
+              apr_hash_t *props,
+              svn_boolean_t complete,
+              apr_pool_t *scratch_pool)
+{
+  /* This is an export, we don't care about properties. */
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+complete_ev2(void *baton,
+             apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+add_directory_ev2(void *baton,
+                  const char *relpath,
+                  const apr_array_header_t *children,
+                  apr_hash_t *props,
+                  svn_revnum_t replaces_rev,
+                  apr_pool_t *scratch_pool)
+{
+  struct edit_baton *eb = baton;
+  svn_node_kind_t kind;
+  const char *full_path = svn_dirent_join(eb->root_path, relpath,
+                                          scratch_pool);
+  svn_string_t *val;
+
+  SVN_ERR(svn_io_check_path(full_path, &kind, scratch_pool));
+  if (kind == svn_node_none)
+    SVN_ERR(svn_io_dir_make(full_path, APR_OS_DEFAULT, scratch_pool));
+  else if (kind == svn_node_file)
+    return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
+                             _("'%s' exists and is not a directory"),
+                             svn_dirent_local_style(full_path, scratch_pool));
+  else if (! (kind == svn_node_dir && eb->force))
+    return svn_error_createf(SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
+                             _("'%s' already exists"),
+                             svn_dirent_local_style(full_path, scratch_pool));
+
+  if ( (val = apr_hash_get(props, SVN_PROP_EXTERNALS, APR_HASH_KEY_STRING)) )
+    SVN_ERR(add_externals(eb->externals, full_path, val));
+  
+  if (eb->notify_func)
+    {
+      svn_wc_notify_t *notify = svn_wc_create_notify(full_path,
+                                                     svn_wc_notify_update_add,
+                                                     scratch_pool);
+      notify->kind = svn_node_dir;
+      (*eb->notify_func)(eb->notify_baton, notify, scratch_pool);
+    }
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 get_editor(const svn_delta_editor_t **export_editor,
            void **edit_baton,
            void *eb,
@@ -1114,6 +1293,15 @@ get_editor(const svn_delta_editor_t **ex
                             shim_callbacks->fetch_props_func,
                             shim_callbacks->fetch_baton,
                             result_pool, scratch_pool));
+
+  SVN_ERR(svn_editor_create(&editorv2, eb, ctx->cancel_func, ctx->cancel_baton,
+                            result_pool, scratch_pool));
+  SVN_ERR(svn_editor_setcb_set_props(editorv2, set_props_ev2, scratch_pool));
+  SVN_ERR(svn_editor_setcb_complete(editorv2, complete_ev2, scratch_pool));
+  SVN_ERR(svn_editor_setcb_add_directory(editorv2, add_directory_ev2,
+                                         scratch_pool));
+  SVN_ERR(svn_editor_setcb_add_file(editorv2, add_file_ev2, scratch_pool));
+
   SVN_ERR(svn_delta__delta_from_editor(export_editor, edit_baton,
                             editorv2, found_abs_paths,
                             shim_callbacks->fetch_props_func,



Mime
View raw message