Author: julianfoad
Date: Mon Jul  9 10:34:28 2018
New Revision: 1835407

URL: http://svn.apache.org/viewvc?rev=1835407&view=rev
Log:
Shelving: implement shelf diff summary mode.

"svn shelf-diff --summarize"

* subversion/include/private/svn_client_private.h,
  subversion/libsvn_client/client.h,
  subversion/libsvn_client/diff_summarize.c
  (svn_client__get_diff_summarize_callbacks): Move from a private to a
    semi-public header file. Remove 'const' from the output parameter.

* subversion/libsvn_client/diff.c
  (svn_client_diff_summarize2,
   svn_client_diff_summarize_peg2): Tweak to match that 'const' change.

* subversion/svn/cl.h,
  subversion/svn/diff-cmd.c
  (svn_cl__get_diff_summarize): Newly exposed API.
  (svn_cl__diff): Use it.

* subversion/svn/shelf-cmd.c
  (shelf_diff): Implement summary mode.

* subversion/svn/svn.c
  (svn_cl__cmd_table): Add '--summarize' option to shelf-diff.

* subversion/tests/cmdline/shelf_tests.py
  (shelf_diff_simple): Extend to test summary mode.

* tools/client-side/bash_completion
  (_svn): Add '--summarize' option to shelf-diff.

Modified:
    subversion/trunk/subversion/include/private/svn_client_private.h
    subversion/trunk/subversion/libsvn_client/client.h
    subversion/trunk/subversion/libsvn_client/diff.c
    subversion/trunk/subversion/libsvn_client/diff_summarize.c
    subversion/trunk/subversion/svn/cl.h
    subversion/trunk/subversion/svn/diff-cmd.c
    subversion/trunk/subversion/svn/shelf-cmd.c
    subversion/trunk/subversion/svn/svn.c
    subversion/trunk/subversion/tests/cmdline/shelf_tests.py
    subversion/trunk/tools/client-side/bash_completion

Modified: subversion/trunk/subversion/include/private/svn_client_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_client_private.h?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_client_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_client_private.h Mon Jul  9 
10:34:28 2018
@@ -386,6 +386,29 @@ svn_client__shelf_diff(svn_client_shelf_
                        svn_diff_tree_processor_t *diff_processor,
                        apr_pool_t *scratch_pool);
 
