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/11/01 18:01:43 UTC

svn commit: r1537987 - in /subversion/branches/invoke-diff-cmd-feature: BRANCH-README diff_cmd_config subversion/include/svn_io.h subversion/libsvn_subr/io.c subversion/svn/svn.c

Author: gbg
Date: Fri Nov  1 17:01:43 2013
New Revision: 1537987

URL: http://svn.apache.org/r1537987
Log:
On the invoke-diff-cmd branch: Continuation from r1535411: Adjust
substitution syntax to %svn_(label)_[old|new|mine|yours|base].  Update
string assigment to use apr_pstrdup.

* subversion/libsvn_subr/io.c

  (__create_custom_diff_cmd): Update substitution syntax.  Update
    string assigment to use apr_pstrdup.

* subversion/svn/svn.c
  (svn_cl__options[], "invoke-diff-cmd"): Update help info.
  
* BRANCH-README: Update.

Removed:
    subversion/branches/invoke-diff-cmd-feature/diff_cmd_config
Modified:
    subversion/branches/invoke-diff-cmd-feature/BRANCH-README
    subversion/branches/invoke-diff-cmd-feature/subversion/include/svn_io.h
    subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_subr/io.c
    subversion/branches/invoke-diff-cmd-feature/subversion/svn/svn.c

Modified: subversion/branches/invoke-diff-cmd-feature/BRANCH-README
URL: http://svn.apache.org/viewvc/subversion/branches/invoke-diff-cmd-feature/BRANCH-README?rev=1537987&r1=1537986&r2=1537987&view=diff
==============================================================================
--- subversion/branches/invoke-diff-cmd-feature/BRANCH-README (original)
+++ subversion/branches/invoke-diff-cmd-feature/BRANCH-README Fri Nov  1 17:01:43 2013
@@ -35,29 +35,20 @@ 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_new_label%  label of the new file  
-                    %svn_old_label%  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" '                          
-     Other constructs possible are:                         
-     +%svn_new%, %svn_new%- and +++%svn_new_label%+++       
-     With optional switch given at the start of the command:
-     --svn-cfg-file=/path/to/config-file (automatic)        
-     Read config file, apply the diff-cmds stored in there  
-     --query-cfg-file=/path/to/config-file (interactive)    
-     As above, but query interactively.                     
-     Example: svn diff --invoke-diff-cmd='--svn-cfg-file\  
-      /home/user/diff_cmds diff -u %svn_new% %svn-old%'     
-     Config file format: (accepts # comments)               
-     relative/path/to/file/ = diff %svn_new% ...            
+       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:
@@ -149,23 +140,7 @@ The test for the updated --diff-cmd is 
 TODO:
 ====
 
-  * refactor svn_io_parse_mimetypes_file() into a more general
-    svn_io_read_text_file().
-
-  * add code for the interactive switch, bearing in mind 3rd party
-    clients.(needs more research)
-
-  * Adding invoke-diff-cmd to merge:
-    add --invoke-diff-3-cmd using the svn_io_create_custom_diff_cmd()
-    and creating a new svn_io_run_external_merge function to manage
-    the external call in the same way that svn_io_run_external_diff
-    does.  Add the necessary UI components.  Add --invoke-diff-3-cmd
-    to 'svn up'.
-
-  * Fix the issue of unclear labels being displayed in external merge
-    programs:
-
-       http://subversion.tigris.org/issues/show_bug.cgi?id=3836
+  * Finalise the discussion about which substitution syntax to choose.
 
 
 Review tools

Modified: subversion/branches/invoke-diff-cmd-feature/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/branches/invoke-diff-cmd-feature/subversion/include/svn_io.h?rev=1537987&r1=1537986&r2=1537987&view=diff
==============================================================================
--- subversion/branches/invoke-diff-cmd-feature/subversion/include/svn_io.h (original)
+++ subversion/branches/invoke-diff-cmd-feature/subversion/include/svn_io.h Fri Nov  1 17:01:43 2013
@@ -2426,17 +2426,6 @@ svn_io_run_external_diff(const char *dir
                          const char *external_diff_cmd,
                          apr_pool_t *scratch_pool);
 
-
-/** Open the diff_cmd file which contains custom diff commands
- *  pertaining to individual files.
- *  
- *  @since New in 1.9.
- */
-svn_error_t *
-svn_io_parse_diff_cmd_file(const char *diff_cmd_file,
-                           apr_array_header_t *diff_file_data,
-                           apr_pool_t *pool);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

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=1537987&r1=1537986&r2=1537987&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 Fri Nov  1 17:01:43 2013
@@ -3023,21 +3023,21 @@ __create_custom_diff_cmd(const char *lab
     const char *delimiter;
     const char *replace;
   } tokens_tab[] = {  /* Diff terminology */
-    { "%svn_old_label%", label1 },
-    { "%svn_new_label%", label2 },
-    { "%svn_base_label%", label3 },
-    { "%svn_old%", from },  
-    { "%svn_new%", to },    
-    { "%svn_base%", base },    
+    { "%svn_label_old",  label1 },
+    { "%svn_label_new",  label2 },
+    { "%svn_label_base", label3 },
+    { "%svn_old",  from },  
+    { "%svn_new",  to   },    
+    { "%svn_base", base },    
     { NULL, NULL }
   };
  
   if (label3) /* Merge terminology */
     {
-      tokens_tab[0].delimiter = "%svn_from_label%";
-      tokens_tab[1].delimiter = "%svn_to_label%";
-      tokens_tab[3].delimiter = "%svn_from%";
-      tokens_tab[4].delimiter = "%svn_to%";
+      tokens_tab[0].delimiter = "%svn_label_mine";
+      tokens_tab[1].delimiter = "%svn_label_yours";
+      tokens_tab[3].delimiter = "%svn_mine";
+      tokens_tab[4].delimiter = "%svn_yours";
     }
 
   words = svn_cstring_split(cmd, " ", TRUE, scratch_pool);
@@ -3089,71 +3089,13 @@ __create_custom_diff_cmd(const char *lab
                                 strlen(tokens_tab[i].replace));
           i = delimiters;
         }
