subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kot...@apache.org
Subject svn commit: r1703369 - in /subversion/branches/ra_serf-stream-commit/subversion: include/svn_delta.h libsvn_delta/cancel.c libsvn_delta/default_editor.c
Date Wed, 16 Sep 2015 08:59:33 GMT
Author: kotkov
Date: Wed Sep 16 08:59:32 2015
New Revision: 1703369

URL: http://svn.apache.org/r1703369
Log:
On the ra_serf-stream-commit branch: Sketch the new delta editor callback.

It would allow us to apply an existing svn_txdelta_stream_t delta stream
to a file.  Using this callback in libsvn_ra_serf would allow us to get rid
of storing the svndiff into a temporary file prior to PUT'tting contents.

* subversion\include\svn_delta.h
  (svn_txdelta_stream_open_func_t): New typedef.
  (svn_delta_editor_t): Add a forward declaration for this type.
  (svn_delta_editor_t.apply_textdelta_stream): New callback.

* subversion\libsvn_delta\default_editor.c
  (apply_textdelta_stream): Provide default implementation for this callback
   that fallbacks to apply_textdelta().
  (default_editor): Extend the default instance of svn_delta_editor_t.

* subversion\libsvn_delta\cancel.c
  (apply_textdelta_stream): Implement this forwarding callback, and ...
  (svn_delta_get_cancellation_editor): ...install it here.

Modified:
    subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h
    subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/cancel.c
    subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/default_editor.c

Modified: subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h?rev=1703369&r1=1703368&r2=1703369&view=diff
==============================================================================
--- subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h (original)
+++ subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h Wed Sep 16 08:59:32
2015
@@ -330,6 +330,16 @@ typedef svn_error_t *
 typedef const unsigned char *
 (*svn_txdelta_md5_digest_fn_t)(void *baton);
 
+/** A typedef for a function that opens a #svn_txdelta_stream_t object,
+ * allocated in @a pool.  @a baton is provided by the caller.
+ *
+ * @since New in 1.10.
+ */
+typedef svn_error_t *
+(*svn_txdelta_stream_open_func_t)(svn_txdelta_stream_t **txdelta_stream,
+                                  void *baton,
+                                  apr_pool_t *pool);
+
 /** Create and return a generic text delta stream with @a baton, @a
  * next_window and @a md5_digest.  Allocate the new stream in @a
  * pool.
@@ -662,6 +672,9 @@ svn_txdelta_skip_svndiff_window(apr_file
  * @{
  */
 
+/* Forward declarations. */
+typedef struct svn_delta_editor_t svn_delta_editor_t;
+
 /** A structure full of callback functions the delta source will invoke
  * as it produces the delta.
  *
@@ -843,7 +856,7 @@ svn_txdelta_skip_svndiff_window(apr_file
  * dead; the only further operation which may be called on the editor
  * is @c abort_edit.
  */
