You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/12/07 18:35:44 UTC

svn commit: r1211553 - in /subversion/trunk/subversion: include/svn_delta.h libsvn_delta/compat.c libsvn_repos/commit.c libsvn_repos/dump.c libsvn_wc/update_editor.c

Author: hwright
Date: Wed Dec  7 17:35:44 2011
New Revision: 1211553

URL: http://svn.apache.org/viewvc?rev=1211553&view=rev
Log:
Ev2 shims: fetch the proper delta base to reconstruct the full text when
converting from a delta editor to an editor.

Current number of test failures: 649

* subversion/include/svn_delta.h
  (svn_delta_fetch_base_func_t): New.
  (svn_delta_shim_callbacks_t): Add fetch base func and baton.

* subversion/libsvn_wc/update_editor.c
  (fetch_base_func): New.
  (make_editor): Populate fetch_base_func and baton callbacks.

* subversion/libsvn_repos/commit.c
  (fetch_base_func): New.
  (svn_repos_get_commit_editor5): Populate fetch_base_func and baton callbacks.

* subversion/libsvn_repos/dump.c
  (fetch_base_func): New.
  (get_dump_editor): Populate fetch_base_func and baton callbacks.
 
* subversion/libsvn_delta/compat.c
  (ev2_edit_baton): Add fetch base func and baton members.
  (ev2_add_file, ev2_open_file): Go fetch the delta base via the callbacks.
  (window_handler): Trace error return.
  (ev2_apply_textdelta): If given a delta base, use it. 
  (delta_from_editor): Take a use fetch base func and baton.
  (svn_editor__insert_shims): Provide fetch base func and baton to
    delta_from_editor(). 

Modified:
    subversion/trunk/subversion/include/svn_delta.h
    subversion/trunk/subversion/libsvn_delta/compat.c
    subversion/trunk/subversion/libsvn_repos/commit.c
    subversion/trunk/subversion/libsvn_repos/dump.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c

Modified: subversion/trunk/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_delta.h?rev=1211553&r1=1211552&r2=1211553&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_delta.h (original)
+++ subversion/trunk/subversion/include/svn_delta.h Wed Dec  7 17:35:44 2011
@@ -1111,6 +1111,20 @@ typedef svn_error_t *(*svn_delta_fetch_k
   apr_pool_t *scratch_pool
   );
 
+/** Callback to fetch the FILENAME of a file to use as the delta base for
+ * PATH.  The file should last at least as long as RESULT_POOL.  If the base
+ * stream is empty, return NULL through FILENAME.
+ *
+ * @since New in 1.8.
+ */
+typedef svn_error_t *(*svn_delta_fetch_base_func_t)(
+  const char **filename,
+  void *baton,
+  const char *path,
+  apr_pool_t *result_pool,
+  apr_pool_t *scratch_pool
+  );
+
 /** Collection of callbacks used for the shim code.  To enable this struct
  * to grow, always use svn_delta_shim_callbacks_default()
  * to allocate new instances of it.
@@ -1123,6 +1137,8 @@ typedef struct svn_delta_shim_callbacks_
   void *fetch_props_baton;
   svn_delta_fetch_kind_func_t fetch_kind_func;
   void *fetch_kind_baton;
+  svn_delta_fetch_base_func_t fetch_base_func;
+  void *fetch_base_baton;
 } svn_delta_shim_callbacks_t;
 
 /** Return a collection of default shim functions in @a result_pool.

Modified: subversion/trunk/subversion/libsvn_delta/compat.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/compat.c?rev=1211553&r1=1211552&r2=1211553&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/compat.c (original)
+++ subversion/trunk/subversion/libsvn_delta/compat.c Wed Dec  7 17:35:44 2011
@@ -123,6 +123,9 @@ struct ev2_edit_baton
 
   target_revision_func_t target_revision_func;
   void *target_revision_baton;
+
+  svn_delta_fetch_base_func_t fetch_base_func;
+  void *fetch_base_baton;
 };
 
 struct ev2_dir_baton
@@ -536,9 +539,12 @@ ev2_add_file(const char *path,
 
   fb->eb = pb->eb;
   fb->path = apr_pstrdup(result_pool, path);
-  fb->delta_base = NULL;
   *file_baton = fb;
 
+  SVN_ERR(fb->eb->fetch_base_func(&fb->delta_base,
+                                  fb->eb->fetch_base_baton,
+                                  path, result_pool, result_pool));
+
   if (!copyfrom_path)
     {
       /* A simple add. */
