You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2012/05/01 22:20:11 UTC

svn commit: r1332805 - in /subversion/branches/ev2-export/subversion/libsvn_client: client.h commit.c commit_util.c

Author: hwright
Date: Tue May  1 20:20:11 2012
New Revision: 1332805

URL: http://svn.apache.org/viewvc?rev=1332805&view=rev
Log:
On the ev2-export branch:
Shuffle some code around.

* subversion/libsvn_client/client.h
  (svn_client__get_detranslated_stream): Add prototype.

* subversion/libsvn_client/commit_util.c
  (svn_client__get_detranslated_stream): Move to here...

* subversion/libsvn_client/commit.c
  (get_file_contents): ...from there.
  (import_file): Update caller.

Modified:
    subversion/branches/ev2-export/subversion/libsvn_client/client.h
    subversion/branches/ev2-export/subversion/libsvn_client/commit.c
    subversion/branches/ev2-export/subversion/libsvn_client/commit_util.c

Modified: subversion/branches/ev2-export/subversion/libsvn_client/client.h
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_client/client.h?rev=1332805&r1=1332804&r2=1332805&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/libsvn_client/client.h (original)
+++ subversion/branches/ev2-export/subversion/libsvn_client/client.h Tue May  1 20:20:11 2012
@@ -1109,6 +1109,19 @@ svn_client__get_normalized_stream(svn_st
                                   apr_pool_t *result_pool,
                                   apr_pool_t *scratch_pool);
 
+/* Return in FSTREAM a readable stream for the contents of LOCAL_ABSPATH,
+   with the appropriate detranslation as given by PROPERTIES.  CHECKSUM will
+   contain the expected SHA1 checksum of the contents.
+
+   Both CHECKSUM AND FSTREAM are allocated in RESULT_POOL. */
+svn_error_t *
+svn_client__get_detranslated_stream(svn_stream_t **fstream,
+                                    svn_checksum_t **checksum,
+                                    const char *local_abspath,
+                                    apr_hash_t *properties,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool);
+
 
 struct svn_client__shim_callbacks_baton
 {

Modified: subversion/branches/ev2-export/subversion/libsvn_client/commit.c
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_client/commit.c?rev=1332805&r1=1332804&r2=1332805&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/libsvn_client/commit.c (original)
+++ subversion/branches/ev2-export/subversion/libsvn_client/commit.c Tue May  1 20:20:11 2012
@@ -79,102 +79,6 @@ typedef struct import_ctx_t
 } import_ctx_t;
 
 
