You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Julian Foad <ju...@btopenworld.com> on 2004/11/09 13:52:35 UTC

[PATCH] Split and simplify svn_opt_args_to_target_array API

Julian Foad wrote:
> The doc string for "svn_opt_args_to_target_array" doesn't say that it 
> strips the "@rev" part from the first two paths if @a extract_revisions 
> is set.

This patch improves the doc. string.

> Also, that feature of it is really an ugly way of combining two 
> different functions into one; it should be split into two functions, the 
> main one (used by nearly everything) which does not handle revisions, 
> and a special one (only used by diff and merge) which ensures that there 
> are only two targets, and extracts their revisions.

This patch splits out the basic part of the function as 
"svn_opt_args_to_target_array2", uses it nearly everywhere, and deprecates the 
original.

We shouldn't continue to use our deprecated stuff.  With this patch, the 
original is still used by "svn_cl__diff" in some cases, but that appears to be 
using it wrongly so it needs to change anyway.  I'll do that as a separate 
patch.  Here I've annotated what I think is wrong, with "###" comments:

Index: subversion/clients/cmdline/diff-cmd.c
===================================================================
--- subversion/clients/cmdline/diff-cmd.c       (revision 11796)
+++ subversion/clients/cmdline/diff-cmd.c       (working copy)
@@ -95,25 +95,23 @@ svn_cl__diff (apr_getopt_t *os,
      {
        apr_array_header_t *tmp, *tmp2;

        /* The 'svn diff --old=OLD[@OLDREV] [--new=NEW[@NEWREV]]
           [PATH...]' case matches. */

-      SVN_ERR (svn_opt_args_to_target_array (&targets, os,
-                                             opt_state->targets,
-                                             NULL,
-                                             NULL,
-                                             FALSE, pool));
+      SVN_ERR (svn_opt_args_to_target_array2 (&targets, os,
+                                              opt_state->targets, pool));

        tmp = apr_array_make (pool, 2, sizeof (const char *));
        APR_ARRAY_PUSH (tmp, const char *) = (opt_state->old_target);
        APR_ARRAY_PUSH (tmp, const char *) = (opt_state->new_target
                                              ? opt_state->new_target
                                              : APR_ARRAY_IDX (tmp, 0,
                                                               const char *));
-
+      /* ### We shouldn't attempt to extract revisions from 'os'
+       * targets as well as old_target and new_target. */
        SVN_ERR (svn_opt_args_to_target_array (&tmp2, os, tmp,
                                               &(opt_state->start_revision),
                                               &(opt_state->end_revision),
                                               TRUE, /* extract @revs */ pool));

        old_target = APR_ARRAY_IDX (tmp2, 0, const char *);
@@ -133,29 +131,26 @@ svn_cl__diff (apr_getopt_t *os,
        svn_boolean_t working_copy_present = FALSE, url_present = FALSE;

        /* The 'svn diff [-r M[:N]] [TARGET[@REV]...]' case matches. */

        /* Here each target is a pegged object. Find out the starting
           and ending paths for each target. */
-      SVN_ERR (svn_opt_args_to_target_array (&targets, os,
-                                             opt_state->targets,
-                                             NULL,
-                                             NULL,
-                                             FALSE, pool));
+      SVN_ERR (svn_opt_args_to_target_array2 (&targets, os,
+                                              opt_state->targets, pool));

        svn_opt_push_implicit_dot_target (targets, pool);

        tmp = apr_array_make (pool, 2, sizeof (const char *));
        APR_ARRAY_PUSH (tmp, const char *) = ".";
        APR_ARRAY_PUSH (tmp, const char *) = ".";

        SVN_ERR (svn_opt_args_to_target_array (&tmp2, os, tmp,
                                               &(opt_state->start_revision),
                                               &(opt_state->end_revision),
                                               TRUE, /* extract @revs */ pool));
-
+      /* ### Extract revs from first two targets only?  Must be wrong. */
        old_target = APR_ARRAY_IDX (tmp2, 0, const char *);
        new_target = APR_ARRAY_IDX (tmp2, 1, const char *);

        /* Check to see if at least one of our paths is a working copy
           path. */
        for (i = 0; i < targets->nelts; ++i)


- Julian