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 2014/02/26 14:19:00 UTC

svn commit: r1572044 - in /subversion/trunk/subversion: include/svn_types.h libsvn_ra_serf/log.c libsvn_ra_svn/client.c libsvn_ra_svn/protocol libsvn_subr/types.c mod_dav_svn/reports/log.c svnserve/serve.c

Author: stefan2
Date: Wed Feb 26 13:18:59 2014
New Revision: 1572044

URL: http://svn.apache.org/r1572044
Log:
Change the network encoding of the "move behavior" option enum from an
integer to a string as we already do for e.g. the depth option.

* subversion/include/svn_types.h
  (svn_move_behavior_to_word,
   svn_move_behavior_from_word): Declare new type<->string conversion utils.

* subversion/libsvn_subr/types.c
  (svn_move_behavior_to_word,
   svn_move_behavior_from_word): Implement these new utils.

* subversion/mod_dav_svn/reports/log.c
  (dav_svn__log_report): Use a string to encode the move behavior option.

* subversion/libsvn_ra_serf/log.c
  (create_log_body): Extract the move behavior from its string rep.

* subversion/svnserve/serve.c
  (log_cmd): Use a 'word' to encode the move behavior option.

* subversion/libsvn_ra_svn/client.c
  (perform_ra_svn_log): Extract the move behavior from the optional 'word'.

* subversion/libsvn_ra_svn/protocol
  (Main Command Set): Update log encoding command description.

Suggested by: ivan

Modified:
    subversion/trunk/subversion/include/svn_types.h
    subversion/trunk/subversion/libsvn_ra_serf/log.c
    subversion/trunk/subversion/libsvn_ra_svn/client.c
    subversion/trunk/subversion/libsvn_ra_svn/protocol
    subversion/trunk/subversion/libsvn_subr/types.c
    subversion/trunk/subversion/mod_dav_svn/reports/log.c
    subversion/trunk/subversion/svnserve/serve.c

Modified: subversion/trunk/subversion/include/svn_types.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_types.h?rev=1572044&r1=1572043&r2=1572044&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_types.h (original)
+++ subversion/trunk/subversion/include/svn_types.h Wed Feb 26 13:18:59 2014
@@ -1076,6 +1076,25 @@ typedef enum svn_move_behavior_t
   svn_move_behavior_auto_moves
 } svn_move_behavior_t;
 
+/** Return a constant string expressing @a value as an English word,
+ * e.g., "none", "explicit", etc.  The string is not localized,
+ * as it may be used for client<->server communications.
+ *
+ * @since New in 1.9.
+ */
+const char *
+svn_move_behavior_to_word(svn_move_behavior_t value);
+
+/** Return the appropriate move behavior for @a word.  @a word is as
+ * returned from svn_move_behavior_to_word().  If @a word does not
+ * represent a recognized behavior, return #svn_move_behavior_explicit_moves.
+ *
+ * @since New in 1.9.
+ */
+svn_move_behavior_t
+svn_move_behavior_from_word(const char *word);
+
+
 
 
 /** Callback function type for commits.

Modified: subversion/trunk/subversion/libsvn_ra_serf/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/log.c?rev=1572044&r1=1572043&r2=1572044&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/log.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/log.c Wed Feb 26 13:18:59 2014
@@ -475,9 +475,10 @@ create_log_body(serf_bucket_t **body_bkt
 
   if (log_ctx->move_behavior != svn_move_behavior_no_moves)
     {
+      const char *value = svn_move_behavior_to_word(log_ctx->move_behavior);
       svn_ra_serf__add_tag_buckets(buckets,
                                    "S:move-behavior",
-                                   apr_ltoa(pool, log_ctx->move_behavior),
+                                   value,
                                    alloc);
     }
 

Modified: subversion/trunk/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/client.c?rev=1572044&r1=1572043&r2=1572044&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/client.c Wed Feb 26 13:18:59 2014
@@ -1674,13 +1674,13 @@ perform_ra_svn_log(svn_error_t **outer_e
           else
             want_custom_revprops = TRUE;
         }
-      SVN_ERR(svn_ra_svn__write_tuple(conn, pool, "!)n)",
-                                      (apr_uint64_t) move_behavior));
+      SVN_ERR(svn_ra_svn__write_tuple(conn, pool, "!)w)",
+                                svn_move_behavior_to_word(move_behavior)));
     }
   else
     {
-      SVN_ERR(svn_ra_svn__write_tuple(conn, pool, "!w()n)", "all-revprops",
-                                      (apr_uint64_t) move_behavior));
+      SVN_ERR(svn_ra_svn__write_tuple(conn, pool, "!w()w)", "all-revprops",
+                                svn_move_behavior_to_word(move_behavior)));
 
       want_author = TRUE;
       want_date = TRUE;

Modified: subversion/trunk/subversion/libsvn_ra_svn/protocol
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/protocol?rev=1572044&r1=1572043&r2=1572044&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/protocol (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/protocol Wed Feb 26 13:18:59 2014
@@ -383,12 +383,11 @@ second place for auth-request point as n
                 ? limit:number
                 ? include-merged-revisions:bool
                 all-revprops | revprops ( revprop:string ... )
-                ? move-behavior:number )
+                ? move-behavior:word )
     Before sending response, server sends log entries, ending with "done".
     If a client does not want to specify a limit, it should send 0 as the
     limit parameter.  rev-props excludes author, date, and log; they are
     sent separately for backwards-compatibility.
-    Move-behavior is encoded like enum svn_move_behavior_t.
     log-entry: ( ( change:changed-path-entry ... ) rev:number
                  [ author:string ] [ date:string ] [ message:string ]
                  ? has-children:bool invalid-revnum:bool

Modified: subversion/trunk/subversion/libsvn_subr/types.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/types.c?rev=1572044&r1=1572043&r2=1572044&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/types.c (original)
+++ subversion/trunk/subversion/libsvn_subr/types.c Wed Feb 26 13:18:59 2014
@@ -350,3 +350,39 @@ svn_location_segment_dup(const svn_locat
     new_segment->path = apr_pstrdup(pool, segment->path);
   return new_segment;
 }
+
+const char *
+svn_move_behavior_to_word(svn_move_behavior_t value)
+{
+  switch (value)
+    {
+    case svn_move_behavior_no_moves:
+      return "none";
+    case svn_move_behavior_explicit_moves:
+      return "explicit";
+    case svn_move_behavior_auto_moves:
+      return "auto";
+    default:
+      return "INVALID-MOVE-BEHAVIOR";
+    }
+}
+
+svn_move_behavior_t
+svn_move_behavior_from_word(const char *word)
+{
+  if (word)
+    {
+      if (strcmp(word, "none") == 0)
+        return svn_move_behavior_no_moves;
+      if (strcmp(word, "explicit") == 0)
+        return svn_move_behavior_explicit_moves;
+      if (strcmp(word, "auto") == 0)
+        return svn_move_behavior_auto_moves;
+    }
+
+  /* There's no special value for invalid move behavior, and no convincing
+     reason to make one yet, so just fall back to "explicit moves only",
+     i.e. no conversion either way.
+  */
+  return svn_move_behavior_explicit_moves;
+}

