You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2011/12/09 15:59:09 UTC

svn commit: r1212463 - in /subversion/trunk/subversion: svn/merge-cmd.c tests/cmdline/input_validation_tests.py

Author: julianfoad
Date: Fri Dec  9 14:59:09 2011
New Revision: 1212463

URL: http://svn.apache.org/viewvc?rev=1212463&view=rev
Log:
Improve the error message given when a merge source path is specified as a
working copy path without a suitable revision specifier. A repository
revision is required, and if no revision or a WC revision were specified, the
previous failure mode was inconsistent:

  $ svn merge iota1 iota2 iota
  svn: E195002: A working copy merge source needs an explicit revision
  $ svn merge iota@COMMITTED iota@PREV iota
  svn: E195000: A path under version control is needed for this operation

The new failure mode is:

  $ svn merge iota1 iota2 iota
  svn: E195002: Invalid merge source 'iota1'; a working copy path can only \
    be used with a repository revision (a number, a date, or head)
  $ svn merge iota@COMMITTED iota@PREV iota
  svn: E195002: Invalid merge source 'iota'; a working copy path can only \
    be used with a repository revision (a number, a date, or head)

Trapping this error earlier (in svn rather than in svn_client_merge4) also
gives us more freedom to change how svn_client_merge4 handles the condition of
being passed a working copy path and a working copy revision specifier.

* subversion/svn/merge-cmd.c
  (svn_cl__merge): On WC source paths, require a number, date or head
    revision rather than any non-empty revision specifier. Improve the error
    message when that is not satisfied.

* subversion/tests/cmdline/input_validation_tests.py
  (invalid_merge_args): Generalize the expected error pattern to match both
    before and after this change. Test for only one kind of invalidity at a
    time: for example, when testing for an invalid target, do not specify an
    invalid source as well. Extend with more cases.

Modified:
    subversion/trunk/subversion/svn/merge-cmd.c
    subversion/trunk/subversion/tests/cmdline/input_validation_tests.py

Modified: subversion/trunk/subversion/svn/merge-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/merge-cmd.c?rev=1212463&r1=1212462&r2=1212463&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/merge-cmd.c (original)
+++ subversion/trunk/subversion/svn/merge-cmd.c Fri Dec  9 14:59:09 2011
@@ -207,14 +207,24 @@ svn_cl__merge(apr_getopt_t *os,
          revisions--since it ignores local modifications it may not do what
          the user expects.  Forcing the user to specify a repository
          revision should avoid any confusion. */
-      if ((first_range_start.kind == svn_opt_revision_unspecified
-           && ! svn_path_is_url(sourcepath1))
-          ||
-          (first_range_end.kind == svn_opt_revision_unspecified
-           && ! svn_path_is_url(sourcepath2)))
-        return svn_error_create
-          (SVN_ERR_CLIENT_BAD_REVISION, 0,
-           _("A working copy merge source needs an explicit revision"));
+      if (first_range_start.kind != svn_opt_revision_number
+          && first_range_start.kind != svn_opt_revision_date
+          && first_range_start.kind != svn_opt_revision_head
+          && ! svn_path_is_url(sourcepath1))
+        return svn_error_createf(
+          SVN_ERR_CLIENT_BAD_REVISION, NULL,
+          _("Invalid merge source '%s'; a working copy path can only be "
+            "used with a repository revision (a number, a date, or head)"),
+          svn_dirent_local_style(sourcepath1, pool));
+      if (first_range_end.kind != svn_opt_revision_number
+          && first_range_end.kind != svn_opt_revision_date
+          && first_range_end.kind != svn_opt_revision_head
+          && ! svn_path_is_url(sourcepath2))
+        return svn_error_createf(
+          SVN_ERR_CLIENT_BAD_REVISION, NULL,
+          _("Invalid merge source '%s'; a working copy path can only be "
+            "used with a repository revision (a number, a date, or head)"),
+          svn_dirent_local_style(sourcepath2, pool));
 
       /* Default peg revisions to each URL's youngest revision. */
       if (first_range_start.kind == svn_opt_revision_unspecified)

Modified: subversion/trunk/subversion/tests/cmdline/input_validation_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/input_validation_tests.py?rev=1212463&r1=1212462&r2=1212463&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/input_validation_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/input_validation_tests.py Fri Dec  9 14:59:09 2011
@@ -151,13 +151,18 @@ def invalid_log_targets(sbox):
 def invalid_merge_args(sbox):
   "invalid arguments for 'merge'"
   sbox.build(read_only=True)
-  run_and_verify_svn_in_wc(sbox, "svn: E195002: A working copy merge source needs "
-                           "an explicit revision", 'merge', 'iota', '^/')
-  for (src, target) in [('iota@HEAD', '^/'), ('iota@BASE', 'file://')]:
-    run_and_verify_svn_in_wc(sbox, "svn: E205000: Merge sources must both be either "
-                             "paths or URLs", 'merge', src, target)
+  for args in [('iota', 'A/mu@HEAD'),
+               ('iota@BASE', 'A/mu@HEAD')]:
+    run_and_verify_svn_in_wc(sbox, "svn: E195002: .* working copy .* revision",
+                             'merge', *args)
+  for args in [(sbox.repo_url, 'A@1', 'A'),
+               ('^/A', 'A@HEAD', 'A'),
+               ('A@HEAD', '^/A', 'A'),
+               ('A@HEAD', '^/A')]:
+    run_and_verify_svn_in_wc(sbox, "svn: E205000: Merge sources must both "
+                             "be either paths or URLs", 'merge', *args)
   run_and_verify_svn_in_wc(sbox, "svn: E155010: Path '.*' does not exist",
-                           'merge', 'iota@BASE', 'iota@HEAD', 'nonexistent')
+                           'merge', '^/@0', '^/@1', 'nonexistent')
   run_and_verify_svn_in_wc(sbox, "svn: E205000: Too many arguments given",
                           'merge', '-c42', '^/A/B', '^/A/C', 'iota')
   run_and_verify_svn_in_wc(sbox, "svn: E205000: Cannot specify a revision range with" +