You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/11/17 14:32:14 UTC

svn commit: r1036032 - /subversion/trunk/subversion/svn/main.c

Author: stsp
Date: Wed Nov 17 13:32:14 2010
New Revision: 1036032

URL: http://svn.apache.org/viewvc?rev=1036032&view=rev
Log:
* subversion/svn/main.c
  (main): Make "merge -c -r42" work, which previously caused an error:
    "svn: Non-numeric change argument (-r42) given to -c"
   This makes it easier to reverse-merge copy/pasted revision numbers which
   start with 'r'. It's also consistent with the forward-merge syntax
   "-c r42" which has always been working.

Modified:
    subversion/trunk/subversion/svn/main.c

Modified: subversion/trunk/subversion/svn/main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/main.c?rev=1036032&r1=1036031&r2=1036032&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/main.c (original)
+++ subversion/trunk/subversion/svn/main.c Wed Nov 17 13:32:14 2010
@@ -1388,6 +1388,15 @@ main(int argc, const char *argv[])
               const char *change_str =
                 APR_ARRAY_IDX(change_revs, i, const char *);
               const char *s = change_str;
+              svn_boolean_t is_negative;
+
+              /* Check for a leading minus to allow -c -r42.
+               * The is_negative flag is only used to handle this one case.
+               * The -c -42 case (without 'r') is handled by strtol()
+               * returning a negative number. */
+              is_negative = (*s == '-');
+              if (is_negative)
+                s++;
 
               /* Allow any number of 'r's to prefix a revision number.
                  ### TODO: Any reason we're not just using opt.c's
@@ -1398,7 +1407,7 @@ main(int argc, const char *argv[])
               changeno = changeno_end = strtol(s, &end, 10);
               if (end != s && *end == '-')
                 {
-                  if (changeno < 0)
+                  if (changeno < 0 || is_negative)
                     {
                       err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                                               _("Negative number in range (%s)"
@@ -1426,6 +1435,9 @@ main(int argc, const char *argv[])
                   return svn_cmdline_handle_exit_error(err, pool, "svn: ");
                 }
 
+              if (is_negative)
+                changeno = -changeno;
+
               /* Figure out the range:
                     -c N  -> -r N-1:N
                     -c -N -> -r N:N-1