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 2013/10/23 19:34:57 UTC

svn commit: r1535080 - in /subversion/trunk: notes/http-and-webdav/webdav-protocol subversion/libsvn_ra_serf/log.c subversion/mod_dav_svn/reports/log.c

Author: stefan2
Date: Wed Oct 23 17:34:57 2013
New Revision: 1535080

URL: http://svn.apache.org/r1535080
Log:
Make our HTTP report for log actually transmit moves.
This change is simple as we can duplicate the ADD / REPLACE
code for moves.

* notes/http-and-webdav/webdav-protocol
  (log-report): add moved-path elements to our documentation

* subversion/mod_dav_svn/reports/log.c
  (start_path_with_copy_from): new utility handling changed paths
                               that _may_ have a copy-from; code
                               taken from log_receiver; handle moves
  (log_receiver): simplify; handle moves

* subversion/libsvn_ra_serf/log.c
  (log_state_e): add states for the new moved-path elements
  (log_ttable): add entries translating the new XML elements to
                internal state
  (log_closed): translate the new states to SVN path actions

Modified:
    subversion/trunk/notes/http-and-webdav/webdav-protocol
    subversion/trunk/subversion/libsvn_ra_serf/log.c
    subversion/trunk/subversion/mod_dav_svn/reports/log.c