+/*** Editor for diff summary ***/
+
+/* Set *DIFF_PROCESSOR to a diff processor that will report a diff summary
+   to SUMMARIZE_FUNC.
+
+   P_ROOT_RELPATH will return a pointer to a string that must be set,
+   before the processor is called, to a prefix that will be found on
+   every DIFF_PROCESSOR relpath, that will be removed before passing
+   the path to SUMMARIZE_FUNC.
+
+   ORIGINAL_TARGET is not used.
+
+   SUMMARIZE_FUNC is called with SUMMARIZE_BATON as parameter by the
+   created callbacks for each changed item.
+*/
+svn_error_t *
+svn_client__get_diff_summarize_callbacks(
+                        svn_diff_tree_processor_t **diff_processor,
+                        svn_client_diff_summarize_func_t summarize_func,
+                        void *summarize_baton,
+                        apr_pool_t *result_pool,
+                        apr_pool_t *scratch_pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/trunk/subversion/libsvn_client/client.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Mon Jul  9 10:34:28 2018
@@ -682,32 +682,6 @@ svn_client__get_diff_editor2(const svn_d
 /* ---------------------------------------------------------------- */
 
 
-/*** Editor for diff summary ***/
-
-/* Set *DIFF_PROCESSOR to a diff processor that will report a diff summary
-   to SUMMARIZE_FUNC.
-
-   P_ROOT_RELPATH will return a pointer to a string that must be set,
-   before the processor is called, to a prefix that will be found on
-   every DIFF_PROCESSOR relpath, that will be removed before passing
-   the path to SUMMARIZE_FUNC.
-
-   ORIGINAL_TARGET is not used.
-
-   SUMMARIZE_FUNC is called with SUMMARIZE_BATON as parameter by the
-   created callbacks for each changed item.
-*/
-svn_error_t *
-svn_client__get_diff_summarize_callbacks(
-                        const svn_diff_tree_processor_t **diff_processor,
-                        svn_client_diff_summarize_func_t summarize_func,
-                        void *summarize_baton,
-                        apr_pool_t *result_pool,
-                        apr_pool_t *scratch_pool);
-
-/* ---------------------------------------------------------------- */
-
-
 /*** Copy Stuff ***/
 
 /* This structure is used to associate a specific copy or move SRC with a

Modified: subversion/trunk/subversion/libsvn_client/diff.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff.c?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff.c Mon Jul  9 10:34:28 2018
@@ -2796,7 +2796,7 @@ svn_client_diff_summarize2(const char *p
                            svn_client_ctx_t *ctx,
                            apr_pool_t *pool)
 {
-  const svn_diff_tree_processor_t *diff_processor;
+  svn_diff_tree_processor_t *diff_processor;
   svn_opt_revision_t peg_revision;
 
   /* We will never do a pegged diff from here. */
@@ -2828,7 +2828,7 @@ svn_client_diff_summarize_peg2(const cha
                                svn_client_ctx_t *ctx,
                                apr_pool_t *pool)
 {
-  const svn_diff_tree_processor_t *diff_processor;
+  svn_diff_tree_processor_t *diff_processor;
 
   SVN_ERR(svn_client__get_diff_summarize_callbacks(&diff_processor,
                      summarize_func, summarize_baton,

Modified: subversion/trunk/subversion/libsvn_client/diff_summarize.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff_summarize.c?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff_summarize.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff_summarize.c Mon Jul  9 
10:34:28 2018
@@ -257,7 +257,7 @@ diff_file_deleted(const char *relpath,
 
 svn_error_t *
 svn_client__get_diff_summarize_callbacks(
-                        const svn_diff_tree_processor_t **diff_processor,
+                        svn_diff_tree_processor_t **diff_processor,
                         svn_client_diff_summarize_func_t summarize_func,
                         void *summarize_baton,
                         apr_pool_t *result_pool,

Modified: subversion/trunk/subversion/svn/cl.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Mon Jul  9 10:34:28 2018
@@ -921,6 +921,20 @@ svn_cl__similarity_check(const char *key
                          apr_size_t token_count,
                          apr_pool_t *scratch_pool);
 
+/* Return in FUNC_P and BATON_P a callback that prints a summary diff,
+ * according to the options XML and IGNORE_PROPERTIES.
+ *
+ * ANCHOR is a URL or local path to be prefixed to the printed paths.
+ */
+svn_error_t *
+svn_cl__get_diff_summary_writer(svn_client_diff_summarize_func_t *func_p,
+                                void **baton_p,
+                                svn_boolean_t xml,
+                                svn_boolean_t ignore_properties,
+                                const char *anchor,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/trunk/subversion/svn/diff-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/diff-cmd.c?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/diff-cmd.c (original)
+++ subversion/trunk/subversion/svn/diff-cmd.c Mon Jul  9 10:34:28 2018
@@ -181,6 +181,24 @@ summarize_regular(const svn_client_diff_
   return svn_cmdline_fflush(stdout);
 }
 
+svn_error_t *
+svn_cl__get_diff_summary_writer(svn_client_diff_summarize_func_t *func_p,
+                                void **baton_p,
+                                svn_boolean_t xml,
+                                svn_boolean_t ignore_properties,
+                                const char *anchor,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool)
+{
+  struct summarize_baton_t *b = apr_pcalloc(result_pool, sizeof(*b));
+
+  b->anchor = anchor;
+  b->ignore_properties = ignore_properties;
+  *func_p = xml ? summarize_xml : summarize_regular;
+  *baton_p = b;
+  return SVN_NO_ERROR;
+}
+
 /* An svn_opt_subcommand_t to handle the 'diff' command.
    This implements the `svn_opt_subcommand_t' interface. */
 svn_error_t *
@@ -203,9 +221,6 @@ svn_cl__diff(apr_getopt_t *os,
   svn_boolean_t ignore_properties =
     opt_state->diff.patch_compatible || opt_state->diff.ignore_properties;
   int i;
-  struct summarize_baton_t summarize_baton;
-  const svn_client_diff_summarize_func_t summarize_func =
-    (opt_state->xml ? summarize_xml : summarize_regular);
 
   if (opt_state->extensions)
     options = svn_cstring_split(opt_state->extensions, " \t\n\r", TRUE, pool);
@@ -448,9 +463,13 @@ svn_cl__diff(apr_getopt_t *os,
 
           if (opt_state->diff.summarize)
             {
-              summarize_baton.anchor = target1;
-              summarize_baton.ignore_properties = ignore_properties;
+              svn_client_diff_summarize_func_t summarize_func;
+              void *summarize_baton;
 
+              SVN_ERR(svn_cl__get_diff_summary_writer(
+                                &summarize_func, &summarize_baton,
+                                opt_state->xml, ignore_properties, target1,
+                                iterpool, iterpool));
               SVN_ERR(svn_client_diff_summarize2(
                                 target1,
                                 &opt_state->start_revision,
@@ -459,7 +478,7 @@ svn_cl__diff(apr_getopt_t *os,
                                 opt_state->depth,
                                 ! opt_state->diff.notice_ancestry,
                                 opt_state->changelists,
-                                summarize_func, &summarize_baton,
+                                summarize_func, summarize_baton,
                                 ctx, iterpool));
             }
           else
@@ -502,8 +521,13 @@ svn_cl__diff(apr_getopt_t *os,
 
           if (opt_state->diff.summarize)
             {
-              summarize_baton.anchor = truepath;
-              summarize_baton.ignore_properties = ignore_properties;
+              svn_client_diff_summarize_func_t summarize_func;
+              void *summarize_baton;
+
+              SVN_ERR(svn_cl__get_diff_summary_writer(
+                                &summarize_func, &summarize_baton,
+                                opt_state->xml, ignore_properties, truepath,
+                                iterpool, iterpool));
               SVN_ERR(svn_client_diff_summarize_peg2(
                                 truepath,
                                 &peg_revision,
@@ -512,7 +536,7 @@ svn_cl__diff(apr_getopt_t *os,
                                 opt_state->depth,
                                 ! opt_state->diff.notice_ancestry,
                                 opt_state->changelists,
-                                summarize_func, &summarize_baton,
+                                summarize_func, summarize_baton,
                                 ctx, iterpool));
             }
           else

Modified: subversion/trunk/subversion/svn/shelf-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/shelf-cmd.c?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/shelf-cmd.c (original)
+++ subversion/trunk/subversion/svn/shelf-cmd.c Mon Jul  9 10:34:28 2018
@@ -705,6 +705,7 @@ static svn_error_t *
 shelf_diff(const char *name,
            const char *arg,
            const char *local_abspath,
+           svn_boolean_t summarize,
            svn_client_ctx_t *ctx,
            apr_pool_t *scratch_pool)
 {
@@ -734,22 +735,40 @@ shelf_diff(const char *name,
   SVN_ERR(svn_stream_for_stdout(&stream, scratch_pool));
   errstream = svn_stream_empty(scratch_pool);
 
-  SVN_ERR(svn_client__get_diff_writer_svn(
-            &diff_processor,
-            NULL /*anchor*/,
-            "", "", /*orig_path_1, orig_path_2,*/
-            NULL /*options*/,
-            "" /*relative_to_dir*/,
-            FALSE /*no_diff_added*/,
-            FALSE /*no_diff_deleted*/,
-            FALSE /*show_copies_as_adds*/,
-            FALSE /*ignore_content_type*/,
-            FALSE /*ignore_properties*/,
-            FALSE /*properties_only*/,
-            TRUE /*pretty_print_mergeinfo*/,
-            svn_cmdline_output_encoding(scratch_pool),
-            stream, errstream,
-            ctx, scratch_pool));
+  if (summarize)
+    {
+      svn_client_diff_summarize_func_t func;
+      void *baton;
+
+      SVN_ERR(svn_cl__get_diff_summary_writer(&func, &baton,
+                                              FALSE /*xml*/,
+                                              FALSE /*ignore_properties*/,
+                                              "" /*anchor/prefix*/,
+                                              scratch_pool, scratch_pool));
+      SVN_ERR(svn_client__get_diff_summarize_callbacks(&diff_processor,
+                                                       func, baton,
+                                                       scratch_pool,
+                                                       scratch_pool));
+    }
+  else
+    {
+      SVN_ERR(svn_client__get_diff_writer_svn(
+                &diff_processor,
+                NULL /*anchor*/,
+                "", "", /*orig_path_1, orig_path_2,*/
+                NULL /*options*/,
+                "" /*relative_to_dir*/,
+                FALSE /*no_diff_added*/,
+                FALSE /*no_diff_deleted*/,
+                FALSE /*show_copies_as_adds*/,
+                FALSE /*ignore_content_type*/,
+                FALSE /*ignore_properties*/,
+                FALSE /*properties_only*/,
+                TRUE /*pretty_print_mergeinfo*/,
+                svn_cmdline_output_encoding(scratch_pool),
+                stream, errstream,
+                ctx, scratch_pool));
+    }
 
   SVN_ERR(svn_client__shelf_diff(shelf_version, "", diff_processor,
                                  scratch_pool));
@@ -1086,6 +1105,7 @@ svn_cl__shelf_diff(apr_getopt_t *os,
                    void *baton,
                    apr_pool_t *pool)
 {
+  svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   const char *local_abspath;
   const char *name;
@@ -1103,7 +1123,9 @@ svn_cl__shelf_diff(apr_getopt_t *os,
     return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                             _("Too many arguments"));
 
-  SVN_ERR(shelf_diff(name, arg, local_abspath, ctx, pool));
+  SVN_ERR(shelf_diff(name, arg, local_abspath,
+                     opt_state->diff.summarize,
+                     ctx, pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/svn/svn.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Mon Jul  9 10:34:28 2018
@@ -1958,6 +1958,7 @@ const svn_opt_subcommand_desc3_t svn_cl_
      "  The shelving feature is EXPERIMENTAL. This command is likely to 
change\n"
      "  in the next release, and there is no promise of backward 
compatibility.\n"
     )},
+    {opt_summarize},
   },
 
   { "x-shelf-drop", svn_cl__shelf_drop, {"shelf-drop"}, {N_(

Modified: subversion/trunk/subversion/tests/cmdline/shelf_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/shelf_tests.py?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/shelf_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/shelf_tests.py Mon Jul  9 
10:34:28 2018
@@ -909,6 +909,7 @@ def shelf_diff_simple(sbox):
   svntest.actions.run_and_verify_svn(None, [],
                                      'shelf-save', 'foo')
 
+  # basic svn-style diff
   expected_output = make_diff_header('A/mu', 'revision 2', 'working copy') + [
                       "@@ -1 +1,2 @@\n",
                       " This is the file 'mu'.\n",
@@ -918,6 +919,11 @@ def shelf_diff_simple(sbox):
   svntest.actions.run_and_verify_svn(expected_output, [],
                                      'shelf-diff', 'foo')
 
+  # basic summary diff
+  expected_output = [ 'MM      A/mu\n' ]
+  svntest.actions.run_and_verify_svn(expected_output, [],
+                                     'shelf-diff', '--summarize', 'foo')
+
 
 ########################################################################
 # Run the tests

Modified: subversion/trunk/tools/client-side/bash_completion
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/client-side/bash_completion?rev=1835407&r1=1835406&r2=1835407&view=diff
==============================================================================
--- subversion/trunk/tools/client-side/bash_completion (original)
+++ subversion/trunk/tools/client-side/bash_completion Mon Jul  9 10:34:28 2018
@@ -1028,7 +1028,7 @@ _svn()
                cmdOpts="$pOpts"
                ;;
        shelf-diff)
-               cmdOpts="$pOpts"
+               cmdOpts="$pOpts --summarize"
                ;;
        shelf-drop)
                cmdOpts="$pOpts"


Reply via email to