-      result[argv] = apr_pstrdup(scratch_pool, word->data); 
+      result[argv] = apr_pstrdup(pool,word->data);
     }  
   result[argv] = NULL;
   svn_pool_destroy(scratch_pool);
   return result;
 }
 
-/* Copy pasta from svn_io_parse_mimetypes_file below.  Should really
-refactor this as a generalised wrap that calls any given file and just
-hands back a stuffed array_header_t of the contents and lets the
-caller deal with the result.  (but that's for another patch)
-*/
-svn_error_t *
-svn_io_parse_diff_cmd_file(const char *diff_cmd_file,
-                           apr_array_header_t *diff_file_data,
-                           apr_pool_t *pool)
-{
-  svn_error_t *err = SVN_NO_ERROR;
-  svn_boolean_t eof = FALSE;
-  svn_stringbuf_t *buf;
-  apr_pool_t *subpool = svn_pool_create(pool);
-  apr_file_t *types_file;
-  svn_stream_t *mimetypes_stream;
-
-  SVN_ERR(svn_io_file_open(&types_file, diff_cmd_file,
-                           APR_READ, APR_OS_DEFAULT, pool));
-  mimetypes_stream = svn_stream_from_aprfile2(types_file, FALSE, pool);
-
-  while (1)
-    {
-      svn_pool_clear(subpool);
-
-      /* Read a line. */
-      if ((err = svn_stream_readline(mimetypes_stream, &buf,
-                                     APR_EOL_STR, &eof, subpool)))
-        break;
-
-      /* Only pay attention to non-empty, non-comment lines. */
-      if (buf->len)
-        {
-          if (buf->data[0] == '#')
-            continue;
-
-          APR_ARRAY_PUSH(diff_file_data,  char*)
-            = apr_pstrdup(pool, buf->data);
-        }
-      if (eof)
-        break;
-    }
-  svn_pool_destroy(subpool);
-
-  /* If there was an error above, close the file (ignoring any error
-     from *that*) and return the originally error. */
-  if (err)
-    {
-      svn_error_clear(svn_stream_close(mimetypes_stream));
-      return err;
-    }
-
-  /* Close the stream (which closes the underlying file, too). */
-  SVN_ERR(svn_stream_close(mimetypes_stream));
-
-  return SVN_NO_ERROR;
-}
-
 svn_error_t *
 svn_io_run_external_diff(const char *dir,
                          const char *label1,
@@ -3166,88 +3108,17 @@ svn_io_run_external_diff(const char *dir
                          const char *external_diff_cmd,
                          apr_pool_t *pool)
 {
-  int exitcode, file_in_list = 0, has_switch = 0;
+  int exitcode;
   const char ** cmd;
-  char *diff_cmd, *the_config;
-  apr_array_header_t *diff_file_data;
-  svn_stringbuf_t *the_cmd;
-  apr_array_header_t *words;
+
   apr_pool_t *scratch_pool = svn_pool_create(pool); 
 
   if (0 == strlen(external_diff_cmd)) 
      return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL, NULL);
 
-  diff_cmd = apr_palloc(pool, 
-                        ( (sizeof(external_diff_cmd)+1) *sizeof(char *) ) );
-
-  if (strstr(external_diff_cmd, "--svn-cfg-file-query") ) 
-    has_switch = 2; 
-  else if (strstr(external_diff_cmd, "--svn-cfg-file"))
-    has_switch = 1;
-  
-  the_cmd = svn_stringbuf_create_empty(scratch_pool); 
-  
-  if (has_switch)
-    {
-      int i;
-
-      diff_file_data = apr_array_make(scratch_pool, 0, sizeof(char*));
-
-      words = apr_array_make(scratch_pool, 0, sizeof(char **));
-      words = svn_cstring_split(external_diff_cmd, " ", TRUE, scratch_pool);
-
-      the_config = apr_palloc(pool, sizeof(APR_ARRAY_IDX(words, 1, char*)) );       
-      the_config = APR_ARRAY_IDX(words, 1, char*); 
-      
-      SVN_ERR(svn_io_parse_diff_cmd_file(the_config,
-                                         diff_file_data,
-                                         scratch_pool));
-
-      for (i = 0; i < diff_file_data->nelts;  i++)
-        {
-          apr_array_header_t *tokens;
-
-          tokens = svn_cstring_split(APR_ARRAY_IDX(diff_file_data, 
-                                                   i, char *), 
-                                     "=", TRUE, scratch_pool);
-
-          if (strstr(label1, APR_ARRAY_IDX(tokens, 0, char *)) )
-            {
-              diff_cmd = APR_ARRAY_IDX(tokens, 1, char *);
-              i = diff_file_data->nelts; /* found, so we're done here */
-              file_in_list = 1;
-            }
-        }
-
-      if (file_in_list)
-        {
-
-          if (2 == has_switch)
-            {
-              /* here we'd show the user the two different cmds and
-                 let them choose which one.  Not built yet, b/c I've
-                 not worked out yet how to make a hook for a client
-                 here.
-              */
-              ;
-            }
-        }
-      else  
-        { /* build the command from what's in the external_diff_cmd */
-          for (i = 2; i < words->nelts;  i++) 
-            {
-              svn_stringbuf_appendcstr(the_cmd, APR_ARRAY_IDX(words, i, char *));
-              svn_stringbuf_appendcstr(the_cmd, " ");
-            }
-          diff_cmd = apr_pstrdup(scratch_pool, the_cmd->data); 
-        }
-    } /* close has_switch */
-  else /* no switch found, just a diff cmd */
-    diff_cmd = apr_pstrdup(scratch_pool, external_diff_cmd);
-
   cmd = __create_custom_diff_cmd(label1, label2, NULL, 
                                  tmpfile1, tmpfile2, NULL, 
-                                 diff_cmd, scratch_pool);
+                                 external_diff_cmd, scratch_pool);
   if (pexitcode == NULL)
      pexitcode = &exitcode;
   

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=1537987&r1=1537986&r2=1537987&view=diff
==============================================================================
--- subversion/branches/invoke-diff-cmd-feature/subversion/svn/svn.c (original)
+++ subversion/branches/invoke-diff-cmd-feature/subversion/svn/svn.c Fri Nov  1 17:01:43 2013
@@ -350,27 +350,27 @@ const apr_getopt_option_t svn_cl__option
                       "                             "
                       "invocation. \n                                         \n" 
                       "                             "