Modified: subversion/trunk/subversion/mod_dav_svn/reports/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/reports/log.c?rev=1572044&r1=1572043&r2=1572044&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/reports/log.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/reports/log.c Wed Feb 26 13:18:59 2014
@@ -412,21 +412,8 @@ dav_svn__log_report(const dav_resource *
         }
       else if (strcmp(child->name, "move-behavior") == 0)
         {
-          int move_behavior_param;
-          serr = svn_cstring_atoi(&move_behavior_param,
-                                  dav_xml_get_cdata(child, resource->pool, 1));
-          if (serr)
-            return dav_svn__convert_err(serr, HTTP_BAD_REQUEST,
-                                        "Malformed CDATA in element "
-                                        "\"move-behavior\"", resource->pool);
-
-          if (   move_behavior_param < 0
-              || move_behavior_param > svn_move_behavior_auto_moves)
-            return dav_svn__convert_err(serr, HTTP_BAD_REQUEST,
-                                        "Invalid CDATA in element "
-                                        "\"move-behavior\"", resource->pool);
-
-          move_behavior = (svn_move_behavior_t) move_behavior_param;
+          const char *value = dav_xml_get_cdata(child, resource->pool, 1);
+          move_behavior = svn_move_behavior_from_word(value);
         }
       /* else unknown element; skip it */
     }

Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1572044&r1=1572043&r2=1572044&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Wed Feb 26 13:18:59 2014
@@ -2184,7 +2184,8 @@ static svn_error_t *log_cmd(svn_ra_svn_c
   char *revprop_word;
   svn_ra_svn_item_t *elt;
   int i;
-  apr_uint64_t limit, include_merged_revs_param, move_behavior_param;
+  apr_uint64_t limit, include_merged_revs_param;
+  const char *move_behavior_param;
   svn_move_behavior_t move_behavior;
   log_baton_t lb;
   authz_baton_t ab;
@@ -2192,7 +2193,7 @@ static svn_error_t *log_cmd(svn_ra_svn_c
   ab.server = b;
   ab.conn = conn;
 
-  SVN_ERR(svn_ra_svn__parse_tuple(params, pool, "l(?r)(?r)bb?n?Bwl?n", &paths,
+  SVN_ERR(svn_ra_svn__parse_tuple(params, pool, "l(?r)(?r)bb?n?Bwl?w", &paths,
                                   &start_rev, &end_rev, &send_changed_paths,
                                   &strict_node, &limit,
                                   &include_merged_revs_param,
@@ -2229,17 +2230,7 @@ static svn_error_t *log_cmd(svn_ra_svn_c
                              _("Unknown revprop word '%s' in log command"),
                              revprop_word);
 
-  if (move_behavior_param == SVN_RA_SVN_UNSPECIFIED_NUMBER)
-    move_behavior = svn_move_behavior_no_moves;
-  else if (move_behavior_param <= svn_move_behavior_auto_moves)
-    move_behavior = (svn_move_behavior_t) move_behavior_param;
-  else
-    return svn_error_createf(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
-                             apr_psprintf(pool,
-                                          _("Invalid move_behavior value"
-                                            " %%%s in log command"),
-                                          APR_UINT64_T_FMT),
-                             move_behavior_param);
+  move_behavior = svn_move_behavior_from_word(move_behavior_param);
 
   /* If we got an unspecified number then the user didn't send us anything,
      so we assume no limit.  If it's larger than INT_MAX then someone is