Author: cmpilato
Date: Fri Jun 22 15:47:43 2012
New Revision: 1352935

URL: http://svn.apache.org/viewvc?rev=1352935&view=rev
Log:
Finish issue #4199 ("Add real support for the --revision (-r) option
to the 'svn mergeinfo' command").  Prior to this change, 'svn
mergeinfo' accepted the --revision (-r) option, but did nothing with
it.  Oops!

* subversion/include/svn_client.h
  (svn_client_mergeinfo_log2): New iteration (adding an operative
    revision range) of ...
  (svn_client_mergeinfo_log): ... this now-deprecated function.

* subversion/libsvn_client/deprecated.c
  (svn_client_mergeinfo_log): Move this here, and make it a mere
    wrapper around svn_client_mergeinfo_log2().

* subversion/libsvn_client/mergeinfo.c
  (svn_client_mergeinfo_log2): Replaces svn_client_mergeinfo_log(),
    adding 'source_start_revision' and 'source_end_revision'
    parameters and handling.  The core of this change was really
    straightforward -- we just needed to provide the resolved
    start/end revisions to the existing invocation of
    svn_client__get_history_as_mergeinfo().

* subversion/svn/main.c
  (main): Add svn_cl__mergeinfo to the set of functions which may
    accept a revision range.

* subversion/svn/mergeinfo-cmd.c
  (svn_cl__mergeinfo): Upgrade to svn_client_mergeinfo_log2(), passing
    the revision range provided by the user.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/deprecated.c
    subversion/trunk/subversion/libsvn_client/mergeinfo.c
    subversion/trunk/subversion/svn/main.c
    subversion/trunk/subversion/svn/mergeinfo-cmd.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1352935&r1=1352934&r2=1352935&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Fri Jun 22 15:47:43 2012
