Author: julianfoad
Date: Tue May 29 15:48:34 2012
New Revision: 1343789
URL: http://svn.apache.org/viewvc?rev=1343789&view=rev
Log:
Factor out the 'log --diff' code into a separate function.
* subversion/svn/log-cmd.c
(display_diff): New function, extracted ...
(log_entry_receiver): ... from here.
Modified:
subversion/trunk/subversion/svn/log-cmd.c
Modified: subversion/trunk/subversion/svn/log-cmd.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/log-cmd.c?rev=1343789&r1=1343788&r2=1343789&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/log-cmd.c (original)
+++ subversion/trunk/subversion/svn/log-cmd.c Tue May 29 15:48:34 2012
@@ -80,6 +80,67 @@ struct log_receiver_baton
"------------------------------------------------------------------------\n"
+/* Display a diff of the subtree TARGET_PATH_OR_URL@TARGET_PEG_REVISION as
+ * it changed in the revision that LOG_ENTRY describes.
+ *
+ * Restrict the diff to depth DEPTH. Pass DIFF_EXTENSIONS along to the diff
+ * subroutine.
+ *
+ * Write the diff to OUTSTREAM and write any stderr output to ERRSTREAM.
+ * ### How is exit code handled? 0 and 1 -> SVN_NO_ERROR, else an svn error?
+ * ### Should we get rid of ERRSTREAM and use svn_error_t instead?
+ */
+static svn_error_t *
+display_diff(const svn_log_entry_t *log_entry,
+ const char *target_path_or_url,
+ const svn_opt_revision_t *target_peg_revision,
+ svn_depth_t depth,
+ const char *diff_extensions,
+ svn_stream_t *outstream,
+ svn_stream_t *errstream,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *pool)
+{
+ apr_array_header_t *diff_options;
+ svn_opt_revision_t start_revision;
+ svn_opt_revision_t end_revision;
+
+ /* Fall back to "" to get options initialized either way. */
+ if (diff_extensions)
+ diff_options = svn_cstring_split(diff_extensions, " \t\n\r",
+ TRUE, pool);
+ else
+ diff_options = NULL;
+
+ start_revision.kind = svn_opt_revision_number;
+ start_revision.value.number = log_entry->revision - 1;
+ end_revision.kind = svn_opt_revision_number;
+ end_revision.value.number = log_entry->revision;
+
+ SVN_ERR(svn_stream_puts(outstream, _("\n")));
+ SVN_ERR(svn_client_diff_peg6(diff_options,
+ target_path_or_url,
+ target_peg_revision,
+ &start_revision, &end_revision,
+ NULL,
+ depth,
+ FALSE, /* ignore ancestry */
+ TRUE, /* no diff deleted */
+ FALSE, /* show copies as adds */
+ FALSE, /* ignore content type */
+ FALSE, /* ignore prop diff */
+ FALSE, /* properties only */
+ FALSE, /* use git diff format */
+ svn_cmdline_output_encoding(pool),
+ outstream,
+ errstream,
+ NULL,
+ ctx, pool));
+ SVN_ERR(svn_stream_puts(outstream, _("\n")));
+ return SVN_NO_ERROR;
+}
+
+
/* Implement `svn_log_entry_receiver_t', printing the logs in
* a human-readable and machine-parseable format.
*
@@ -282,45 +343,16 @@ log_entry_receiver(void *baton,
{
svn_stream_t *outstream;
svn_stream_t *errstream;
- apr_array_header_t *diff_options;
- svn_opt_revision_t start_revision;
- svn_opt_revision_t end_revision;
SVN_ERR(svn_stream_for_stdout(&outstream, pool));
SVN_ERR(svn_stream_for_stderr(&errstream, pool));
- /* Fall back to "" to get options initialized either way. */
- if (lb->diff_extensions)
- diff_options = svn_cstring_split(lb->diff_extensions, " \t\n\r",
- TRUE, pool);
- else
- diff_options = NULL;
+ SVN_ERR(display_diff(log_entry,
+ lb->target_path_or_url, &lb->target_peg_revision,
+ lb->depth, lb->diff_extensions,
+ outstream, errstream,
+ lb->ctx, pool));
- start_revision.kind = svn_opt_revision_number;
- start_revision.value.number = log_entry->revision - 1;
- end_revision.kind = svn_opt_revision_number;
- end_revision.value.number = log_entry->revision;
-
- SVN_ERR(svn_stream_puts(outstream, _("\n")));
- SVN_ERR(svn_client_diff_peg6(diff_options,
- lb->target_path_or_url,
- &lb->target_peg_revision,
- &start_revision, &end_revision,
- NULL,
- lb->depth,
- FALSE, /* ignore ancestry */
- TRUE, /* no diff deleted */
- FALSE, /* show copies as adds */
- FALSE, /* ignore content type */
- FALSE, /* ignore prop diff */
- FALSE, /* properties only */
- FALSE, /* use git diff format */
- svn_cmdline_output_encoding(pool),
- outstream,
- errstream,
- NULL,
- lb->ctx, pool));
- SVN_ERR(svn_stream_puts(outstream, _("\n")));
SVN_ERR(svn_stream_close(outstream));
SVN_ERR(svn_stream_close(errstream));
}