@@ -572,7 +578,10 @@ ev2_open_file(const char *path,
 
   fb->eb = pb->eb;
   fb->path = apr_pstrdup(result_pool, path);
-  fb->delta_base = NULL;
+
+  SVN_ERR(fb->eb->fetch_base_func(&fb->delta_base,
+                                  fb->eb->fetch_base_baton,
+                                  path, result_pool, result_pool));
 
   *file_baton = fb;
   return SVN_NO_ERROR;
@@ -598,7 +607,7 @@ window_handler(svn_txdelta_window_t *win
 
   svn_pool_destroy(hb->pool);
 
-  return err;
+  return svn_error_trace(err);
 }
 
 
@@ -619,6 +628,9 @@ ev2_apply_textdelta(void *file_baton,
 
   if (! fb->delta_base)
     source = svn_stream_empty(handler_pool);
+  else
+    SVN_ERR(svn_stream_open_readonly(&source, fb->delta_base, handler_pool,
+                                     result_pool));
 
   SVN_ERR(svn_stream_open_unique(&target, &pca->path, NULL,
                                  svn_io_file_del_on_pool_cleanup,
@@ -743,6 +755,8 @@ delta_from_editor(const svn_delta_editor
                   svn_boolean_t *found_abs_paths,
                   svn_delta_fetch_props_func_t fetch_props_func,
                   void *fetch_props_baton,
+                  svn_delta_fetch_base_func_t fetch_base_func,
+                  void *fetch_base_baton,
                   start_edit_func_t start_edit,
                   void *start_edit_baton,
                   target_revision_func_t target_revision,
@@ -782,6 +796,9 @@ delta_from_editor(const svn_delta_editor
   eb->start_edit = start_edit;
   eb->start_edit_baton = start_edit_baton;
 
+  eb->fetch_base_func = fetch_base_func;
+  eb->fetch_base_baton = fetch_base_baton;
+
   eb->target_revision_func = target_revision;
   eb->target_revision_baton = target_revision_baton;
 
@@ -1566,6 +1583,8 @@ svn_editor__insert_shims(const svn_delta
                             found_abs_paths,
                             shim_callbacks->fetch_props_func,
                             shim_callbacks->fetch_props_baton,
+                            shim_callbacks->fetch_base_func,
+                            shim_callbacks->fetch_base_baton,
                             start_edit_func, seb,
                             target_revision_func, seb,
                             result_pool));

Modified: subversion/trunk/subversion/libsvn_repos/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/commit.c?rev=1211553&r1=1211552&r2=1211553&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/commit.c (original)
+++ subversion/trunk/subversion/libsvn_repos/commit.c Wed Dec  7 17:35:44 2011
@@ -815,6 +815,43 @@ kind_fetch_func(svn_kind_t *kind,
   return SVN_NO_ERROR;
 } 
 
+static svn_error_t *
+fetch_base_func(const char **filename,
+                void *baton,
+                const char *path,
+                apr_pool_t *result_pool,
+                apr_pool_t *scratch_pool)
+{
+  struct edit_baton *eb = baton;
+  svn_stream_t *contents;
+  svn_stream_t *file_stream;
+  const char *tmp_filename;
+  svn_fs_root_t *fs_root;
+  svn_error_t *err;
+
+  SVN_ERR(svn_fs_revision_root(&fs_root, eb->fs,
+                               svn_fs_txn_base_revision(eb->txn),
+                               scratch_pool));
+
+  err = svn_fs_file_contents(&contents, fs_root, path, scratch_pool);
+  if (err && err->apr_err == SVN_ERR_FS_NOT_FOUND)
+    {
+      svn_error_clear(err);
+      *filename = NULL;
+      return SVN_NO_ERROR;
+    }
+  else if (err)
+    return svn_error_trace(err);
+  SVN_ERR(svn_stream_open_unique(&file_stream, &tmp_filename, NULL,
+                                 svn_io_file_del_on_pool_cleanup,
+                                 scratch_pool, scratch_pool));
+  SVN_ERR(svn_stream_copy3(contents, file_stream, NULL, NULL, scratch_pool));
+
+  *filename = apr_pstrdup(result_pool, tmp_filename);
+
+  return SVN_NO_ERROR;
+}
+
 
 
 /*** Public interfaces. ***/
@@ -893,6 +930,8 @@ svn_repos_get_commit_editor5(const svn_d
   shim_callbacks->fetch_props_baton = eb;
   shim_callbacks->fetch_kind_func = kind_fetch_func;
   shim_callbacks->fetch_kind_baton = eb;
+  shim_callbacks->fetch_base_func = fetch_base_func;
+  shim_callbacks->fetch_base_baton = eb;
 
   SVN_ERR(svn_editor__insert_shims(editor, edit_baton, *editor, *edit_baton,
                                    shim_callbacks, pool, pool));

Modified: subversion/trunk/subversion/libsvn_repos/dump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/dump.c?rev=1211553&r1=1211552&r2=1211553&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/dump.c (original)
+++ subversion/trunk/subversion/libsvn_repos/dump.c Wed Dec  7 17:35:44 2011
@@ -849,6 +849,37 @@ change_dir_prop(void *parent_baton,
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+fetch_base_func(const char **filename,
+                void *baton,
+                const char *path,
+                apr_pool_t *result_pool,
+                apr_pool_t *scratch_pool)
+{
+  struct edit_baton *eb = baton;
+  svn_stream_t *contents;
+  svn_stream_t *file_stream;
+  const char *tmp_filename;
+  svn_error_t *err;
+
+  err = svn_fs_file_contents(&contents, eb->fs_root, path, scratch_pool);
+  if (err && err->apr_err == SVN_ERR_FS_NOT_FOUND)
+    {
+      svn_error_clear(err);
+      *filename = NULL;
+      return SVN_NO_ERROR;
+    }
+  else if (err)
+    return svn_error_trace(err);
+  SVN_ERR(svn_stream_open_unique(&file_stream, &tmp_filename, NULL,
+                                 svn_io_file_del_on_pool_cleanup,
+                                 scratch_pool, scratch_pool));
+  SVN_ERR(svn_stream_copy3(contents, file_stream, NULL, NULL, scratch_pool));
+
+  *filename = apr_pstrdup(result_pool, tmp_filename);
+
+  return SVN_NO_ERROR;
+}
 
 
 static svn_error_t *
@@ -898,6 +929,9 @@ get_dump_editor(const svn_delta_editor_t
   *edit_baton = eb;
   *editor = dump_editor;
 
+  shim_callbacks->fetch_base_func = fetch_base_func;
+  shim_callbacks->fetch_base_baton = eb;
+
   SVN_ERR(svn_editor__insert_shims(editor, edit_baton, *editor, *edit_baton,
                                    shim_callbacks, pool, pool));
 

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1211553&r1=1211552&r2=1211553&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Wed Dec  7 17:35:44 2011
@@ -4715,6 +4715,47 @@ close_edit(void *edit_baton,
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+fetch_base_func(const char **filename,
+                void *baton,
+                const char *path,
+                apr_pool_t *result_pool,
+                apr_pool_t *scratch_pool)
+{
+  struct edit_baton *eb = baton;
+  svn_stream_t *contents;
+  svn_stream_t *file_stream;
+  const char *tmp_filename;
+  const svn_checksum_t *checksum;
+  svn_error_t *err;
+  const char *local_abspath = svn_dirent_join(eb->target_abspath, path,
+                                              scratch_pool);
+
+  err = svn_wc__db_base_get_info(NULL, NULL, NULL, NULL, NULL, NULL,
+                                 NULL, NULL, NULL, NULL, &checksum,
+                                 NULL, NULL, NULL, NULL, eb->db,
+                                 local_abspath, scratch_pool, scratch_pool);
+  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+    {
+      svn_error_clear(err);
+      *filename = NULL;
+      return SVN_NO_ERROR;
+    }
+  else if (err)
+    return svn_error_trace(err);
+  SVN_ERR(svn_wc__db_pristine_read(&contents, NULL, eb->db, local_abspath,
+                                   checksum, scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_stream_open_unique(&file_stream, &tmp_filename, NULL,
+                                 svn_io_file_del_on_pool_cleanup,
+                                 scratch_pool, scratch_pool));
+  SVN_ERR(svn_stream_copy3(contents, file_stream, NULL, NULL, scratch_pool));
+
+  *filename = apr_pstrdup(result_pool, tmp_filename);
+
+  return SVN_NO_ERROR;
+}
+
 
 
 /*** Returning editors. ***/
@@ -4995,6 +5036,8 @@ make_editor(svn_revnum_t *target_revisio
   shim_callbacks->fetch_kind_baton = sfb;
   shim_callbacks->fetch_props_func = svn_wc__fetch_props_func;
   shim_callbacks->fetch_props_baton = sfb;
+  shim_callbacks->fetch_base_func = fetch_base_func;
+  shim_callbacks->fetch_base_baton = eb;
 
   SVN_ERR(svn_editor__insert_shims(editor, edit_baton, *editor, *edit_baton,
                                    shim_callbacks, result_pool, scratch_pool));