@@ -3730,8 +3730,32 @@ svn_client_mergeinfo_get_merged(apr_hash
  * If the server doesn't support retrieval of mergeinfo, return an
  * #SVN_ERR_UNSUPPORTED_FEATURE error.
  *
+ * @since New in 1.8.
+ */
+svn_error_t *
+svn_client_mergeinfo_log2(svn_boolean_t finding_merged,
+                          const char *target_path_or_url,
+                          const svn_opt_revision_t *target_peg_revision,
+                          const char *source_path_or_url,
+                          const svn_opt_revision_t *source_peg_revision,
+                          const svn_opt_revision_t *source_start_revision,
+                          const svn_opt_revision_t *source_end_revision,
+                          svn_log_entry_receiver_t receiver,
+                          void *receiver_baton,
+                          svn_boolean_t discover_changed_paths,
+                          svn_depth_t depth,
+                          const apr_array_header_t *revprops,
+                          svn_client_ctx_t *ctx,
+                          apr_pool_t *scratch_pool);
+
+/**
+ * Similar to svn_client_mergeinfo_log2(), but with @a source_start_revision
+ * and @a source_end_revision always of kind @c svn_opt_revision_unspecified;
+ *
+ * @deprecated Provided for backwards compatibility with the 1.7 API.
  * @since New in 1.7.
  */
+SVN_DEPRECATED
 svn_error_t *
 svn_client_mergeinfo_log(svn_boolean_t finding_merged,
                          const char *target_path_or_url,

Modified: subversion/trunk/subversion/libsvn_client/deprecated.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/deprecated.c?rev=1352935&r1=1352934&r2=1352935&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_client/deprecated.c Fri Jun 22 15:47:43 
2012
@@ -2565,6 +2565,34 @@ svn_client_url_from_path(const char **ur
 
 /*** From mergeinfo.c ***/
 svn_error_t *
+svn_client_mergeinfo_log(svn_boolean_t finding_merged,
+                         const char *target_path_or_url,
+                         const svn_opt_revision_t *target_peg_revision,
+                         const char *source_path_or_url,
+                         const svn_opt_revision_t *source_peg_revision,
+                         svn_log_entry_receiver_t receiver,
+                         void *receiver_baton,
+                         svn_boolean_t discover_changed_paths,
+                         svn_depth_t depth,
+                         const apr_array_header_t *revprops,
+                         svn_client_ctx_t *ctx,
+                         apr_pool_t *scratch_pool)
+{
+  svn_opt_revision_t start_revision, end_revision;
+
+  start_revision.kind = svn_opt_revision_unspecified;
+  end_revision.kind = svn_opt_revision_unspecified;
+
+  return svn_client_mergeinfo_log2(finding_merged,
+                                   target_path_or_url, target_peg_revision,
+                                   source_path_or_url, source_peg_revision,
+                                   &start_revision, &end_revision,
+                                   receiver, receiver_baton,
+                                   discover_changed_paths, depth, revprops,
+                                   ctx, scratch_pool);
+}
+
+svn_error_t *
 svn_client_mergeinfo_log_merged(const char *path_or_url,
                                 const svn_opt_revision_t *peg_revision,
                                 const char *merge_source_path_or_url,

Modified: subversion/trunk/subversion/libsvn_client/mergeinfo.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mergeinfo.c?rev=1352935&r1=1352934&r2=1352935&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_client/mergeinfo.c Fri Jun 22 15:47:43 
2012
@@ -1622,20 +1622,21 @@ svn_client_mergeinfo_get_merged(apr_hash
 
 
 svn_error_t *
-svn_client_mergeinfo_log(svn_boolean_t finding_merged,
-                         const char *target_path_or_url,
-                         const svn_opt_revision_t *target_peg_revision,
-                         const char *source_path_or_url,
-                         const svn_opt_revision_t *source_peg_revision,
-                         svn_log_entry_receiver_t log_receiver,
-                         void *log_receiver_baton,
-                         svn_boolean_t discover_changed_paths,
-                         svn_depth_t depth,
-                         const apr_array_header_t *revprops,
-                         svn_client_ctx_t *ctx,
-                         apr_pool_t *scratch_pool)
+svn_client_mergeinfo_log2(svn_boolean_t finding_merged,
+                          const char *target_path_or_url,
+                          const svn_opt_revision_t *target_peg_revision,
+                          const char *source_path_or_url,
+                          const svn_opt_revision_t *source_peg_revision,
+                          const svn_opt_revision_t *source_start_revision,
+                          const svn_opt_revision_t *source_end_revision,
+                          svn_log_entry_receiver_t log_receiver,
+                          void *log_receiver_baton,
+                          svn_boolean_t discover_changed_paths,
+                          svn_depth_t depth,
+                          const apr_array_header_t *revprops,
+                          svn_client_ctx_t *ctx,
+                          apr_pool_t *scratch_pool)
 {
-  apr_pool_t *sesspool = svn_pool_create(scratch_pool);
   const char *log_target = NULL;
   const char *repos_root;
   const char *target_repos_rel;
@@ -1662,6 +1663,23 @@ svn_client_mergeinfo_log(svn_boolean_t f
       SVN_ERR_UNSUPPORTED_FEATURE, NULL,
       _("Only depths 'infinity' and 'empty' are currently supported"));
 
+  /* Validate and sanitize the incoming source operative revision range. */
+  if (!((source_start_revision->kind == svn_opt_revision_unspecified) ||
+        (source_start_revision->kind == svn_opt_revision_number) ||
+        (source_start_revision->kind == svn_opt_revision_date) ||
+        (source_start_revision->kind == svn_opt_revision_head)))
+    return svn_error_create
+      (SVN_ERR_CLIENT_BAD_REVISION, NULL, NULL);
+  if (!((source_end_revision->kind == svn_opt_revision_unspecified) ||
+        (source_end_revision->kind == svn_opt_revision_number) ||
+        (source_end_revision->kind == svn_opt_revision_date) ||
+        (source_end_revision->kind == svn_opt_revision_head)))
+    return svn_error_create
+      (SVN_ERR_CLIENT_BAD_REVISION, NULL, NULL);
+  if ((source_end_revision->kind == svn_opt_revision_unspecified)
+      && (source_start_revision->kind != svn_opt_revision_unspecified))
+    source_end_revision = source_start_revision;
+
   /* We need the union of TARGET_PATH_OR_URL@TARGET_PEG_REVISION's mergeinfo
      and MERGE_SOURCE_URL's history.  It's not enough to do path
      matching, because renames in the history of MERGE_SOURCE_URL
@@ -1717,43 +1735,56 @@ svn_client_mergeinfo_log(svn_boolean_t f
   /* Open RA sessions to the repository for the source and target.
    * ### TODO: As the source and target must be in the same repository, we
    * should share a single session, tracking the two URLs separately. */
-  if (!finding_merged)
-    {
-      svn_ra_session_t *target_session;
-      svn_client__pathrev_t *pathrev;
-
-      SVN_ERR(svn_client__ra_session_from_path2(
-                &target_session, &pathrev,
-                target_path_or_url, NULL,
-                target_peg_revision, target_peg_revision,
-                ctx, sesspool));
-      SVN_ERR(svn_client__get_history_as_mergeinfo(
-                &target_history, NULL,
-                pathrev, SVN_INVALID_REVNUM, SVN_INVALID_REVNUM,
-                target_session, ctx, scratch_pool));
-    }
   {
-    svn_ra_session_t *source_session;
+    apr_pool_t *sesspool = svn_pool_create(scratch_pool);
+    svn_ra_session_t *source_session, *target_session;
     svn_client__pathrev_t *pathrev;
+    svn_revnum_t start_rev, end_rev, youngest_rev = SVN_INVALID_REVNUM;
+    
+    if (! finding_merged)
+      {
+        SVN_ERR(svn_client__ra_session_from_path2(&target_session, &pathrev,
+                                                  target_path_or_url, NULL,
+                                                  target_peg_revision,
+                                                  target_peg_revision,
+                                                  ctx, sesspool));
+        SVN_ERR(svn_client__get_history_as_mergeinfo(&target_history, NULL,
+                                                     pathrev,
+                                                     SVN_INVALID_REVNUM,
+                                                     SVN_INVALID_REVNUM,
+                                                     target_session, ctx,
+                                                     scratch_pool));
+      }
+    
+    SVN_ERR(svn_client__ra_session_from_path2(&source_session, &pathrev,
+                                              source_path_or_url, NULL,
+                                              source_peg_revision,
+                                              source_peg_revision,
+                                              ctx, sesspool));
+    SVN_ERR(svn_client__get_revision_number(&start_rev, &youngest_rev,
+                                            ctx->wc_ctx, source_path_or_url,
+                                            source_session,
+                                            source_start_revision,
+                                            sesspool));
+    SVN_ERR(svn_client__get_revision_number(&end_rev, &youngest_rev,
+                                            ctx->wc_ctx, source_path_or_url,
+                                            source_session,
+                                            source_end_revision,
+                                            sesspool));
+    SVN_ERR(svn_client__get_history_as_mergeinfo(&source_history, NULL,
+                                                 pathrev, end_rev, start_rev,
+                                                 source_session, ctx,
+                                                 scratch_pool));
 
-    SVN_ERR(svn_client__ra_session_from_path2(
-              &source_session, &pathrev,
-              source_path_or_url, NULL,
-              source_peg_revision, source_peg_revision,
-              ctx, sesspool));
-    SVN_ERR(svn_client__get_history_as_mergeinfo(
-              &source_history, NULL,
-              pathrev, SVN_INVALID_REVNUM, SVN_INVALID_REVNUM,
-              source_session, ctx, scratch_pool));
+    /* Close the source and target sessions. */
+    svn_pool_destroy(sesspool);
   }
-  /* Close the source and target sessions. */
-  svn_pool_destroy(sesspool);
 
   /* Separate the explicit or inherited mergeinfo on TARGET_PATH_OR_URL,
      and possibly its explicit subtree mergeinfo, into their
      inheritable and non-inheritable parts. */
-  master_noninheritable_rangelist =
-    apr_array_make(scratch_pool, 64, sizeof(svn_merge_range_t *));
+  master_noninheritable_rangelist = apr_array_make(scratch_pool, 64,
+                                                   sizeof(svn_merge_range_t 
*));
   master_inheritable_rangelist = apr_array_make(scratch_pool, 64,
                                                 sizeof(svn_merge_range_t *));
   inheritable_subtree_merges = apr_hash_make(scratch_pool);

Modified: subversion/trunk/subversion/svn/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/main.c?rev=1352935&r1=1352934&r2=1352935&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/main.c (original)
+++ subversion/trunk/subversion/svn/main.c Fri Jun 22 15:47:43 2012
@@ -1049,6 +1049,11 @@ const svn_opt_subcommand_desc2_t svn_cl_
      "  specified by the --show-revs option.  If --show-revs isn't passed,\n"
      "  it defaults to --show-revs='merged'.\n"
      "\n"
+     "  If --revision (-r) is provided, filter the displayed information to\n"
+     "  show only that which is associated with the revisions within the\n"
+     "  specified range.  Revision numbers, dates, and the 'HEAD' keyword 
are\n"
+     "  valid range values.\n"
+     "\n"
      "  The depth can be 'empty' or 'infinity'; the default is 'empty'.\n"),
     {'r', 'R', opt_depth, opt_show_revs} },
 
@@ -2463,6 +2468,7 @@ main(int argc, const char *argv[])
   if (subcommand->cmd_func != svn_cl__blame
       && subcommand->cmd_func != svn_cl__diff
       && subcommand->cmd_func != svn_cl__log
+      && subcommand->cmd_func != svn_cl__mergeinfo
       && subcommand->cmd_func != svn_cl__merge)
     {
       if (opt_state.end_revision.kind != svn_opt_revision_unspecified)

Modified: subversion/trunk/subversion/svn/mergeinfo-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/mergeinfo-cmd.c?rev=1352935&r1=1352934&r2=1352935&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/mergeinfo-cmd.c (original)
+++ subversion/trunk/subversion/svn/mergeinfo-cmd.c Fri Jun 22 15:47:43 2012
@@ -122,19 +122,23 @@ svn_cl__mergeinfo(apr_getopt_t *os,
   /* Do the real work, depending on the requested data flavor. */
   if (opt_state->show_revs == svn_cl__show_revs_merged)
     {
-      SVN_ERR(svn_client_mergeinfo_log(TRUE, target, &tgt_peg_revision,
-                                       source, &src_peg_revision,
-                                       print_log_rev, NULL,
-                                       TRUE, depth, NULL, ctx,
-                                       pool));
+      SVN_ERR(svn_client_mergeinfo_log2(TRUE, target, &tgt_peg_revision,
+                                        source, &src_peg_revision,
+                                        &(opt_state->start_revision),
+                                        &(opt_state->end_revision),
+                                        print_log_rev, NULL,
+                                        TRUE, depth, NULL, ctx,
+                                        pool));
     }
   else if (opt_state->show_revs == svn_cl__show_revs_eligible)
     {
-      SVN_ERR(svn_client_mergeinfo_log(FALSE, target, &tgt_peg_revision,
-                                       source, &src_peg_revision,
-                                       print_log_rev, NULL,
-                                       TRUE, depth, NULL, ctx,
-                                       pool));
+      SVN_ERR(svn_client_mergeinfo_log2(FALSE, target, &tgt_peg_revision,
+                                        source, &src_peg_revision,
+                                        &(opt_state->start_revision),
+                                        &(opt_state->end_revision),
+                                        print_log_rev, NULL,
+                                        TRUE, depth, NULL, ctx,
+                                        pool));
     }
   return SVN_NO_ERROR;
 }


Reply via email to