-/* Return in FSTREAM a readable stream for the contents of LOCAL_ABSPATH,
-   with the appropriate detranslation as given by PROPERTIES.  CHECKSUM will
-   contain the expected SHA1 checksum of the contents.
-
-   Both CHECKSUM AND FSTREAM are allocated in RESULT_POOL. */
-static svn_error_t *
-get_file_contents(svn_stream_t **fstream,
-                  svn_checksum_t **checksum,
-                  const char *local_abspath,
-                  apr_hash_t *properties,
-                  apr_pool_t *result_pool,
-                  apr_pool_t *scratch_pool)
-{
-  svn_stream_t *contents;
-  const svn_string_t *eol_style_val = NULL;
-  const svn_string_t *keywords_val = NULL;
-  svn_boolean_t special = FALSE;
-  svn_subst_eol_style_t eol_style;
-  const char *eol;
-  apr_hash_t *keywords;
-
-  /* If there are properties, look for EOL-style and keywords ones. */
-  if (properties)
-    {
-      eol_style_val = apr_hash_get(properties, SVN_PROP_EOL_STYLE,
-                                   sizeof(SVN_PROP_EOL_STYLE) - 1);
-      keywords_val = apr_hash_get(properties, SVN_PROP_KEYWORDS,
-                                  sizeof(SVN_PROP_KEYWORDS) - 1);
-      if (apr_hash_get(properties, SVN_PROP_SPECIAL, APR_HASH_KEY_STRING))
-        special = TRUE;
-    }
-
-  if (eol_style_val)
-    svn_subst_eol_style_from_value(&eol_style, &eol, eol_style_val->data);
-  else
-    {
-      eol = NULL;
-      eol_style = svn_subst_eol_style_none;
-    }
-
-  if (keywords_val)
-    SVN_ERR(svn_subst_build_keywords2(&keywords, keywords_val->data,
-                                      APR_STRINGIFY(SVN_INVALID_REVNUM),
-                                      "", 0, "", scratch_pool));
-  else
-    keywords = NULL;
-
-  if (special)
-    {
-      SVN_ERR(svn_subst_read_specialfile(&contents, local_abspath,
-                                         scratch_pool, scratch_pool));
-    }
-  else
-    {
-      /* Open the working copy file. */
-      SVN_ERR(svn_stream_open_readonly(&contents, local_abspath, scratch_pool,
-                                       scratch_pool));
-
-      /* If we have EOL styles or keywords, then detranslate the file. */
-      if (svn_subst_translation_required(eol_style, eol, keywords,
-                                         FALSE, TRUE))
-        {
-          if (eol_style == svn_subst_eol_style_unknown)
-            return svn_error_createf(SVN_ERR_IO_UNKNOWN_EOL, NULL,
-                                    _("%s property on '%s' contains "
-                                      "unrecognized EOL-style '%s'"),
-                                    SVN_PROP_EOL_STYLE,
-                                    svn_dirent_local_style(local_abspath,
-                                                           scratch_pool),
-                                    eol_style_val->data);
-
-          /* We're importing, so translate files with 'native' eol-style to
-           * repository-normal form, not to this platform's native EOL. */
-          if (eol_style == svn_subst_eol_style_native)
-            eol = SVN_SUBST_NATIVE_EOL_STR;
-
-          /* Wrap the working copy stream with a filter to detranslate it. */
-          contents = svn_subst_stream_translated(contents,
-                                                 eol,
-                                                 TRUE /* repair */,
-                                                 keywords,
-                                                 FALSE /* expand */,
-                                                 scratch_pool);
-        }
-    }
-
-  *fstream = svn_stream_buffered(result_pool);
-  contents = svn_stream_checksummed2(contents, checksum, NULL,
-                                     svn_checksum_sha1, TRUE, scratch_pool);
-  SVN_ERR(svn_stream_copy3(contents, svn_stream_disown(*fstream, result_pool),
-                           NULL, NULL, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-
 /* Import file PATH as EDIT_PATH in the repository directory indicated
  * by DIR_BATON in EDITOR.
  *
@@ -237,8 +141,9 @@ import_file(svn_editor_t *editor,
                  svn_string_create(SVN_PROP_BOOLEAN_TRUE, pool));
 
   /* Now, transmit the file contents. */
-  SVN_ERR(get_file_contents(&contents, &checksum, local_abspath,
-                            properties, pool, pool));
+  SVN_ERR(svn_client__get_detranslated_stream(&contents, &checksum,
+                                              local_abspath,
+                                              properties, pool, pool));
 
   SVN_ERR(svn_editor_add_file(editor, relpath, checksum, contents, properties,
                               SVN_INVALID_REVNUM));

Modified: subversion/branches/ev2-export/subversion/libsvn_client/commit_util.c
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_client/commit_util.c?rev=1332805&r1=1332804&r2=1332805&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/libsvn_client/commit_util.c (original)
+++ subversion/branches/ev2-export/subversion/libsvn_client/commit_util.c Tue May  1 20:20:11 2012
@@ -37,6 +37,7 @@
 #include "svn_pools.h"
 #include "svn_props.h"
 #include "svn_iter.h"
+#include "svn_subst.h"
 #include "svn_hash.h"
 
 #include <assert.h>
@@ -1973,3 +1974,93 @@ svn_client__ensure_revprop_table(apr_has
   *revprop_table_out = new_revprop_table;
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_client__get_detranslated_stream(svn_stream_t **fstream,
+                                    svn_checksum_t **checksum,
+                                    const char *local_abspath,
+                                    apr_hash_t *properties,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool)
+{
+  svn_stream_t *contents;
+  const svn_string_t *eol_style_val = NULL;
+  const svn_string_t *keywords_val = NULL;
+  svn_boolean_t special = FALSE;
+  svn_subst_eol_style_t eol_style;
+  const char *eol;
+  apr_hash_t *keywords;
+
+  /* If there are properties, look for EOL-style and keywords ones. */
+  if (properties)
+    {
+      eol_style_val = apr_hash_get(properties, SVN_PROP_EOL_STYLE,
+                                   sizeof(SVN_PROP_EOL_STYLE) - 1);
+      keywords_val = apr_hash_get(properties, SVN_PROP_KEYWORDS,
+                                  sizeof(SVN_PROP_KEYWORDS) - 1);
+      if (apr_hash_get(properties, SVN_PROP_SPECIAL, APR_HASH_KEY_STRING))
+        special = TRUE;
+    }
+
+  if (eol_style_val)
+    svn_subst_eol_style_from_value(&eol_style, &eol, eol_style_val->data);
+  else
+    {
+      eol = NULL;
+      eol_style = svn_subst_eol_style_none;
+    }
+
+  if (keywords_val)
+    SVN_ERR(svn_subst_build_keywords2(&keywords, keywords_val->data,
+                                      APR_STRINGIFY(SVN_INVALID_REVNUM),
+                                      "", 0, "", scratch_pool));
+  else
+    keywords = NULL;
+
+  if (special)
+    {
+      SVN_ERR(svn_subst_read_specialfile(&contents, local_abspath,
+                                         scratch_pool, scratch_pool));
+    }
+  else
+    {
+      /* Open the working copy file. */
+      SVN_ERR(svn_stream_open_readonly(&contents, local_abspath, scratch_pool,
+                                       scratch_pool));
+
+      /* If we have EOL styles or keywords, then detranslate the file. */
+      if (svn_subst_translation_required(eol_style, eol, keywords,
+                                         FALSE, TRUE))
+        {
+          if (eol_style == svn_subst_eol_style_unknown)
+            return svn_error_createf(SVN_ERR_IO_UNKNOWN_EOL, NULL,
+                                    _("%s property on '%s' contains "
+                                      "unrecognized EOL-style '%s'"),
+                                    SVN_PROP_EOL_STYLE,
+                                    svn_dirent_local_style(local_abspath,
+                                                           scratch_pool),
+                                    eol_style_val->data);
+
+          /* We're importing, so translate files with 'native' eol-style to
+           * repository-normal form, not to this platform's native EOL. */
+          if (eol_style == svn_subst_eol_style_native)
+            eol = SVN_SUBST_NATIVE_EOL_STR;
+
+          /* Wrap the working copy stream with a filter to detranslate it. */
+          contents = svn_subst_stream_translated(contents,
+                                                 eol,
+                                                 TRUE /* repair */,
+                                                 keywords,
+                                                 FALSE /* expand */,
+                                                 scratch_pool);
+        }
+    }
+
+  *fstream = svn_stream_buffered(result_pool);
+  contents = svn_stream_checksummed2(contents, checksum, NULL,
+                                     svn_checksum_sha1, TRUE, scratch_pool);
+  SVN_ERR(svn_stream_copy3(contents, svn_stream_disown(*fstream, result_pool),
+                           NULL, NULL, scratch_pool));
+
+  return SVN_NO_ERROR;
+}