subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1689091 - in /subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer: logic.c mergeinfo-normalizer.h svn-mergeinfo-normalizer.c wc_mergeinfo.c
Date Fri, 03 Jul 2015 21:05:20 GMT
Author: stefan2
Date: Fri Jul  3 21:05:20 2015
New Revision: 1689091

URL: http://svn.apache.org/r1689091
Log:
On the svn-mergeinfo-normalizer branch:
Add a '--verbose' option to the 'normalize' sub-command.

In this first stage, we show a header and a footer for each node that
we process.  The logic is taken from the 'analyze' output.

* tools/client-side/svn-mergeinfo-normalizer/mergeinfo-normalizer.h
  (svn_min__opt_state_t): Add VERBOSE flag.

* tools/client-side/svn-mergeinfo-normalizer/svn-mergeinfo-normalizer.c
  (svn_min__cmd_table): Make '-v' option available to 'normalize'.
  (sub_main): Process -v option.

* tools/client-side/svn-mergeinfo-normalizer/wc_mergeinfo.c
  (svn_min__get_mergeinfo_pair): Improve usability by also providing path
                                 info in case there only a single node.

* tools/client-side/svn-mergeinfo-normalizer/logic.c
  (show_elision_header,
   show_elision_result): New console output functions. Their code taken
                         from analyze-cmd.c .
  (normalize): Invoke the new output functions.  Show progress only if
               there is no other output.

Modified:
    subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c
    subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/mergeinfo-normalizer.h
    subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/svn-mergeinfo-normalizer.c
    subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/wc_mergeinfo.c

Modified: subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c?rev=1689091&r1=1689090&r2=1689091&view=diff
==============================================================================
--- subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c
(original)
+++ subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c
Fri Jul  3 21:05:20 2015
@@ -33,6 +33,7 @@
 #include "svn_path.h"
 #include "svn_pools.h"
 #include "private/svn_fspath.h"
+#include "private/svn_sorts_private.h"
 
 #include "mergeinfo-normalizer.h"
 
@@ -292,6 +293,79 @@ progress_string(const progress_t *progre
 }
 
 static svn_error_t *