Modified: subversion/trunk/notes/http-and-webdav/webdav-protocol
URL: http://svn.apache.org/viewvc/subversion/trunk/notes/http-and-webdav/webdav-protocol?rev=1535080&r1=1535079&r2=1535080&view=diff
==============================================================================
--- subversion/trunk/notes/http-and-webdav/webdav-protocol (original)
+++ subversion/trunk/notes/http-and-webdav/webdav-protocol Wed Oct 23 17:34:57 2013
@@ -374,6 +374,8 @@ Response:
       <S:has-children/> (optional)
       <S:added-path( copyfrom-path="PATH" copyfrom-rev="REVNUM">PATH</S:added-path>... (optional)
       <S:replaced-path( copyfrom-path="PATH" copyfrom-rev="REVNUM">PATH</S:replaced-path>... (optional)
+      <S:moved-path( copyfrom-path="PATH" copyfrom-rev="REVNUM">PATH</S:moved-path>... (optional)
+      <S:replaced-by-moved-path( copyfrom-path="PATH" copyfrom-rev="REVNUM">PATH</S:replaced-by-moved-path>... (optional)
       <S:deleted-path>PATH</S:deleted-path>... (optional)
       <S:modified-path>PATH</S:modified-path>... (optional)
     </S:log-item>

Modified: subversion/trunk/subversion/libsvn_ra_serf/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/log.c?rev=1535080&r1=1535079&r2=1535080&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/log.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/log.c Wed Oct 23 17:34:57 2013
@@ -60,6 +60,8 @@ enum log_state_e {
   HAS_CHILDREN,
   ADDED_PATH,
   REPLACED_PATH,
+  MOVED_PATH,
+  MOVE_REPLACED_PATH,
   DELETED_PATH,
   MODIFIED_PATH,
   SUBTRACTIVE_MERGE
@@ -137,6 +139,14 @@ static const svn_ra_serf__xml_transition
     TRUE, { "?node-kind", "?text-mods", "?prop-mods",
             "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
 
+  { ITEM, S_, "moved-path", MOVED_PATH,
+    TRUE, { "?node-kind", "?text-mods", "?prop-mods",
+            "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
+
+  { ITEM, S_, "replaced-by-moved-path", MOVE_REPLACED_PATH,
+    TRUE, { "?node-kind", "?text-mods", "?prop-mods",
+            "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
+
   { ITEM, S_, "deleted-path", DELETED_PATH,
     TRUE, { "?node-kind", "?text-mods", "?prop-mods", NULL }, TRUE },
 
@@ -384,6 +394,10 @@ log_closed(svn_ra_serf__xml_estate_t *xe
         action = 'A';
       else if (leaving_state == REPLACED_PATH)
         action = 'R';
+      else if (leaving_state == MOVED_PATH)
+        action = 'V';
+      else if (leaving_state == MOVE_REPLACED_PATH)
+        action = 'E';
       else if (leaving_state == DELETED_PATH)
         action = 'D';
       else

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=1535080&r1=1535079&r2=1535080&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/reports/log.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/reports/log.c Wed Oct 23 17:34:57 2013
@@ -87,6 +87,48 @@ maybe_send_header(struct log_receiver_ba
   return SVN_NO_ERROR;
 }
 
+/* Utility for log_receiver opening a new XML element in LRB's brigade
+   for LOG_ITEM and return the element's name in *ELEMENT.  Use POOL for
+   temporary allocations.
+
+   Call this function for items that may have a copy-from */
+static svn_error_t *
+start_path_with_copy_from(const char **element,
+                          struct log_receiver_baton *lrb,
+                          svn_log_changed_path2_t *log_item,
+                          apr_pool_t *pool)
+{
+  switch (log_item->action)
+    {
+      case 'A': *element = "S:added-path";
+                break;
+      case 'R': *element = "S:replaced-path";
+                break;
+      case 'V': *element = "S:moved-path";
+                break;
+      case 'E': *element = "S:replaced-by-moved-path";
+                break;
+
+      default:  /* Caller, you did wrong! */
+                SVN_ERR_MALFUNCTION();
+    }
+
+  if (log_item->copyfrom_path
+      && SVN_IS_VALID_REVNUM(log_item->copyfrom_rev))
+    SVN_ERR(dav_svn__brigade_printf
+            (lrb->bb, lrb->output,
+             "<%s copyfrom-path=\"%s\" copyfrom-rev=\"%ld\"",
+             *element,
+             apr_xml_quote_string(pool,
+                                  log_item->copyfrom_path,
+                                  1), /* escape quotes */
+             log_item->copyfrom_rev));
+  else
+    SVN_ERR(dav_svn__brigade_printf(lrb->bb, lrb->output, "<%s", *element));
+
+  return SVN_NO_ERROR;
+}
+
 
 /* This implements `svn_log_entry_receiver_t'.
    BATON is a `struct log_receiver_baton *'.  */
@@ -203,39 +245,11 @@ log_receiver(void *baton,
           switch (log_item->action)
             {
             case 'A':
-              if (log_item->copyfrom_path
-                  && SVN_IS_VALID_REVNUM(log_item->copyfrom_rev))
-                SVN_ERR(dav_svn__brigade_printf
-                        (lrb->bb, lrb->output,
-                         "<S:added-path copyfrom-path=\"%s\""
-                         " copyfrom-rev=\"%ld\"",
-                         apr_xml_quote_string(iterpool,
-                                              log_item->copyfrom_path,
-                                              1), /* escape quotes */
-                         log_item->copyfrom_rev));
-              else
-                SVN_ERR(dav_svn__brigade_puts(lrb->bb, lrb->output,
-                                              "<S:added-path"));
-
-              close_element = "S:added-path";
-              break;
-
             case 'R':
-              if (log_item->copyfrom_path
-                  && SVN_IS_VALID_REVNUM(log_item->copyfrom_rev))
-                SVN_ERR(dav_svn__brigade_printf
-                        (lrb->bb, lrb->output,
-                         "<S:replaced-path copyfrom-path=\"%s\""
-                         " copyfrom-rev=\"%ld\"",
-                         apr_xml_quote_string(iterpool,
-                                              log_item->copyfrom_path,
-                                              1), /* escape quotes */
-                         log_item->copyfrom_rev));
-              else
-                SVN_ERR(dav_svn__brigade_puts(lrb->bb, lrb->output,
-                                              "<S:replaced-path"));
-
-              close_element = "S:replaced-path";
+            case 'V':
+            case 'E':
+              SVN_ERR(start_path_with_copy_from(&close_element, lrb,
+                                                log_item, iterpool));
               break;
 
             case 'D':