Author: dannas
Date: Wed Sep 8 19:18:29 2010
New Revision: 995210
URL: http://svn.apache.org/viewvc?rev=995210&view=rev
Log:
In the patch code, factor out the code dealing with closing streams to
its own function for readability.
* subversion/libsvn_client/patch.c
(close_target_streams): New. Created with code from ...
(apply_one_patch): .. here.
Suggested by: stsp
Modified:
subversion/trunk/subversion/libsvn_client/patch.c
Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=995210&r1=995209&r2=995210&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Wed Sep 8 19:18:29 2010
@@ -1599,6 +1599,45 @@ send_patch_notification(const patch_targ
return SVN_NO_ERROR;
}
+/* Close the streams of the TARGET so that their content is flushed
+ * to disk. This will also close underlying streams and files. Use POOL for
+ * temporary allocations. */
+static svn_error_t *
+close_target_streams(const patch_target_t *target,
+ apr_pool_t *pool)
+{
+ apr_hash_index_t *hi;
+ target_content_info_t *prop_content_info;
+
+ /* First the streams belonging to properties .. */
+ for (hi = apr_hash_first(pool, target->prop_targets);
+ hi;
+ hi = apr_hash_next(hi))
+ {
+ prop_patch_target_t *prop_target;
+ prop_target = svn__apr_hash_index_val(hi);
+ prop_content_info = prop_target->content_info;
+
+ /* ### If the prop did not exist pre-patching we'll not have a
+ * ### stream to read from. Find a better way to store info on
+ * ### the existence of the target prop. */
+ if (prop_content_info->stream)
+ SVN_ERR(svn_stream_close(prop_content_info->stream));
+
+ SVN_ERR(svn_stream_close(prop_content_info->patched));
+ }
+
+
+ /* .. And then streams associted with the file. The reject stream is
+ * shared between all target_content_info structures. */
+ if (target->kind_on_disk == svn_node_file)
+ SVN_ERR(svn_stream_close(target->content_info->stream));
+ SVN_ERR(svn_stream_close(target->content_info->patched));
+ SVN_ERR(svn_stream_close(target->content_info->reject));
+
+ return SVN_NO_ERROR;
+}
+
/* Apply a PATCH to a working copy at ABS_WC_PATH and put the result
* into temporary files, to be installed in the working copy later.
* Return information about the patch target in *PATCH_TARGET, allocated
@@ -1815,40 +1854,7 @@ apply_one_patch(patch_target_t **patch_t
svn_pool_destroy(iterpool);
- /* ### Move this a separate function? apply_one_patch() has gotten quite
- * ### big. We should consider splitting it up into several pieces. */
- {
- apr_hash_index_t *hi;
- target_content_info_t *prop_content_info;
-
- /* Close the streams of the target so that their content is flushed
- * to disk. This will also close underlying streams and files.
- * First the streams belonging to properties .. */
- for (hi = apr_hash_first(result_pool, target->prop_targets);
- hi;
- hi = apr_hash_next(hi))
- {
- prop_patch_target_t *prop_target;
- prop_target = svn__apr_hash_index_val(hi);
- prop_content_info = prop_target->content_info;
-
- /* ### If the prop did not exist pre-patching we'll not have a
- * ### stream to read from. Find a better way to store info on
- * ### the existence of the target prop. */
- if (prop_content_info->stream)
- SVN_ERR(svn_stream_close(prop_content_info->stream));
-
- SVN_ERR(svn_stream_close(prop_content_info->patched));
- }
-
-
- /* .. And then streams associted with the file. The reject stream is
- * shared between all target_content_info structures. */
- if (target->kind_on_disk == svn_node_file)
- SVN_ERR(svn_stream_close(target->content_info->stream));
- SVN_ERR(svn_stream_close(target->content_info->patched));
- SVN_ERR(svn_stream_close(target->content_info->reject));
- }
+ SVN_ERR(close_target_streams(target, scratch_pool));
if (! target->skipped)
{