You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gb...@apache.org on 2013/06/01 14:49:15 UTC
svn commit: r1488516 - in
/subversion/branches/invoke-diff-cmd-feature/subversion:
libsvn_client/diff.c libsvn_subr/io.c svn/log-cmd.c svn/svn.c
Author: gbg
Date: Sat Jun 1 12:49:15 2013
New Revision: 1488516
URL: http://svn.apache.org/r1488516
Log:
On the invoke-diff-cmd branch: Add invoke-diff-cmd option to the log
command. Refactor failed_command code. Expand help info. Tidy code.
* subversion/libsvn_client/diff.c
(set_up_diff_cmd_and_options): Assign variable at declaration time.
Tidy code.
* subversion/libsvn_subr/io.c
(svn_io_run_external_diff): Use safer apr_pstrcat function instead
of strcat. Remove call to svn_dirent_local_style.
* subversion/svn/log-cmd.c
(log_receiver_baton): New struct member invoke_diff_cmd.
(display_diff): New parameter 'invoke_diff_cmd' . Pass
invoke_diff_cmd parameter into svn_client_diff_peg7().
(log_entry_receiver): Pass invoke_diff_cmd into display_diff().
(svn_cl__log): Ensure mutual exclusions between invoke_diff_cmd and
quiet and diff-cmd, require 'diff' option. Populate
log_receiver_baton member invoke_diff_cmd. Tidy code.
(svn_cl__options): Expand help info for invoke-diff-cmd option.
* subversion/svn/svn.c
(svn_cl__cmd_table): Add opt_invoke_diff_cmd to the list of valid
subcommands.
Modified:
subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c
subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_subr/io.c
subversion/branches/invoke-diff-cmd-feature/subversion/svn/log-cmd.c
subversion/branches/invoke-diff-cmd-feature/subversion/svn/svn.c
Modified: subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c
URL: http://svn.apache.org/viewvc/subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c?rev=1488516&r1=1488515&r2=1488516&view=diff
==============================================================================
--- subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c (original)
+++ subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c Sat Jun 1 12:49:15 2013
@@ -2465,14 +2465,16 @@ set_up_diff_cmd_and_options(struct diff_
/* old style diff_cmd has precedence in config file */
if (config)
{
- svn_config_t *cfg = svn_hash_gets(config, SVN_CONFIG_CATEGORY_CONFIG);
-
+ svn_config_t *cfg;
+
+ cfg = svn_hash_gets(config, SVN_CONFIG_CATEGORY_CONFIG);
+
svn_config_get(cfg, &diff_cmd, SVN_CONFIG_SECTION_HELPERS,
SVN_CONFIG_OPTION_DIFF_CMD, NULL);
if (options == NULL)
{
const char *diff_extensions;
-
+
svn_config_get(cfg, &diff_extensions, SVN_CONFIG_SECTION_HELPERS,
SVN_CONFIG_OPTION_DIFF_EXTENSIONS, NULL);
if (diff_extensions)
@@ -2481,7 +2483,7 @@ set_up_diff_cmd_and_options(struct diff_
}
if (options == NULL)
options = apr_array_make(pool, 0, sizeof(const char *));
-
+
if (diff_cmd)
SVN_ERR(svn_path_cstring_to_utf8(&diff_cmd_baton->diff_cmd,
diff_cmd, pool));
@@ -2490,8 +2492,8 @@ set_up_diff_cmd_and_options(struct diff_
if (config) /* check if there is a invoke_diff_cmd in the config file */
{
svn_config_t *cfg;
-
- cfg = svn_hash_gets(config, SVN_CONFIG_CATEGORY_CONFIG);
+
+ cfg = svn_hash_gets(config, SVN_CONFIG_CATEGORY_CONFIG);
diff_cmd_baton->diff_cmd = NULL;
svn_config_get(cfg, &diff_cmd, SVN_CONFIG_SECTION_HELPERS,
SVN_CONFIG_OPTION_INVOKE_DIFF_CMD, NULL);
@@ -2499,7 +2501,6 @@ set_up_diff_cmd_and_options(struct diff_
{
SVN_ERR(svn_path_cstring_to_utf8(&diff_cmd_baton->invoke_diff_cmd,
diff_cmd, pool));
-
return SVN_NO_ERROR;
}
}
Modified: subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_subr/io.c?rev=1488516&r1=1488515&r2=1488516&view=diff
==============================================================================
--- subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_subr/io.c Sat Jun 1 12:49:15 2013
@@ -3029,27 +3029,21 @@ svn_io_run_external_diff(const char *dir
NULL, outfile, errfile, pool));
if (*pexitcode != 0 && *pexitcode != 1)
- {
- int i, size;
- char * failed_command;
-
- for (i = 0, size = 0; cmd[i]; i++)
- size += strlen(cmd[i]) + 1;
-
- failed_command = apr_palloc(pool, size * sizeof(char *));
-
- for (i = 0; cmd[i]; i++)
- {
- strcat(failed_command, cmd[i]);
- strcat(failed_command, " ");
- }
-
- return svn_error_createf(SVN_ERR_EXTERNAL_PROGRAM, NULL,
- _("'%s' was expanded to '%s' and returned %d"),
- external_diff_cmd,
- svn_dirent_local_style(failed_command, pool),
- *pexitcode);
- }
+ {
+ int i;
+ const char *failed_command = "";
+
+ for (i = 0; cmd[i]; ++i)
+ {
+ failed_command = apr_pstrcat(pool, failed_command, cmd[i], NULL);
+ failed_command = apr_pstrcat(pool, failed_command, " ", NULL);
+ }
+ return svn_error_createf(SVN_ERR_EXTERNAL_PROGRAM, NULL,
+ _("'%s' was expanded to '%s' and returned %d"),
+ external_diff_cmd,
+ failed_command,
+ *pexitcode);
+ }
return SVN_NO_ERROR;
}
Modified: subversion/branches/invoke-diff-cmd-feature/subversion/svn/log-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/invoke-diff-cmd-feature/subversion/svn/log-cmd.c?rev=1488516&r1=1488515&r2=1488516&view=diff
==============================================================================
--- subversion/branches/invoke-diff-cmd-feature/subversion/svn/log-cmd.c (original)
+++ subversion/branches/invoke-diff-cmd-feature/subversion/svn/log-cmd.c Sat Jun 1 12:49:15 2013
@@ -67,6 +67,9 @@ struct log_receiver_baton
/* Diff arguments received from command line. */
const char *diff_extensions;
+ /* Custom diff command. */
+ const char *invoke_diff_cmd;
+
/* Stack which keeps track of merge revision nesting, using svn_revnum_t's */
apr_array_header_t *merge_stack;
@@ -102,6 +105,7 @@ display_diff(const svn_log_entry_t *log_
const char *diff_extensions,
svn_stream_t *outstream,
svn_stream_t *errstream,
+ const char *invoke_diff_cmd,
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
@@ -140,8 +144,7 @@ display_diff(const svn_log_entry_t *log_
outstream,
errstream,
NULL,
- NULL,
- /* invoke_diff_cmd, */
+ invoke_diff_cmd,
ctx, pool));
SVN_ERR(svn_stream_puts(outstream, _("\n")));
return SVN_NO_ERROR;
@@ -468,6 +471,7 @@ log_entry_receiver(void *baton,
lb->target_path_or_url, &lb->target_peg_revision,
lb->depth, lb->diff_extensions,
outstream, errstream,
+ lb->invoke_diff_cmd,
lb->ctx, pool));
SVN_ERR(svn_stream_close(outstream));
@@ -705,25 +709,38 @@ svn_cl__log(apr_getopt_t *os,
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("'diff' option is not supported in "
"XML mode"));
- }
+ }
+ if (opt_state->diff.diff_cmd && opt_state->diff.diff_cmd)
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("'diff-cmd' and 'invoke-diff-cmd' options are "
+ "mutually exclusive"));
+
if (opt_state->quiet && opt_state->show_diff)
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("'quiet' and 'diff' options are "
"mutually exclusive"));
+
if (opt_state->diff.diff_cmd && (! opt_state->show_diff))
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("'diff-cmd' option requires 'diff' "
"option"));
+
if (opt_state->diff.internal_diff && (! opt_state->show_diff))
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("'internal-diff' option requires "
"'diff' option"));
+
if (opt_state->extensions && (! opt_state->show_diff))
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("'extensions' option requires 'diff' "
"option"));
+ if (opt_state->diff.invoke_diff_cmd && (! opt_state->show_diff))
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("'invoke-diff-cmd' option requires 'diff' "
+ "option"));
+
if (opt_state->depth != svn_depth_unknown && (! opt_state->show_diff))
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("'depth' option requires 'diff' option"));
@@ -787,6 +804,7 @@ svn_cl__log(apr_getopt_t *os,
lb.depth = opt_state->depth == svn_depth_unknown ? svn_depth_infinity
: opt_state->depth;
lb.diff_extensions = opt_state->extensions;
+ lb.invoke_diff_cmd = opt_state->diff.invoke_diff_cmd;
lb.merge_stack = apr_array_make(pool, 0, sizeof(svn_revnum_t));
lb.search_patterns = opt_state->search_patterns;
lb.pool = pool;
Modified: subversion/branches/invoke-diff-cmd-feature/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/branches/invoke-diff-cmd-feature/subversion/svn/svn.c?rev=1488516&r1=1488515&r2=1488516&view=diff
==============================================================================
--- subversion/branches/invoke-diff-cmd-feature/subversion/svn/svn.c (original)
+++ subversion/branches/invoke-diff-cmd-feature/subversion/svn/svn.c Sat Jun 1 12:49:15 2013
@@ -342,15 +342,19 @@ const apr_getopt_option_t svn_cl__option
" "
"invocation. \n \n"
" "
- "Substitutions: %f1% %f2% files to compare \n"
+ "Substitutions: %f1% original file \n"
" "
- " %l1% %l2% user defined labels \n"
+ " %f2% changed file \n"
" "
- "Examples: --invoke-diff-cmd=\"diff -y %f1% %f2% \n"
+ " %l1% label of the original file \n"
+ " "
+ " %l2% label of the changed file \n"
+ " "
+ "Examples: --invoke-diff-cmd=\"diff -y %f1% %f2%\" \n"
" "
" --invoke-diff-cmd=\"kdiff3 -auto -o /home/u/log \\ \n"
" "
- " %f1% %f2% --L1 %l1% --L2 \"Custom Label\" \" \n"
+ " +%f1% %f2% --L1 %l1% --L2 \"Custom Label\" \" \n"
" "
"The switch symbol '%' can be escaped in the usual way \n"
" "
@@ -761,7 +765,7 @@ const svn_opt_subcommand_desc2_t svn_cl_
{'r', 'q', 'v', 'g', 'c', opt_targets, opt_stop_on_copy, opt_incremental,
opt_xml, 'l', opt_with_all_revprops, opt_with_no_revprops, opt_with_revprop,
opt_depth, opt_diff, opt_diff_cmd, opt_internal_diff, 'x', opt_search,
- opt_search_and, },
+ opt_search_and, opt_invoke_diff_cmd },
{{opt_with_revprop, N_("retrieve revision property ARG")},
{'c', N_("the change made in revision ARG")}} },