subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1196005 - in /subversion/trunk/subversion/svn: cl.h copy-cmd.c util.c
Date Tue, 01 Nov 2011 14:20:29 GMT
Author: julianfoad
Date: Tue Nov  1 14:20:28 2011
New Revision: 1196005

URL: http://svn.apache.org/viewvc?rev=1196005&view=rev
Log:
Make 'svn' reject a non-empty peg revision specifier where a peg revision
does not make sense, such as on targets of 'svn add'. Allow the 'copy'
subcommand to accept '@HEAD' on the destination path as a special exemption
because that usage appears in the test suite.

* subversion/svn/cl.h,
  subversion/svn/util.c
  (svn_cl__eat_peg_revisions): Throw an error if there is a peg revision
    specifier that is not empty (just an '@' symbol).

* subversion/svn/copy-cmd.c
  (svn_cl__copy): Replace the inappropriate use of svn_cl__eat_peg_revisions
    with in-line code to handle the destination path. It previously called
    'eat' for all the source and destination arguments but only cared about
    the latter. As a special examption, allow '@HEAD'.

Modified:
    subversion/trunk/subversion/svn/cl.h
    subversion/trunk/subversion/svn/copy-cmd.c
    subversion/trunk/subversion/svn/util.c

Modified: subversion/trunk/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1196005&r1=1196004&r2=1196005&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Tue Nov  1 14:20:28 2011
@@ -766,42 +766,19 @@ svn_cl__node_description(const svn_wc_co
                          const char *wc_repos_root_URL,
                          apr_pool_t *pool);
 
-/* Return, in @a *true_targets_p, a copy of @a targets with peg revision
- * specifiers snipped off the end of each element.
- *
- * ### JAF TODO: This function is not good because it does not allow the
- * ### caller to detect if an invalid peg revision was specified.
- * ###
- * ### Callers should never have a need to silently *discard* all peg
- * ### revisions, even if they are doing this *after* saving any peg
- * ### revisions that might be of interest on certain arguments: I don't
- * ### think it can ever be correct to silently ignore a peg revision that
- * ### is specified, whether it makes semantic sense or not.
- * ###
- * ### Instead, callers should parse all the arguments and silently
- * ### ignore an *empty* peg revision part (just an "@", which can be
- * ### used to escape an earlier "@" in the argument) on any argument,
- * ### even an argument on which a peg revision does not make sense,
- * ### but should not silently ignore a non-empty peg when it does not
- * ### make sense.
- * ###
- * ### Something like:
- * ###   For each (URL-like?) argument that doesn't accept a peg rev:
- * ###     Parse into peg-rev and true-path parts;
- * ###     If (peg rev != unspecified)
- * ###       Error("This arg doesn't accept a peg rev.").
- * ###     Use the true-path part.
+/* Return, in @a *true_targets_p, a shallow copy of @a targets with any
+ * empty peg revision specifier snipped off the end of each element.  If any
+ * target has a non-empty peg revision specifier, throw an error.  The user
+ * may have specified a peg revision where it doesn't make sense to do so,
+ * or may have forgotten to escape an '@' character in a filename.
  *
  * This function is useful for subcommands for which peg revisions
- * do not make any sense. Such subcommands still need to allow peg
- * revisions to be specified on the command line so that users of
+ * do not make any sense. Such subcommands still need to allow an empty
+ * peg revision to be specified on the command line so that users of
  * the command line client can consistently escape '@' characters
  * in filenames by appending an '@' character, regardless of the
  * subcommand being used.
  *
- * If a peg revision is present but cannot be parsed, an error is thrown.
- * The user has likely forgotten to escape an '@' character in a filename.
- *
  * It is safe to pass the address of @a targets as @a true_targets_p.
  *
  * Do all allocations in @a pool. */

Modified: subversion/trunk/subversion/svn/copy-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/copy-cmd.c?rev=1196005&r1=1196004&r2=1196005&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/copy-cmd.c (original)
+++ subversion/trunk/subversion/svn/copy-cmd.c Tue Nov  1 14:20:28 2011
@@ -76,7 +76,19 @@ svn_cl__copy(apr_getopt_t *os,
       APR_ARRAY_PUSH(sources, svn_client_copy_source_t *) = source;
     }
 
-  SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
+  /* Get DST_PATH (the target path or URL) and check that no peg revision is
+   * specified for it. */
+  {
+    const char *tgt = APR_ARRAY_IDX(targets, targets->nelts - 1, const char *);
+    svn_opt_revision_t peg;
+
+    SVN_ERR(svn_opt_parse_path(&peg, &dst_path, tgt, pool));
+    if (peg.kind != svn_opt_revision_unspecified
+        && peg.kind != svn_opt_revision_head /* special exemption */)
+      return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+                               _("'%s': a peg revision is not allowed here"),
+                               tgt);
+  }
 
   /* Figure out which type of notification to use.
      (There is no need to check that the src paths are homogeneous;
@@ -84,8 +96,6 @@ svn_cl__copy(apr_getopt_t *os,
      error if they are not.) */
   src_path = APR_ARRAY_IDX(targets, 0, const char *);
   srcs_are_urls = svn_path_is_url(src_path);
-  dst_path = APR_ARRAY_IDX(targets, targets->nelts - 1, const char *);
-  apr_array_pop(targets);
   dst_is_url = svn_path_is_url(dst_path);
 
   if ((! srcs_are_urls) && (! dst_is_url))

Modified: subversion/trunk/subversion/svn/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/util.c?rev=1196005&r1=1196004&r2=1196005&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/util.c (original)
+++ subversion/trunk/subversion/svn/util.c Tue Nov  1 14:20:28 2011
@@ -1358,10 +1358,14 @@ svn_cl__eat_peg_revisions(apr_array_head
   for (i = 0; i < targets->nelts; i++)
     {
       const char *target = APR_ARRAY_IDX(targets, i, const char *);
-      const char *true_target;
+      const char *true_target, *peg;
 
-      SVN_ERR(svn_opt__split_arg_at_peg_revision(&true_target, NULL,
+      SVN_ERR(svn_opt__split_arg_at_peg_revision(&true_target, &peg,
                                                  target, pool));
+      if (peg[0] && peg[1])
+        return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+                                 _("'%s': a peg revision is not allowed here"),
+                                 target);
       APR_ARRAY_PUSH(true_targets, const char *) = true_target;
     }
 



Mime
View raw message