[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] --invoke-diff-cmd

From: Gabriela Gibson <gabriela.gibson_at_gmail.com>
Date: Mon, 16 Jun 2014 15:21:05 +0100

Hi,

I'm not sure how to update my branch because the underlying base has
changed(and doesn't merge all that well) and thus, I restarted with
just a patch and a copy of the current trunk.

So, just to keep things simple, I just post it as a patch for now.

Gabriela

Ps.: I'll take a look at the --invoke-diff3-cmd part this week sometime.

======================================================================
                 Introduction to --invoke-diff-cmd
======================================================================

--invoke-diff-cmd allows command line selection of an external diff
program and will be extended to cover the existing diff3 option with a
similar --invoke-diff3-cmd option.

Currently this capability is provided by user written shell scripts
which are passed as the diff program via the svn config file.

--invoke-diff-cmd is currently implemented for 'diff', 'log',
'svnlook' and the config file.

See: http://subversion.tigris.org/issues/show_bug.cgi?id=2044 for the
original motivation for this project.

What --invoke-diff-cmd provides
===============================

Users can type 'free-style' command lines for their selected
diff/merge program, and optionally select a diff command file that
applies stored commands to selected files. If the file diffed is not
in the list, the given command will be used instead.

from 'svn help diff':

   --invoke-diff-cmd ARG:

        use ARG as format string for external diff command
         invocation.

         Substitutions: %svn_new new file
                        %svn_old old file
                        %svn_label_new label of the new file
                        %svn_label_old label of the old file
         Examples:
         --invoke-diff-cmd='diff -y %svn_new %svn_old'
         --invoke-diff-cmd="kdiff3 -auto -o /home/u/log \
               %svn_new %svn_old --L1 %svn_new_label \
              --L2 "Custom Label" '
         Substitution variables may be embedded in strings:
         +%svn_new, %svn_new- and file=%svn_label_new+

Structure of the feature:
=========================

API components
--------------

    ./subversion/libsvn_subr/io.c __create_custom_diff_cmd()

    transforms the user input 'invoke-diff-cmd' into a command line
    call by substitution the labels and file names(where defined),
    whilst leaving everything else untouched.

    ./subversion/libsvn_subr/io.c svn_io_run_external_diff()

    calls __create_custom_diff_cmd() and does all the error checking
    required, before routing the result to the actual call to the APR
    routine that makes it.

UI components
-------------

   --invoke-diff-cmd and its user interface components for the command
   line have been installed everywhere where --diff-cmd is available,
   in svnlook.c, svn.c, svnlog.c.

Tests
=====

The test for the 'invoke-diff-cmd' feature is

   /subversion/tests/cmdline/diff_tests.py diff_invoke_external_diffcmd

[[[

* subversion/include/private/svn_io_private.h

   (svn_io__create_custom_diff_cmd): New function declaration.

* subversion/include/svn_config.h

   (SVN_CONFIG_OPTION_INVOKE_DIFF_CMD): New definition.

* subversion/include/svn_error_codes.h

   (SVN_CLIENT_DIFF_CMD): New macro.

* subversion/include/svn_io.h

    (svn_io_run_external_diff): New function.

* subversion/libsvn_client/diff.c

   (diff_writer_info_t): New member: 'invoke_diff_cmd'.

   (create_diff_writer_info): Add routine to read invoke_diff_cmd
     either from the commandline (preferential) or from the config
     file, after it is established that the diff-cmd is not defined on
     the commandline or in the .subversion/config file. Readjust the
     flow of the function to ensure that the internal diff routine is
     called if neither diff_cmd or invoke_diff_cmd are called.

   (diff_content_changed): Raise an error if both diff_cmd and
     invoke-diff-cmd are set. Add invoke-diff-cmd to if condition.
     Add comment explaining the presence of non-canonical path in
     function call. Call svn_io_run_external_diff if --invoke-diff-cmd
     option was specified, otherwise retain previous behaviour.

* subversion/libsvn_subr/config_file.c

   (svn_config_ensure,"invoke-diff-cmd"): New entry: invoke-diff-cmd.
     Add help info.

* subversion/libsvn_subr/io.c

   (svn_io__create_custom_diff_cmd): New function.

   (svn_io_run_external_diff): New function.

* subversion/svn/cl.h

   (struct svn_cl__opt_state_t.diff): New member: 'invoke_diff_cmd'.

* subversion/svn/log-cmd.c

   (log_receiver_baton): New struct member invoke_diff_cmd.

   (svn_cl__log): Ensure mutual exclusions between invoke_diff_cmd and
     diff-cmd. Require 'diff' option to be set when requesting
     invoke_diff option. Populate log_receiver_baton member
     invoke_diff_cmd.

* subversion/svnlook/svnlook.c

   (enum): New variable svnlook__invoke_diff_cmd.

   (options_table[]): New entry 'invoke-diff-cmd'.

   (cmd_tablcmd[]): Add svnlook__invoke_diff_cmd to diff cmd table
     entry.

   (svnlook_opt_state): New member variable "invoke_diff_cmd". Adjust
     comment alignment on diff-cmd.

   (svnlook_ctxt_t): New member variable "invoke_diff_cmd".

   (print_diff_tree): Modify 'if condition' to include new
     invoke_diff_cmd. Add conditional call to
     /include/svn_io.c:svn_io_run_external_diff().

   (get_ctxt_baton): Assign invoke_diff_cmd data.

   (main): Add case svnlook__invoke_diff_cmd. Assign opt_arg to
     opt_state.invoke_diff_cmd. Add exclusiveness test for
     invoke_diff_cmd and diff_cmd.

* subversion/svn/svn.c

   (svn_cl__longopt_t): New enum opt_invoke_diff_cmd.

   (svn_cl__options "invoke-diff-cmd"): Add help information. Add new
     variable 'opt_invoke_diff_cmd'.

   (svn_cl__cmd_table[]): New option: 'invoke-diff-cmd', help info. Add
     opt_invoke_diff_cmd to svn_cl__log entry. Add opt_invoke_diff_cmd
     to the list of valid subcommands.

   (sub_main): Add case opt_invoke_diff_cmd. Prohibit simultaneous
     usage of --invoke-diff-cmd and --internal-diff. Prohibit
     simultaneous usage of --diff-cmd and --invoke-diff-cmd. Add call
     to svn_config_set.

* subversion/tests/cmdline/diff_tests.py

   (diff_invoke_external_diffcmd): New function.

   (test_list): Add new entry 'diff_invoke_external_diffcmd'.

* subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout

   (--invoke-diff-cmd): Add new entry to 'help' output data.

]]]

Received on 2014-06-16 16:21:33 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.