subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1688437 - in /subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer: clear-obsolete-cmd.c combine-ranges-cmd.c logic.c mergeinfo-normalizer.h normalize-cmd.c
Date Tue, 30 Jun 2015 12:10:22 GMT
Author: stefan2
Date: Tue Jun 30 12:10:22 2015
New Revision: 1688437

URL: http://svn.apache.org/r1688437
Log:
On the svn-mergeinfo-normalizer:
Begin combining the normalization logic of the various sub-commands.

This patch unifies the main command loop that iterates over all
working copies, reads the m/i, log and session info, calls a processing
function and stores the result.

* tools/client-side/svn-mergeinfo-normalizer/mergeinfo-normalizer.h
  (svn_min__opt_state_t): Turn the various sub-commands into options that
                          can be combined freely.
  (svn_min__process_t,
   svn_min__run_command): The new, unified command implementation.

* tools/client-side/svn-mergeinfo-normalizer/logic.c
  (): New file implementing the new internal API. To minimize the coding
      effort, it got forked off clear-obsolete-cmd.c .

* tools/client-side/svn-mergeinfo-normalizer/clear-obsolete-cmd.c
  (remove_obsoletes): Match the svn_min__process_t signature.
  (svn_min__clear_obsolete): Just call svn_min__run_command.

* tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.c
  (shorten_lines): Match the svn_min__process_t signature.
  (svn_min__combine_ranges): Just call svn_min__run_command.

* tools/client-side/svn-mergeinfo-normalizer/normalize-cmd.c
  (normalize): Match the svn_min__process_t signature.
  (svn_min__normalize): Just call svn_min__run_command.

Added:
    subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c
      - copied, changed from r1688329, subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.c
Modified:
    subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/clear-obsolete-cmd.c
    subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.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/normalize-cmd.c

Modified: subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/clear-obsolete-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/clear-obsolete-cmd.c?rev=1688437&r1=1688436&r2=1688437&view=diff
==============================================================================
--- subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/clear-obsolete-cmd.c
(original)
+++ subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/clear-obsolete-cmd.c
Tue Jun 30 12:10:22 2015
@@ -37,7 +37,6 @@
 #include "mergeinfo-normalizer.h"
 
 #include "svn_private_config.h"
-#include <apr_poll.h>
 
 
 /*** Code. ***/
