The following is a partially tested patch which make the import
process drive the commit with post-fix text-deltas. That is, if you
apply this patch, instead of file additions being done like:
1. make file
2. send file contents to repos
3. close file
you will instead have steps 2 and 3 for the entire set of the new
files delayed until the end of the import.
This patch is NOT proposed Good Behavior, but exists for the purposes
of testing memory consumption differences between the post-fix and
inline text-delta drivers.
Index: ./subversion/libsvn_client/commit.c
===================================================================
--- ./subversion/libsvn_client/commit.c
+++ ./subversion/libsvn_client/commit.c Thu Mar 7 11:56:06 2002
@@ -97,32 +97,33 @@
* Use POOL for any temporary allocation.
*/
static svn_error_t *
-import_file (const svn_delta_edit_fns_t *editor,
+import_file (apr_hash_t *committed_targets,
+ const svn_delta_edit_fns_t *editor,
void *dir_baton,
svn_stringbuf_t *path,
svn_stringbuf_t *name,
apr_pool_t *pool)
{
void *file_baton;
+ svn_stringbuf_t *full_path;
+ const char *mimetype;
SVN_ERR (editor->add_file (name, dir_baton,
NULL, SVN_INVALID_REVNUM,
&file_baton));
- SVN_ERR (send_file_contents (path, file_baton, editor, pool));
-
- /* Try to detect the mime-type of this new addition. */
- {
- const char *mimetype;
-
- SVN_ERR (svn_io_detect_mimetype (&mimetype, path->data, pool));
- if (mimetype)
- SVN_ERR (editor->change_file_prop
- (file_baton,
- svn_stringbuf_create (SVN_PROP_MIME_TYPE, pool),
- svn_stringbuf_create (mimetype, pool)));
- }
- SVN_ERR (editor->close_file (file_baton));
+ full_path = svn_stringbuf_dup (path, apr_hash_pool_get (committed_targets));
+
+ SVN_ERR (svn_io_detect_mimetype (&mimetype, full_path->data, pool));
+ if (mimetype)
+ SVN_ERR (editor->change_file_prop
+ (file_baton,
+ svn_stringbuf_create (SVN_PROP_MIME_TYPE, pool),
+ svn_stringbuf_create (mimetype, pool)));
+
+ apr_hash_set (committed_targets,
+ full_path->data, full_path->len,
+ (void *)file_baton);
return SVN_NO_ERROR;
}
@@ -135,7 +136,8 @@
* Use POOL for any temporary allocation.
*/
static svn_error_t *
-import_dir (const svn_delta_edit_fns_t *editor,
+import_dir (apr_hash_t *committed_targets,
+ const svn_delta_edit_fns_t *editor,
void *dir_baton,
svn_stringbuf_t *path,
apr_pool_t *pool)
@@ -190,12 +192,14 @@
&this_dir_baton));
/* Recurse. */
- SVN_ERR (import_dir (editor, this_dir_baton, new_path, subpool));
+ SVN_ERR (import_dir (committed_targets,
+ editor, this_dir_baton, new_path, subpool));
SVN_ERR (editor->close_directory (this_dir_baton));
}
else if (this_entry.filetype == APR_REG)
{
- SVN_ERR (import_file (editor, dir_baton, new_path, name, subpool));
+ SVN_ERR (import_file (committed_targets,
+ editor, dir_baton, new_path, name, subpool));
}
else
{
@@ -254,6 +258,8 @@
{
void *root_baton;
enum svn_node_kind kind;
+ apr_hash_t *committed_targets = apr_hash_make (pool);
+ apr_hash_index_t *hi;
/* Basic sanity check. */
if (new_entry && (strcmp (new_entry->data, "") == 0))
@@ -291,7 +297,8 @@
"new entry name required when importing a file");
}
- SVN_ERR (import_file (editor, root_baton, path, new_entry, pool));
+ SVN_ERR (import_file (committed_targets,
+ editor, root_baton, path, new_entry, pool));
}
else if (kind == svn_node_dir)
{
@@ -303,7 +310,7 @@
NULL, SVN_INVALID_REVNUM,
&new_dir_baton));
- SVN_ERR (import_dir (editor,
+ SVN_ERR (import_dir (committed_targets, editor,
new_dir_baton ? new_dir_baton : root_baton,
path,
pool));
@@ -311,13 +318,30 @@
/* Close one baton or two. */
if (new_dir_baton)
SVN_ERR (editor->close_directory (new_dir_baton));
- SVN_ERR (editor->close_directory (root_baton));
}
else if (kind == svn_node_none)
{
return svn_error_createf
(SVN_ERR_UNKNOWN_NODE_KIND, 0, NULL, pool,
"'%s' does not exist.", path->data);
+ }
+
+ SVN_ERR (editor->close_directory (root_baton));
+
+ /* Do post-fix textdeltas here! */
+ for (hi = apr_hash_first (pool, committed_targets);
+ hi;
+ hi = apr_hash_next (hi))
+ {
+ const void *key;
+ apr_ssize_t keylen;
+ void *file_baton;
+ svn_stringbuf_t *full_path;
+
+ apr_hash_this (hi, &key, &keylen, &file_baton);
+ full_path = svn_stringbuf_create ((char *) key, pool);
+ SVN_ERR (send_file_contents (full_path, file_baton, editor, pool));
+ SVN_ERR (editor->close_file (file_baton));
}
SVN_ERR (editor->close_edit (edit_baton));
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Mar 7 20:19:32 2002