-                      "Substitutions: %svn_new% new file                      \n"
+                      "Substitutions: %svn_new new file                       \n"
                       "                             "
-                      "               %svn_old% old file                      \n"
+                      "               %svn_old old file                       \n"
                       "                             "
-                      "               %svn_new_label%  label of the new file  \n"
+                      "               %svn_label_new  label of the new file   \n"
                       "                             "
-                      "               %svn_old_label%  label of the old file  \n"
+                      "               %svn_label_old  label of the old file   \n"
                       "                             "
                       "Examples:                                              \n"
                       "                             "
-                      "--invoke-diff-cmd=\'diff -y %svn_new% %svn_old%\'      \n"          
+                      "--invoke-diff-cmd=\'diff -y %svn_new %svn_old\'        \n"          
                       "                             "
                       "--invoke-diff-cmd=\"kdiff3 -auto -o /home/u/log \\     \n"
                       "                             "
-                      "      %svn_new% %svn_old% --L1 %svn_new_label% \\      \n"
+                      "      %svn_new %svn_old --L1 %svn_label_new \\         \n"
                       "                             "
                       "     --L2 \"Custom Label\" \'                          \n"
                       "                             "
-                      "Other constructs possible are:                         \n"
+                      "Substitution variables may be embedded in strings:     \n"
                       "                             "
-                      "+%svn_new%, %svn_new%- and +++%svn_new_label%+++       \n"
+                      "+%svn_new, %svn_new- and file=%svn_label_new+          \n"
                       "                             "
                       "With optional switch given at the start of the command:\n"                       
                                     "                             "