+show_elision_header(const char *parent_path,
+                    const char *relpath,
+                    svn_min__opt_state_t *opt_state,
+                    apr_pool_t *scratch_pool)
+{
+  if (!opt_state->verbose)
+    return SVN_NO_ERROR;
+
+  if (*relpath)
+    SVN_ERR(svn_cmdline_printf(scratch_pool,
+                               _("Trying to elide mergeinfo from path\n"
+                                 "    %s\n"
+                                 "    into mergeinfo at path\n"
+                                 "    %s\n\n"),
+                               svn_dirent_join(parent_path, relpath,
+                                               scratch_pool),
+                               parent_path));
+  else
+    SVN_ERR(svn_cmdline_printf(scratch_pool,
+                               _("Trying to elide mergeinfo at path\n"
+                                 "    %s\n\n"),
+                               parent_path));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+show_elision_result(svn_mergeinfo_t parent_mergeinfo,
+                    svn_mergeinfo_t subtree_mergeinfo,
+                    svn_min__opt_state_t *opt_state,
+                    apr_pool_t *scratch_pool)
+{
+  if (!opt_state->verbose)
+    return SVN_NO_ERROR;
+
+  if (apr_hash_count(subtree_mergeinfo))
+    {
+      apr_array_header_t *sorted_mi;
+      int i;
+      apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+
+      if (parent_mergeinfo)
+        SVN_ERR(svn_cmdline_printf(scratch_pool,
+                  _("    Sub-tree merge info cannot be elided due to "
+                    "the following branches:\n")));
+      else
+        SVN_ERR(svn_cmdline_printf(scratch_pool,
+                  _("    Merge info kept for the following branches:\n")));
+
+      sorted_mi = svn_sort__hash(subtree_mergeinfo,
+                                 svn_sort_compare_items_lexically,
+                                 scratch_pool);
+      for (i = 0; i < sorted_mi->nelts; ++i)
+        {
+          const char *branch = APR_ARRAY_IDX(sorted_mi, i,
+                                              svn_sort__item_t).key;
+          svn_pool_clear(iterpool);
+          SVN_ERR(svn_cmdline_printf(scratch_pool, _("    %s\n"), branch));
+        }
+
+      SVN_ERR(svn_cmdline_printf(scratch_pool, _("\n")));
+      svn_pool_destroy(iterpool);
+    }
+  else
+    {
+      SVN_ERR(svn_cmdline_printf(scratch_pool,
+                _("    All sub-tree mergeinfo has be elided.\n\n")));
+    }
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 normalize(apr_array_header_t *wc_mergeinfo,
           svn_min__log_t *log,
           svn_min__branch_lookup_t *lookup,
@@ -317,6 +391,8 @@ normalize(apr_array_header_t *wc_mergein
       svn_min__get_mergeinfo_pair(&parent_path, &relpath,
                                   &parent_mergeinfo, &subtree_mergeinfo,
                                   wc_mergeinfo, i);
+      SVN_ERR(show_elision_header(parent_path, relpath, opt_state,
+                                  scratch_pool));
 
       /* Quickly eliminate entries for known deleted branches. */
       SVN_ERR(remove_obsolete_lines(lookup, subtree_mergeinfo, opt_state,
@@ -374,8 +450,12 @@ normalize(apr_array_header_t *wc_mergein
       SVN_ERR(shorten_lines(subtree_mergeinfo, log, opt_state, &progress,
                             iterpool));
 
+      /* Display what's left. */
+      SVN_ERR(show_elision_result(parent_mergeinfo, subtree_mergeinfo,
+                                  opt_state, scratch_pool));
+
       /* Print progress info. */
-      if (!opt_state->quiet && i % 100 == 0)
+      if (!opt_state->verbose && !opt_state->quiet && i % 100 == 0)
         SVN_ERR(svn_cmdline_printf(iterpool, "    %s.\n",
                                    progress_string(&progress, opt_state,
                                                    iterpool, iterpool)));

Modified: subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/mergeinfo-normalizer.h
URL: http://svn.apache.org/viewvc/subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/mergeinfo-normalizer.h?rev=1689091&r1=1689090&r2=1689091&view=diff
==============================================================================
--- subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/mergeinfo-normalizer.h
(original)
+++ subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/mergeinfo-normalizer.h
Fri Jul  3 21:05:20 2015
@@ -52,6 +52,7 @@ typedef struct svn_min__opt_state_t
 
   svn_boolean_t quiet;           /* sssh...avoid unnecessary output */
   svn_boolean_t version;         /* print version information */
+  svn_boolean_t verbose;         /* be verbose */
   svn_boolean_t help;            /* print usage message */
   const char *auth_username;     /* auth username */
   const char *auth_password;     /* auth password */

Modified: subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/svn-mergeinfo-normalizer.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/svn-mergeinfo-normalizer.c?rev=1689091&r1=1689090&r2=1689091&view=diff
==============================================================================
--- subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/svn-mergeinfo-normalizer.c
(original)
+++ subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/svn-mergeinfo-normalizer.c
Fri Jul  3 21:05:20 2015
@@ -227,7 +227,7 @@ const svn_opt_subcommand_desc2_t svn_min
   { "normalize", svn_min__normalize, { 0 }, N_
     ("Normalize the mergeinfo throughout the working copy sub-tree.\n"
      "usage: normalize [WCPATH...]\n"),
-    {opt_targets, opt_depth, opt_dry_run, 'q',
+    {opt_targets, opt_depth, opt_dry_run, 'q', 'v',
      opt_remove_obsoletes, opt_remove_redundant, opt_combine_ranges} },
 
   { "analyze", svn_min__analyze, { "analyse" }, N_
@@ -368,6 +368,9 @@ sub_main(int *exit_code, int argc, const
       case 'q':
         opt_state.quiet = TRUE;
         break;
+      case 'v':
+        opt_state.verbose = TRUE;
+        break;
       case opt_targets:
         {
           svn_stringbuf_t *buffer, *buffer_utf8;

Modified: subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/wc_mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/wc_mergeinfo.c?rev=1689091&r1=1689090&r2=1689091&view=diff
==============================================================================
--- subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/wc_mergeinfo.c
(original)
+++ subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/wc_mergeinfo.c
Fri Jul  3 21:05:20 2015
@@ -258,7 +258,7 @@ svn_min__get_mergeinfo_pair(const char *
 
   if (!entry->parent)
     {
-      *parent_path = "";
+      *parent_path = entry->local_path;
       *subtree_relpath = "";
       *parent_mergeinfo = NULL;
 



Mime
View raw message