-typedef struct svn_delta_editor_t
+struct svn_delta_editor_t
 {
   /** Set the target revision for this edit to @a target_revision.  This
    * call, if used, should precede all other editor calls.
@@ -1115,9 +1128,44 @@ typedef struct svn_delta_editor_t
   svn_error_t *(*abort_edit)(void *edit_baton,
                              apr_pool_t *scratch_pool);
 
+  /** Apply a text delta stream, yielding the new revision of a file.
+   *
+   * @a file_baton indicates the file we're creating or updating, and the
+   * ancestor file on which it is based; it is the baton set by some
+   * prior @c add_file or @c open_file callback.
+   *
+   * @a open_func is a function that opens a #svn_txdelta_stream_t object.
+   * @a open_baton is provided by the caller.
+   *
+   * @a base_checksum is the hex MD5 digest for the base text against
+   * which the delta is being applied; it is ignored if NULL, and may
+   * be ignored even if not NULL.  If it is not ignored, it must match
+   * the checksum of the base text against which svndiff data is being
+   * applied; if it does not, @c apply_textdelta_stream call which detects
+   * the mismatch will return the error SVN_ERR_CHECKSUM_MISMATCH
+   * (if there is no base text, there may still be an error if
+   * @a base_checksum is neither NULL nor the hex MD5 checksum of the
+   * empty string).
+   *
+   * @a result_checksum is the hex MD5 digest for the fulltext that
+   * resulted from a delta application.  The checksum is ignored if NULL.
+   * If not null, it is compared to the checksum of the new fulltext, and
+   * the error SVN_ERR_CHECKSUM_MISMATCH is returned if they do not match.
+   *
+   * Any temporary allocations may be performed in @a scratch_pool.
+   */
+  svn_error_t *(*apply_textdelta_stream)(
+    const svn_delta_editor_t *editor,
+    void *file_baton,
+    const char *base_checksum,
+    const char *result_checksum,
+    svn_txdelta_stream_open_func_t open_func,
+    void *open_baton,
+    apr_pool_t *scratch_pool);
+
   /* Be sure to update svn_delta_get_cancellation_editor() and
    * svn_delta_default_editor() if you add a new callback here. */
-} svn_delta_editor_t;
+};
 
 
 /** Return a default delta editor template, allocated in @a pool.

Modified: subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/cancel.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/cancel.c?rev=1703369&r1=1703368&r2=1703369&view=diff
==============================================================================
--- subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/cancel.c (original)
+++ subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/cancel.c Wed Sep 16
08:59:32 2015
@@ -222,6 +222,28 @@ apply_textdelta(void *file_baton,
 }
 
 static svn_error_t *
+apply_textdelta_stream(const svn_delta_editor_t *editor,
+                       void *file_baton,
+                       const char *base_checksum,
+                       const char *result_checksum,
+                       svn_txdelta_stream_open_func_t open_func,
+                       void *open_baton,
+                       apr_pool_t *scratch_pool)
+{
+  struct file_baton *fb = file_baton;
+  struct edit_baton *eb = fb->edit_baton;
+
+  SVN_ERR(eb->cancel_func(eb->cancel_baton));
+
+  return eb->wrapped_editor->apply_textdelta_stream(eb->wrapped_editor,
+                                                    fb->wrapped_file_baton,
+                                                    base_checksum,
+                                                    result_checksum,
+                                                    open_func, open_baton,
+                                                    scratch_pool);
+}
+
+static svn_error_t *
 close_file(void *file_baton,
            const char *text_checksum,
            apr_pool_t *pool)
@@ -354,6 +376,7 @@ svn_delta_get_cancellation_editor(svn_ca
       tree_editor->add_file = add_file;
       tree_editor->open_file = open_file;
       tree_editor->apply_textdelta = apply_textdelta;
+      tree_editor->apply_textdelta_stream = apply_textdelta_stream;
       tree_editor->change_file_prop = change_file_prop;
       tree_editor->close_file = close_file;
       tree_editor->absent_file = absent_file;

Modified: subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/default_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/default_editor.c?rev=1703369&r1=1703368&r2=1703369&view=diff
==============================================================================
--- subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/default_editor.c (original)
+++ subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/default_editor.c Wed
Sep 16 08:59:32 2015
@@ -133,6 +133,33 @@ close_file(void *file_baton,
 }
 
 
+static svn_error_t *
+apply_textdelta_stream(const svn_delta_editor_t *editor,
+                       void *file_baton,
+                       const char *base_checksum,
+                       const char *result_checksum,
+                       svn_txdelta_stream_open_func_t open_func,
+                       void *open_baton,
+                       apr_pool_t *scratch_pool)
+{
+  svn_txdelta_window_handler_t handler;
+  void *handler_baton;
+
+  SVN_ERR(editor->apply_textdelta(file_baton, base_checksum,
+                                  scratch_pool, &handler,
+                                  &handler_baton));
+  if (handler != svn_delta_noop_window_handler)
+    {
+      svn_txdelta_stream_t *txdelta_stream;
+
+      SVN_ERR(open_func(&txdelta_stream, open_baton, scratch_pool));
+      SVN_ERR(svn_txdelta_send_txstream(txdelta_stream, handler,
+                                        handler_baton, scratch_pool));
+    }
+
+  return SVN_NO_ERROR;
+}
+
 
 static const svn_delta_editor_t default_editor =
 {
@@ -151,7 +178,8 @@ static const svn_delta_editor_t default_
   close_file,
   absent_xxx_func,
   single_baton_func,
-  single_baton_func
+  single_baton_func,
+  apply_textdelta_stream
 };
 
 svn_delta_editor_t *



Mime
View raw message