@@ -77,8 +76,9 @@ remove_obsolete_lines(svn_ra_session_t *
 
 static svn_error_t *
 remove_obsoletes(apr_array_header_t *wc_mergeinfo,
+                 svn_min__log_t *log,
                  svn_ra_session_t *session,
-                 svn_boolean_t quiet,
+                 svn_min__opt_state_t *opt_state,
                  apr_pool_t *scratch_pool)
 {
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
@@ -96,7 +96,8 @@ remove_obsoletes(apr_array_header_t *wc_
       removed += initial_count - apr_hash_count(mergeinfo);
 
       /* Show progress after every 1000 nodes and after the last one. */
-      if (!quiet && ((i+1) % 1000 == 0 || (i+1) == wc_mergeinfo->nelts))
+      if (!opt_state->quiet
+          && ((i+1) % 1000 == 0 || (i+1) == wc_mergeinfo->nelts))
         SVN_ERR(svn_cmdline_printf(iterpool,
                   _("    Processed %d nodes, removed %s branch entries.\n"),
                   i+1,
@@ -115,50 +116,8 @@ svn_min__clear_obsolete(apr_getopt_t *os
                         apr_pool_t *pool)
 {
   svn_min__cmd_baton_t *cmd_baton = baton;
-  apr_pool_t *iterpool = svn_pool_create(pool);
-  apr_pool_t *subpool = svn_pool_create(pool);
-
-  int i;
-  for (i = 0; i < cmd_baton->opt_state->targets->nelts; i++)
-    {
-      svn_ra_session_t *session;
-      apr_array_header_t *wc_mergeinfo;
-
-      svn_pool_clear(iterpool);
-      SVN_ERR(svn_min__add_wc_info(baton, i, iterpool, subpool));
-      SVN_ERR(svn_client_open_ra_session2(&session, cmd_baton->repo_root,
-                                          NULL, cmd_baton->ctx, iterpool,
-                                          subpool));
-
-      /* scan working copy */
-      svn_pool_clear(subpool);
-      SVN_ERR(svn_min__read_mergeinfo(&wc_mergeinfo, cmd_baton, iterpool,
-                                      subpool));
-
-      /* actual normalization */
-      svn_pool_clear(subpool);
-      if (!cmd_baton->opt_state->quiet)
-        SVN_ERR(svn_cmdline_printf(subpool,
-                                   _("Remove obsoletes ...\n")));
-
-      SVN_ERR(remove_obsoletes(wc_mergeinfo, session,
-                               cmd_baton->opt_state->quiet, subpool));
-
-      /* write results to disk */
-      svn_pool_clear(subpool);
-      if (!cmd_baton->opt_state->dry_run)
-        SVN_ERR(svn_min__write_mergeinfo(cmd_baton, wc_mergeinfo, subpool));
-
-      /* show results */
-      if (!cmd_baton->opt_state->quiet)
-        {
-          SVN_ERR(svn_cmdline_printf(subpool, _("\nRemaining mergeinfo:\n")));
-          SVN_ERR(svn_min__print_mergeinfo_stats(wc_mergeinfo, subpool));
-        }
-    }
-
-  svn_pool_destroy(subpool);
-  svn_pool_destroy(iterpool);
+  cmd_baton->opt_state->remove_obsoletes = TRUE;
+  SVN_ERR(svn_min__run_command(os, baton, remove_obsoletes, pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.c?rev=1688437&r1=1688436&r2=1688437&view=diff
==============================================================================
--- subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.c
(original)
+++ subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.c
Tue Jun 30 12:10:22 2015
@@ -78,7 +78,8 @@ inoperative(svn_min__log_t *log,
 static svn_error_t *
 shorten_lines(apr_array_header_t *wc_mergeinfo,
               svn_min__log_t *log,
-              svn_boolean_t quiet,
+              svn_ra_session_t *session,
+              svn_min__opt_state_t *opt_state,
               apr_pool_t *scratch_pool)
 {
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
@@ -132,7 +133,8 @@ shorten_lines(apr_array_header_t *wc_mer
         }
 
       /* Show progress after every 1000 nodes and after the last one. */
-      if (!quiet && ((i+1) % 1000 == 0 || (i+1) == wc_mergeinfo->nelts))
+      if (!opt_state->quiet
+          && ((i+1) % 1000 == 0 || (i+1) == wc_mergeinfo->nelts))
         SVN_ERR(svn_cmdline_printf(iterpool,
                   _("    Processed %d nodes, removed %s revision ranges.\n"),
                   i+1,
@@ -152,62 +154,8 @@ svn_min__combine_ranges(apr_getopt_t *os
                         apr_pool_t *pool)
 {
   svn_min__cmd_baton_t *cmd_baton = baton;
-  apr_pool_t *iterpool = svn_pool_create(pool);
-  apr_pool_t *subpool = svn_pool_create(pool);
-
-  int i;
-  for (i = 0; i < cmd_baton->opt_state->targets->nelts; i++)
-    {
-      apr_array_header_t *wc_mergeinfo;
-      svn_min__log_t *log;
-      const char *url;
-      const char *common_path;
-
-      svn_pool_clear(iterpool);
-      SVN_ERR(svn_min__add_wc_info(baton, i, iterpool, subpool));
-
-      /* scan working copy */
-      svn_pool_clear(subpool);
-      SVN_ERR(svn_min__read_mergeinfo(&wc_mergeinfo, cmd_baton, iterpool,
-                                      subpool));
-
-      /* Any mergeinfo at all? */
-      if (wc_mergeinfo->nelts == 0)
-        continue;
-
-      /* fetch log */
-      svn_pool_clear(subpool);
-      common_path = svn_min__common_parent(wc_mergeinfo, subpool, subpool);
-      SVN_ERR_ASSERT(*common_path == '/');
-      url = svn_path_url_add_component2(cmd_baton->repo_root,
-                                        common_path + 1,
-                                        subpool);
-      SVN_ERR(svn_min__log(&log, url, cmd_baton, iterpool, subpool));
-
-      /* actual normalization */
-      svn_pool_clear(subpool);
-      if (!cmd_baton->opt_state->quiet)
-        SVN_ERR(svn_cmdline_printf(subpool,
-                                   _("Combine revision ranges ...\n")));
-
-      SVN_ERR(shorten_lines(wc_mergeinfo, log, cmd_baton->opt_state->quiet,
-                            subpool));
-
-      /* write results to disk */
-      svn_pool_clear(subpool);
-      if (!cmd_baton->opt_state->dry_run)
-        SVN_ERR(svn_min__write_mergeinfo(cmd_baton, wc_mergeinfo, subpool));
-
-      /* show results */
-      if (!cmd_baton->opt_state->quiet)
-        {
-          SVN_ERR(svn_cmdline_printf(subpool, _("\nRemaining mergeinfo:\n")));
-          SVN_ERR(svn_min__print_mergeinfo_stats(wc_mergeinfo, subpool));
-        }
-    }
-
-  svn_pool_destroy(subpool);
-  svn_pool_destroy(iterpool);
+  cmd_baton->opt_state->combine_ranges = TRUE;
+  SVN_ERR(svn_min__run_command(os, baton, shorten_lines, pool));
 
   return SVN_NO_ERROR;
 }

Copied: subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c
(from r1688329, subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.c)
URL: http://svn.apache.org/viewvc/subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c?p2=subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c&p1=subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.c&r1=1688329&r2=1688437&rev=1688437&view=diff
==============================================================================
--- subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/combine-ranges-cmd.c
(original)
+++ subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/logic.c
Tue Jun 30 12:10:22 2015
@@ -1,6 +1,5 @@
 /*
- * combine-ranges-cmd.c -- Combine revision ranges in MI if the gap between
- *                         them is inoperative for the respective path.
+ * logic.c -- Mergeinfo normalization / cleanup logic used by the commands.
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -43,113 +42,51 @@
 /*** Code. ***/
 
 static svn_boolean_t
-all_positive_ranges(svn_rangelist_t *ranges)
+needs_log(svn_min__opt_state_t *opt_state)
 {
-  int i;
-  for (i = 0; i < ranges->nelts; ++i)
-    {
-      const svn_merge_range_t *range
-        = APR_ARRAY_IDX(ranges, i, const svn_merge_range_t *);
-
-      if (range->start > range->end)
-        return FALSE;
-    }
-
-  return TRUE;
+  return opt_state->combine_ranges || opt_state->remove_redundants;
 }
 
 static svn_boolean_t
-inoperative(svn_min__log_t *log,
-            const char *path,
-            svn_revnum_t start,
-            svn_revnum_t end,
-            apr_pool_t *scratch_pool)
+needs_session(svn_min__opt_state_t *opt_state)
 {
-  svn_merge_range_t range = { 0 };
-  apr_array_header_t *ranges = apr_array_make(scratch_pool, 1, sizeof(&range));
-
-  range.start = start - 1;
-  range.end = end;
-  APR_ARRAY_PUSH(ranges, svn_merge_range_t *) = &range;
-
-  return svn_min__operative(log, path, ranges, scratch_pool)->nelts == 0;
+  return opt_state->remove_obsoletes;
 }
 
-static svn_error_t *
-shorten_lines(apr_array_header_t *wc_mergeinfo,
-              svn_min__log_t *log,
-              svn_boolean_t quiet,
-              apr_pool_t *scratch_pool)
+static const char *
+processing_title(svn_min__opt_state_t *opt_state,
+                 apr_pool_t *result_pool)
 {
-  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
-  apr_pool_t *iterpool2 = svn_pool_create(scratch_pool);
+  svn_stringbuf_t *result = svn_stringbuf_create_empty(result_pool);
+  if (opt_state->remove_obsoletes)
+    svn_stringbuf_appendcstr(result, _("Removing obsolete branches"));
 
-  int i;
-  apr_int64_t removed = 0;
-  for (i = 0; i < wc_mergeinfo->nelts; ++i)
+  if (opt_state->remove_redundants)
     {
-      apr_hash_index_t *hi;
-      svn_mergeinfo_t mergeinfo = svn_min__get_mergeinfo(wc_mergeinfo, i);
-
-      svn_pool_clear(iterpool);
-
-      for (hi = apr_hash_first(iterpool, mergeinfo);
-           hi;
-           hi = apr_hash_next(hi))
-        {
-          int source, dest;
-          const char *path = apr_hash_this_key(hi);
-          svn_rangelist_t *ranges = apr_hash_this_val(hi);
-
-          if (ranges->nelts < 2 || !all_positive_ranges(ranges))
-            continue;
-
-          for (source = 1, dest = 0; source < ranges->nelts; ++source)
-            {
-              svn_merge_range_t *source_range
-                = APR_ARRAY_IDX(ranges, source, svn_merge_range_t *);
-              svn_merge_range_t *dest_range
-                = APR_ARRAY_IDX(ranges, dest, svn_merge_range_t *);
-
-              svn_pool_clear(iterpool2);
-
-              if (   (source_range->inheritable == dest_range->inheritable)
-                  && inoperative(log, path, dest_range->end + 1,
-                                 source_range->start, iterpool2))
-                {
-                  dest_range->end = source_range->end;
-                }
-              else
-                {
-                  ++dest;
-                  APR_ARRAY_IDX(ranges, dest, svn_merge_range_t *)
-                    = source_range;
-                }
-            }
-
-          removed += ranges->nelts - dest - 1;
-          ranges->nelts = dest + 1;
-        }
-
-      /* Show progress after every 1000 nodes and after the last one. */
-      if (!quiet && ((i+1) % 1000 == 0 || (i+1) == wc_mergeinfo->nelts))
-        SVN_ERR(svn_cmdline_printf(iterpool,
-                  _("    Processed %d nodes, removed %s revision ranges.\n"),
-                  i+1,
-                  apr_psprintf(iterpool, "%" APR_UINT64_T_FMT, removed)));
+      if (svn_stringbuf_isempty(result))
+        svn_stringbuf_appendcstr(result, _("Removing redundant mergeinfo"));
+      else
+        svn_stringbuf_appendcstr(result, _("and redundant mergeinfo"));
     }
 
-  svn_pool_destroy(iterpool2);
-  svn_pool_destroy(iterpool);
+  if (opt_state->combine_ranges)
+    {
+      if (svn_stringbuf_isempty(result))
+        svn_stringbuf_appendcstr(result, _("Combining revision ranges"));
+      else
+        svn_stringbuf_appendcstr(result, _(", combining revision ranges"));
+    }
 
-  return SVN_NO_ERROR;
+  svn_stringbuf_appendcstr(result, " ...\n");
+  return result->data;
 }
 
 /* This implements the `svn_opt_subcommand_t' interface. */
 svn_error_t *
-svn_min__combine_ranges(apr_getopt_t *os,
-                        void *baton,
-                        apr_pool_t *pool)
+svn_min__run_command(apr_getopt_t *os,
+                     void *baton,
+                     svn_min__process_t processor,
+                     apr_pool_t *pool)
 {
   svn_min__cmd_baton_t *cmd_baton = baton;
   apr_pool_t *iterpool = svn_pool_create(pool);
@@ -159,7 +96,8 @@ svn_min__combine_ranges(apr_getopt_t *os
   for (i = 0; i < cmd_baton->opt_state->targets->nelts; i++)
     {
       apr_array_header_t *wc_mergeinfo;
-      svn_min__log_t *log;
+      svn_min__log_t *log = NULL;
+      svn_ra_session_t *session = NULL;
       const char *url;
       const char *common_path;
 
@@ -176,22 +114,36 @@ svn_min__combine_ranges(apr_getopt_t *os
         continue;
 
       /* fetch log */
-      svn_pool_clear(subpool);
-      common_path = svn_min__common_parent(wc_mergeinfo, subpool, subpool);
-      SVN_ERR_ASSERT(*common_path == '/');
-      url = svn_path_url_add_component2(cmd_baton->repo_root,
-                                        common_path + 1,
-                                        subpool);
-      SVN_ERR(svn_min__log(&log, url, cmd_baton, iterpool, subpool));
+      if (needs_log(cmd_baton->opt_state))
+        {
+          svn_pool_clear(subpool);
+          common_path = svn_min__common_parent(wc_mergeinfo, subpool, subpool);
+          SVN_ERR_ASSERT(*common_path == '/');
+          url = svn_path_url_add_component2(cmd_baton->repo_root,
+                                            common_path + 1,
+                                            subpool);
+          SVN_ERR(svn_min__log(&log, url, cmd_baton, iterpool, subpool));
+        }
+
+      /* open RA session */
+      if (needs_session(cmd_baton->opt_state))
+        {
+          svn_pool_clear(subpool);
+          SVN_ERR(svn_min__add_wc_info(baton, i, iterpool, subpool));
+          SVN_ERR(svn_client_open_ra_session2(&session, cmd_baton->repo_root,
+                                              NULL, cmd_baton->ctx, iterpool,
+                                              subpool));
+        }
 
       /* actual normalization */
       svn_pool_clear(subpool);
       if (!cmd_baton->opt_state->quiet)
-        SVN_ERR(svn_cmdline_printf(subpool,
-                                   _("Combine revision ranges ...\n")));
+        SVN_ERR(svn_cmdline_fputs(processing_title(cmd_baton->opt_state,
+                                                   subpool),
+                                  stdout, subpool));
 
-      SVN_ERR(shorten_lines(wc_mergeinfo, log, cmd_baton->opt_state->quiet,
-                            subpool));
+      SVN_ERR((*processor)(wc_mergeinfo, log, session, cmd_baton->opt_state,
+                           subpool));
 
       /* write results to disk */
       svn_pool_clear(subpool);

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=1688437&r1=1688436&r2=1688437&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
Tue Jun 30 12:10:22 2015
@@ -61,6 +61,11 @@ typedef struct svn_min__opt_state_t
   const char *config_dir;        /* over-riding configuration directory */
   apr_array_header_t *config_options; /* over-riding configuration options */
 
+  /* Selected normalization operations. */
+  svn_boolean_t remove_obsoletes;
+  svn_boolean_t combine_ranges;
+  svn_boolean_t remove_redundants;
+
   /* trust server SSL certs that would otherwise be rejected as "untrusted" */
   svn_boolean_t trust_server_cert_unknown_ca;
   svn_boolean_t trust_server_cert_cn_mismatch;
@@ -176,6 +181,18 @@ svn_error_t *
 svn_min__print_log_stats(svn_min__log_t *log,
                          apr_pool_t *scratch_pool);
 
+typedef svn_error_t *(* svn_min__process_t)(apr_array_header_t *wc_mergeinfo,
+                                            svn_min__log_t *log,
+                                            svn_ra_session_t *session,
+                                            svn_min__opt_state_t *opt_state,
+                                            apr_pool_t *scratch_pool);
+
+svn_error_t *
+svn_min__run_command(apr_getopt_t *os,
+                     void *baton,
+                     svn_min__process_t processor,
+                     apr_pool_t *pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/normalize-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/normalize-cmd.c?rev=1688437&r1=1688436&r2=1688437&view=diff
==============================================================================
--- subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/normalize-cmd.c
(original)
+++ subversion/branches/svn-mergeinfo-normalizer/tools/client-side/svn-mergeinfo-normalizer/normalize-cmd.c
Tue Jun 30 12:10:22 2015
@@ -121,7 +121,8 @@ remove_lines(svn_min__log_t *log,
 static svn_error_t *
 normalize(apr_array_header_t *wc_mergeinfo,
           svn_min__log_t *log,
-          svn_boolean_t quiet,
+          svn_ra_session_t *session,
+          svn_min__opt_state_t *opt_state,
           apr_pool_t *scratch_pool)
 {
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
@@ -162,7 +163,7 @@ normalize(apr_array_header_t *wc_mergein
             }
         }
 
-      if (!quiet && i % 1000 == 0)
+      if (!opt_state->quiet && i % 1000 == 0)
         SVN_ERR(svn_cmdline_printf(iterpool,
                   _("    Processed %d nodes, eliminated mergeinfo on %d.\n"),
                   wc_mergeinfo->nelts - i, deleted));
@@ -180,62 +181,8 @@ svn_min__normalize(apr_getopt_t *os,
                    apr_pool_t *pool)
 {
   svn_min__cmd_baton_t *cmd_baton = baton;
-  apr_pool_t *iterpool = svn_pool_create(pool);
-  apr_pool_t *subpool = svn_pool_create(pool);
-
-  int i;
-  for (i = 0; i < cmd_baton->opt_state->targets->nelts; i++)
-    {
-      apr_array_header_t *wc_mergeinfo;
-      svn_min__log_t *log;
-      const char *url;
-      const char *common_path;
-
-      svn_pool_clear(iterpool);
-      SVN_ERR(svn_min__add_wc_info(baton, i, iterpool, subpool));
-
-      /* scan working copy */
-      svn_pool_clear(subpool);
-      SVN_ERR(svn_min__read_mergeinfo(&wc_mergeinfo, cmd_baton, iterpool,
-                                      subpool));
-
-      /* Any mergeinfo at all? */
-      if (wc_mergeinfo->nelts == 0)
-        continue;
-
-      /* fetch log */
-      svn_pool_clear(subpool);
-      common_path = svn_min__common_parent(wc_mergeinfo, subpool, subpool);
-      SVN_ERR_ASSERT(*common_path == '/');
-      url = svn_path_url_add_component2(cmd_baton->repo_root,
-                                        common_path + 1,
-                                        subpool);
-      SVN_ERR(svn_min__log(&log, url, cmd_baton, iterpool, subpool));
-
-      /* actual normalization */
-      svn_pool_clear(subpool);
-      if (!cmd_baton->opt_state->quiet)
-        SVN_ERR(svn_cmdline_printf(subpool,
-                                   _("Normalizing mergeinfo ...\n")));
-
-      SVN_ERR(normalize(wc_mergeinfo, log, cmd_baton->opt_state->quiet,
-                        subpool));
-
-      /* write results to disk */
-      svn_pool_clear(subpool);
-      if (!cmd_baton->opt_state->dry_run)
-        SVN_ERR(svn_min__write_mergeinfo(cmd_baton, wc_mergeinfo, subpool));
-
-      /* show results */
-      if (!cmd_baton->opt_state->quiet)
-        {
-          SVN_ERR(svn_cmdline_printf(subpool, _("\nRemaining mergeinfo:\n")));
-          SVN_ERR(svn_min__print_mergeinfo_stats(wc_mergeinfo, subpool));
-        }
-    }
-
-  svn_pool_destroy(subpool);
-  svn_pool_destroy(iterpool);
+  cmd_baton->opt_state->remove_redundants = TRUE;
+  SVN_ERR(svn_min__run_command(os, baton, normalize, pool));
 
   return SVN_NO_ERROR;
 }



Mime
View raw message