[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] 'svn merge -rX' UI annoyance.

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2005-08-04 17:57:29 CEST

"Daniel L. Rall" <dlr@finemaltcoding.com> writes:

> On Thu, 2005-08-04 at 10:03 -0500, C. Michael Pilato wrote:
> > Mark Phippard <MarkP@softlanding.com> writes:
> >
> > > cmpilato@localhost.localdomain wrote on 08/04/2005 10:51:10 AM:
> > >
> > > > I'm constantly frustrated that passing -rX (instead of -rX:Y) as the
> > > > operative range for merge operations doesn't default to -rX:X-1
> > > > behavior. Like, I wanna say "cherry pick a merge of revision 14" and
> > > > I run 'svn merge -r14 ...' only to get bounced for not having
> > > > specified a full revision range.
> > > >
> > > > What would others think about relaxing the 'svn merge' UI such that
> > > > passing a single revision means, "merge that one revision"?
> > >
> > > I assume you meant does not default to -rX-1:X?
> >
> > Oops! Yeah, you're right. Sorry. -rX-1:X.
>
> +1!!!!!

In the spirit of Open Source, I offer my hopefully welcome patch. It
seems to work, but I haven't run it through regression tests yet.

===========================================================================

Teach 'svn merge' how to deal with -rN input (instead of -rN:M) by
treating -rN as -rN-1:N.

      * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
      * *
      * THIS PATCH HAS NOT UNDERGONE REGRESSION TESTING. *
      * *
      * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* subversion/include/svn_opt.h
  (svn_opt_revision_range_prev): New revision specifier kind.

* subversion/libsvn_client/ra.c
  (svn_client__repos_locations): Learn to handle svn_opt_revision_range_prev.

* subversion/clients/cmdline/main.c
  (svn_cl__cmd_table): Update the 'merge' command usage message to
    reflect that the first revision range item is optional, and if
    omitted, is "second-range-revision minus one".

* subversion/clients/cmdline/merge-cmd.c
  (svn_cl__merge): If the end revision isn't specified, don't error --
    just turn (effectively) -rN into -rN-1:N under the hood.

Index: subversion/include/svn_opt.h
===================================================================
--- subversion/include/svn_opt.h (revision 15561)
+++ subversion/include/svn_opt.h (working copy)
@@ -198,7 +198,10 @@
   svn_opt_revision_working,
 
   /** repository youngest */
- svn_opt_revision_head
+ svn_opt_revision_head,
+
+ /** (rev of "the other half of the operative range") - 1 */
+ svn_opt_revision_range_prev
 };
 
 
Index: subversion/libsvn_client/ra.c
===================================================================
--- subversion/libsvn_client/ra.c (revision 15561)
+++ subversion/libsvn_client/ra.c (working copy)
@@ -702,6 +702,14 @@
       || start->kind == svn_opt_revision_unspecified)
     return svn_error_create (SVN_ERR_CLIENT_BAD_REVISION, NULL, NULL);
 
+ /* If one of the operative range revisions is relative to the other,
+ but the other isn't specified, we're heading toward trouble. */
+ if (((end->kind == svn_opt_revision_unspecified)
+ && (start->kind == svn_opt_revision_range_prev))
+ || ((end->kind == svn_opt_revision_unspecified)
+ && (start->kind == svn_opt_revision_range_prev)))
+ return svn_error_create (SVN_ERR_CLIENT_BAD_REVISION, NULL, NULL);
+
   /* Check to see if this is schedule add with history working copy
      path. If it is, then we need to use the URL and peg revision of
      the copyfrom information. */
@@ -749,14 +757,25 @@
     SVN_ERR (svn_client__get_revision_number (&peg_revnum,
                                               ra_session, revision, path,
                                               pool));
-
- SVN_ERR (svn_client__get_revision_number (&start_revnum,
- ra_session, start, path, pool));
- if (end->kind == svn_opt_revision_unspecified)
- end_revnum = start_revnum;
+
+ /* If the start revision depends on the end, we've gotta fetch the
+ end first. */
+ if (start->kind == svn_opt_revision_range_prev)
+ {
+ SVN_ERR (svn_client__get_revision_number (&end_revnum, ra_session,
+ end, path, pool));
+ start_revnum = end_revnum - 1;
+ }
   else
- SVN_ERR (svn_client__get_revision_number (&end_revnum,
- ra_session, end, path, pool));
+ {
+ SVN_ERR (svn_client__get_revision_number (&start_revnum, ra_session,
+ start, path, pool));
+ if (end->kind == svn_opt_revision_unspecified)
+ end_revnum = start_revnum;
+ else
+ SVN_ERR (svn_client__get_revision_number (&end_revnum, ra_session,
+ end, path, pool));
+ }
 
   /* Set the output revision variables. */
   *start_revision = apr_pcalloc (pool, sizeof (**start_revision));
Index: subversion/clients/cmdline/merge-cmd.c
===================================================================
--- subversion/clients/cmdline/merge-cmd.c (revision 15561)
+++ subversion/clients/cmdline/merge-cmd.c (working copy)
@@ -55,10 +55,9 @@
       /* sanity check: they better have given supplied a *range*. */
       if (opt_state->end_revision.kind == svn_opt_revision_unspecified)
         {
- svn_opt_subcommand_help ("merge", svn_cl__cmd_table,
- svn_cl__options, pool);
- return svn_error_create (SVN_ERR_CL_INSUFFICIENT_ARGS, 0,
- _("Second revision required"));
+ opt_state->end_revision.kind = opt_state->start_revision.kind;
+ opt_state->end_revision.value = opt_state->start_revision.value;
+ opt_state->start_revision.kind = svn_opt_revision_range_prev;
         }
       using_alternate_syntax = TRUE;
     }
Index: subversion/clients/cmdline/main.c
===================================================================
--- subversion/clients/cmdline/main.c (revision 15561)
+++ subversion/clients/cmdline/main.c (working copy)
@@ -443,7 +443,7 @@
     N_("Apply the differences between two sources to a working copy path.\n"
        "usage: 1. merge sourceURL1[@N] sourceURL2[@M] [WCPATH]\n"
        " 2. merge sourceWCPATH1@N sourceWCPATH2@M [WCPATH]\n"
- " 3. merge -r N:M SOURCE[@REV] [WCPATH]\n"
+ " 3. merge -r [N:]M SOURCE[@REV] [WCPATH]\n"
        "\n"
        " 1. In the first form, the source URLs are specified at revisions\n"
        " N and M. These are the two sources to be compared. The "
@@ -459,7 +459,9 @@
        " 3. In the third form, SOURCE can be a URL, or working copy item\n"
        " in which case the corresponding URL is used. This URL in\n"
        " revision REV is compared as it existed between revisions N and \n"
- " M. If REV is not specified, HEAD is assumed.\n"
+ " M. If N is not specified, M-1 is assumed. If REV is not\n"
+ " specified, HEAD is assumed.\n"
+ " \n"
        "\n"
        " WCPATH is the working copy path that will receive the changes.\n"
        " If WCPATH is omitted, a default value of '.' is assumed, unless\n"

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Aug 4 18:03:19 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.