git-remote-svn: Week 10
Hi,
After an extended weekend of hacking, I'm happy to report that I've finally managed to finish the SVN client (now renamed svndumpr) and validate it against 10,000 revisions of the ASF repository. It doesn't look like I can go much further with the validation until the dumpfilev3 parser is completed due to hardware limitations. However, Avar has been kind enough to lend me access to a more powerful machine on which I intend to run more tests over the next few days.
The last patch is a nice validation script; I would request everyone who's interested in the project to test it against their repositories so we can weed out any remaining bugs. The code is also available on my GitHub [1]. Also, please review the series thoroughly and don't hesitate to ask trivial questions: I'm new to developing with libsvn myself.
Please note that it has been built and tested only against the Subversion trunk: for Subversion 1.6, you can try using my ra-svn-1.6. Also, there seems to be some unresolved issue on 64-bit systems. We're working on fixing this.
Final note: I'll begin preparing to merge this into the Subversion trunk soon.
Thanks for reading.
[1]: ra-svn and ra-svn-rollout branches of
github.com/artagnon/svn-dump-fast-export
-- Ram
Ramkumar Ramachandra (13):
Add LICENSE
Add skeleton SVN client and Makefile
Add debug editor from Subversion trunk Add skeleton dump editor
Drive the debug editor
Dump the revprops at the start of every revision Implement open_root and close_edit Implement dump_node
Implement directory-related functions Implement file-related functions Implement apply_textdelta
Implement close_file
Add a validation script
PATCH 1/13 Add LICENSE
License the project under a two-clause BSD-style license. A dual license will be required later when attempting to merge into Subversion.
--- LICENSE | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) create mode 100644 LICENSE
LICENSE new file +26 -0
@@ -0,0 +1,26 @@ +Copyright (C) 2010 Ramkumar Ramachandra +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice(s), this list of conditions and the following disclaimer + unmodified other than the allowable addition of one or more + copyright notices. +2. Redistributions in binary form must reproduce the above copyright + notice(s), this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Signature · 1 line
1.7.1
PATCH 2/13 Add skeleton SVN client and Makefile
In reply to Ramkumar RamachandraAdd a basic SVN command-line client along with a Makefile that does just enough to establish a connection with the ASF subversion server; it initializes a memory pool, sees that configuration files are in order, builds up a context object, sets up an authentication baton, and finally opens a session to the subversion server.
--- Makefile | 8 +++++++ svndumpr.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 0 deletions(-) create mode 100644 Makefile create mode 100644 svndumpr.c
Makefile new file +8 -0
@@ -0,0 +1,8 @@ +svndumpr: *.c *.h + $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0 + +svndumpr_bench: *.c *.h + $(CC) -O2 -o $@ svndumpr.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0 + +clean: + $(RM) svndumpr svndumpr_bench
svndumpr.c new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [PATCH 02/13] Add skeleton SVN client and Makefile
Quoted 2 lines · Ramkumar Ramachandra
Add a basic SVN command-line client along with a
Makefilethat does just enough to establish a connection with the ASF subversion server;
Thanks for splitting this out.
Let’s see what’s needed to set up a connection:
Makefile line 2
Quoted 4 lines
+++ b/Makefile
Makefile new file +2
-0@@ -0,0 +1,8 @@ +svndumpr: *.c *.h + $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
Links against libsvnclient-1. Good.
I assume the details of the Makefile are not important, since it is probably going to be revamped in the style of the svn build system anyway.
Quoted 2 lines
(quoted diff) +1
-0+++ b/svndumpr.c@@ -0,0 +1,68 @@
[...]
Quoted 1 line
+svn_error_t
*populate_context()
[...]
Quoted 1 line
+svn_error_t *open_connection(const char *url)
[...]
Quoted 1 line
+svn_error_t *replay_range(svn_revnum_t
start_revision,svn_revnum_tend_revision)
Why not static?
svndumpr.c line 24
Quoted 10 lines
svndumpr.c new file +10
-0+svn_error_t *populate_context () +{ +const char *http_library; + +SVN_ERR (svn_config_get_config (&(ctx->config),NULL , pool)); + + http_library =getenv ("SVN_HTTP_LIBRARY" ); +if (http_library) +svn_config_set (apr_hash_get (ctx->config,"servers" ,APR_HASH_KEY_STRING ), +"global" ,"http-library" , http_library);
I tried googling for this SVN_HTTP_LIBRARY setting, but no useful hints. I take it that this overrides the [global] http-library setting from ~/.subversion/servers? Do other commands honor this environment variable or just svndumpr?
[...]
svndumpr.c line 37
Quoted 10 lines
svndumpr.c new file +10
-0+svn_error_t *open_connection (const char *url) +{ +SVN_ERR (svn_config_ensure (NULL , pool)); +SVN_ERR (svn_client_create_context (&ctx, pool)); +SVN_ERR (svn_ra_initialize (pool)); + +#if defined(WIN32 ) || defined(__CYGWIN__) +if (getenv ("SVN_ASP_DOT_NET_HACK" )) +SVN_ERR (svn_wc_set_adm_dir ("_svn" , pool)); +#endif
I guess it’s water under the bridge now (from 5 years ago), but why do clients have to do this themselves? It would not be so difficult for libsvnclient to automatically set the admin dir according to whether SVN_ASP_DOT_NET_HACK is set or not, or at least to provide a single function to call and do so.
But that is not the topic for the moment. I am tempted to suggest checking SVN_ASP_DOT_NET_HACK unconditionally (i.e., on Unix, too), just so the function is easier to scan. Or there could be a separate set_appropriate_adm_dir function in svndumpr.c:
#if defined(WIN32) || ...
static svn_error_t *set_appropriate_adm_dir(...)
{
if (getenv...
...
}
#else
static svn_error_t *set_appropriate_adm_dir(...
{
return SVN_NO_ERROR;
}
#endifFeel free to ignore me here. :)
svndumpr.c line 43
Quoted 6 lines
svndumpr.c new file +6
-0+ +SVN_ERR (populate_context ()); +SVN_ERR (svn_cmdline_create_auth_baton (&(ctx->auth_baton), TRUE, +NULL ,NULL ,NULL , FALSE, + FALSE,NULL ,NULL ,NULL , + pool));
Maybe comments would help, for the boolean arguments.
svndumpr.c line 51
Quoted 8 lines
svndumpr.c new file +8
-0+SVN_ERR (svn_client_open_ra_session (&session, url, ctx, pool)); +return SVN_NO_ERROR ; +} + +svn_error_t *replay_range (svn_revnum_t start_revision,svn_revnum_t end_revision) +{ +return SVN_NO_ERROR ; +}
Might be more self-explanatory without this function, but that is just nitpicking.
Quoted 7 lines
svndumpr.c new file +7
-0+ +int main () +{ +const char url[] ="http://svn.apache.org/repos/asf" ; +svn_revnum_t start_revision =1 , end_revision =500 ; +if (svn_cmdline_init ("svndumpr" , stderr) !=EXIT_SUCCESS ) +return 1 ;
svndumpr.c line 68
Quoted 10 lines
svndumpr.c new file +10
-0+ + pool =svn_pool_create (NULL ); + +SVN_INT_ERR (open_connection (url)); +SVN_INT_ERR (replay_range (start_revision, end_revision)); + +svn_pool_destroy (pool); + +return 0 ; +}
So: this is an expensive no-op.
Thanks for the pleasant reading.
Jonathan
Re: [PATCH 02/13] Add skeleton SVN client and Makefile
Hi Jonathan,
Quoted 6 lines · Jonathan Nieder
Quoted 2 lines · Ramkumar Ramachandra
Add a basic SVN command-line client along with a
Makefilethat does just enough to establish a connection with the ASF subversion server;Thanks for splitting this out.
Thanks for getting the review process started :)
Quoted 9 lines
Let’s see what’s needed to set up a connection:
Review line 2
Quoted 4 lines
+++ b/Makefile
(quoted diff) +2
-0@@ -0,0 +1,8 @@ +svndumpr: *.c *.h + $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0Links against libsvnclient-1. Good.
Quoted 3 lines
I assume the details of the
Makefileare not important, since it is probably going to be revamped in the style of the svn build system anyway.
Right.
Quoted 10 lines
Quoted 2 lines
(quoted diff) +1
-0+++ b/svndumpr.c@@ -0,0 +1,68 @@[...]
Quoted 1 line
+svn_error_t
*populate_context()[...]
Quoted 1 line
+svn_error_t *open_connection(const char *url)
[...]
Quoted 1 line
+svn_error_t *replay_range(svn_revnum_t
start_revision,svn_revnum_tend_revision)Why not static?
Changed (see end of email).
Quoted 7 lines
Quoted 7 lines
(quoted diff) +7
-0+svn_error_t *populate_context() +{ + const char *http_library; + + SVN_ERR(svn_config_get_config(&(ctx->config), NULL, pool)); + + http_library = getenv("SVN_HTTP_LIBRARY");
Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (http_library) + svn_config_set(apr_hash_get(ctx->config, "servers", APR_HASH_KEY_STRING), + "global", "http-library", http_library);I tried googling for this
SVN_HTTP_LIBRARYsetting, but no useful hints. I take it that this overrides the [global] http-library setting from ~/.subversion/servers? Do other commands honor this environment variable or just svndumpr?
I originally had this to switch between neon and serf libraries. It seems that this is no more necessary.
Quoted 17 lines
[...]
Review
Quoted 10 lines
(quoted diff) +10
-0+svn_error_t *open_connection(const char *url) +{ + SVN_ERR(svn_config_ensure (NULL, pool)); + SVN_ERR(svn_client_create_context (&ctx, pool)); + SVN_ERR(svn_ra_initialize(pool)); + +#if defined(WIN32) || defined(__CYGWIN__) + if (getenv("SVN_ASP_DOT_NET_HACK")) + SVN_ERR(svn_wc_set_adm_dir("_svn", pool)); +#endifI guess it’s water under the bridge now (from 5 years ago), but why do clients have to do this themselves? It would not be so difficult for libsvnclient to automatically set the admin dir according to whether
SVN_ASP_DOT_NET_HACKis set or not, or at least to provide a single function to call and do so.
Good question. I copied this out from some legacy code in the Subversion trunk. Additionally, since I don't have a working copy, this is completely unnecessary. Removed now.
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ + SVN_ERR(populate_context()); + SVN_ERR(svn_cmdline_create_auth_baton(&(ctx->auth_baton), TRUE, + NULL, NULL, NULL, FALSE, + FALSE, NULL, NULL, NULL, + pool));Maybe comments would help, for the boolean arguments.
Fixed.
Quoted 11 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+ SVN_ERR(svn_client_open_ra_session(&session, url, ctx, pool)); + return SVN_NO_ERROR; +} + +svn_error_t *replay_range(svn_revnum_t start_revision, svn_revnum_t end_revision) +{ + return SVN_NO_ERROR; +}Might be more self-explanatory without this function, but that is just nitpicking.
I've filled in the function in a future patch. It's just to say that I'm "opening a connection and then calling replay_range, in that order". Yes, replay_range does nothing in this patch.
Quoted 11 lines
Quoted 11 lines
(quoted diff) +11
-0+ +int main() +{ + const char url[] = "http://svn.apache.org/repos/asf"; + svn_revnum_t start_revision = 1, end_revision = 500; + if (svn_cmdline_init ("svndumpr", stderr) != EXIT_SUCCESS) + return 1; + + pool = svn_pool_create(NULL); + + SVN_INT_ERR(open_connection(url));
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ SVN_INT_ERR(replay_range(start_revision, end_revision)); + + svn_pool_destroy(pool); + + return 0; +}So: this is an expensive no-op.
Exactly. I built up the patches so that at every stage, the program compiles and runs fine, implementing part of full functionality.
Here's a diff of the modifications I made after your review:
svndumpr.c +8 -20
@@ -76,31 +76,19 @@ static svn_error_t *replay_revend(svn_revnum_t revision,return SVN_NO_ERROR ; } -svn_error_t *populate_context () -{ -const char *http_library; - -SVN_ERR (svn_config_get_config (&(ctx->config),NULL , pool)); - - http_library =getenv ("SVN_HTTP_LIBRARY" ); -if (http_library) -svn_config_set (apr_hash_get (ctx->config,"servers" ,APR_HASH_KEY_STRING ), -"global" ,"http-library" , http_library); -return SVN_NO_ERROR ; -} - -svn_error_t *open_connection (const char *url) +static svn_error_t *open_connection (const char *url) {SVN_ERR (svn_config_ensure (NULL , pool));SVN_ERR (svn_client_create_context (&ctx, pool));SVN_ERR (svn_ra_initialize (pool)); -#if defined(WIN32 ) || defined(__CYGWIN__) -if (getenv ("SVN_ASP_DOT_NET_HACK" )) -SVN_ERR (svn_wc_set_adm_dir ("_svn" , pool)); -#endif +SVN_ERR (svn_config_get_config (&(ctx->config),NULL , pool)); -SVN_ERR (populate_context ()); +/* Populte ctx->auth_baton with the auth baton +non-interactively. Arguments 3, 4 and 5 are for username, +password and config_dir which is NULL in this case. Set +no_auth_cache and trust_serv_cert to FALSE, don't provide a +config, and omit cancel_func/ cancel_baton */ SVN_ERR(svn_cmdline_create_auth_baton(&(ctx->auth_baton), TRUE, NULL, NULL, NULL, FALSE, FALSE, NULL, NULL, NULL,
@@ -109,7 +97,7 @@ svn_error_t *open_connection(const char *url)return SVN_NO_ERROR ; } -svn_error_t *replay_range (svn_revnum_t start_revision,svn_revnum_t end_revision) +static svn_error_t *replay_range (svn_revnum_t start_revision,svn_revnum_t end_revision) {const svn_delta_editor_t *dump_editor, *debug_editor;void *debug_baton, *dump_baton;
-- Ram
Jonathan Nieder
Reviewed-byRe: [PATCH 02/13] Add skeleton SVN client and Makefile
Quoted 1 line · Ramkumar Ramachandra
Here's a diff of the modifications I made after your review:
That’s quite helpful.
Quoted 2 lines
+++
b/svndumpr.c(quoted diff) +0
-0@@ -76,31 +76,19 @@ static svn_error_t *replay_revend(svn_revnum_t revision,
[...]
svndumpr.c static svn_error_t *replay_revend(svn_revnum_t revision, · line 94
Quoted 8 lines
svndumpr.c +5
-0+/* Populte ctx->auth_baton with the auth baton +non-interactively. Arguments 3, 4 and 5 are for username, +password and config_dir which is NULL in this case. Set +no_auth_cache and trust_serv_cert to FALSE, don't provide a +config, and omit cancel_func/ cancel_baton */ SVN_ERR(svn_cmdline_create_auth_baton(&(ctx->auth_baton), TRUE, NULL, NULL, NULL, FALSE, FALSE, NULL, NULL, NULL,
I think you took my suggestion too seriously here. Such a comment probably will not help people much; instead, maybe a more focused comment can help the curious avoid looking up svn_cmdline_create_auth_baton:
/* Default authentication providers for noninteractive use. */ SVN_ERR(svn_cmdline_create_auth_baton(...
Looking this up, I notice that function was added in svn 1.6. Hopefully that is okay, since this code is destined for svn trunk.
Except as noted above,
Thanks.
Re: [PATCH 02/13] Add skeleton SVN client and Makefile
Hi,
Quoted 23 lines · Jonathan Nieder
Quoted 1 line · Ramkumar Ramachandra
Here's a diff of the modifications I made after your review:
That’s quite helpful.
Quoted 2 lines
+++
b/svndumpr.c(quoted diff) +0
-0@@ -76,31 +76,19 @@ static svn_error_t *replay_revend(svn_revnum_t revision,[...]
svndumpr.c static svn_error_t *replay_revend(svn_revnum_t revision, · line 94
Quoted 8 lines
svndumpr.c +5
-0+/* Populte ctx->auth_baton with the auth baton +non-interactively. Arguments 3, 4 and 5 are for username, +password and config_dir which is NULL in this case. Set +no_auth_cache and trust_serv_cert to FALSE, don't provide a +config, and omit cancel_func/ cancel_baton */ SVN_ERR(svn_cmdline_create_auth_baton(&(ctx->auth_baton), TRUE, NULL, NULL, NULL, FALSE, FALSE, NULL, NULL, NULL,I think you took my suggestion too seriously here. Such a comment probably will not help people much; instead, maybe a more focused comment can help the curious avoid looking up
svn_cmdline_create_auth_baton:
Quoted 3 lines
/* Default authentication providers for noninteractive use. */ SVN_ERR(svn_cmdline_create_auth_baton(...
Fixed.
Quoted 2 lines
Looking this up, I notice that function was added in svn 1.6. Hopefully that is okay, since this code is destined for svn trunk.
I have a working 1.6 fork now that I intend to merge into git.git. When there's a new release of Subversion that includes my patch, I'll remove it from git.git.
Quoted 1 line
Reviewed-by Jonathan Nieder <[email protected]>
Thanks.
-- Ram
Re: [PATCH 02/13] Add skeleton SVN client and Makefile
In reply to Jonathan NiederJonathan Nieder wrote on Wed, 7 Jul 2010 at 11:25 -0500:
Quoted 16 lines
svndumpr.c line 24
Quoted 10 lines · Ramkumar Ramachandra
svndumpr.c new file +10
-0+svn_error_t *populate_context () +{ +const char *http_library; + +SVN_ERR (svn_config_get_config (&(ctx->config),NULL , pool)); + + http_library =getenv ("SVN_HTTP_LIBRARY" ); +if (http_library) +svn_config_set (apr_hash_get (ctx->config,"servers" ,APR_HASH_KEY_STRING ), +"global" ,"http-library" , http_library);I tried googling for this
SVN_HTTP_LIBRARYsetting, but no useful hints. I take it that this overrides the [global] http-library setting from ~/.subversion/servers? Do other commands honor this environment variable or just svndumpr?
Other commands use --config-option. SVN_HTTP_LIBRARY is not recognized by any released Subversion, nor by trunk@HEAD of Subversion.
It's a debugging relic, anyway. Can be removed. The functionality is provided by editing $CONFIG_DIR/servers.
PATCH 3/13 Add debug editor from Subversion trunk
In reply to Ramkumar RamachandraAdd the debug editor from subversion/libsvn_delta/debug_editor.c along with a header to expose the svn_delta__get_debug_editor function.
--- Makefile | 4 +- debug_editor.c | 402 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ debug_editor.h | 10 ++ 3 files changed, 414 insertions(+), 2 deletions(-) create mode 100644 debug_editor.c create mode 100644 debug_editor.h
Makefile +2 -2
@@ -1,8 +1,8 @@ svndumpr: *.c *.h - $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0 + $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c debug_editor.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 svndumpr_bench: *.c *.h - $(CC) -O2 -o $@ svndumpr.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0 + $(CC) -O2 -o $@ svndumpr.c debug_editor.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 clean: $(RM) svndumpr svndumpr_bench
debug_editor.c new file +402 -0
402 lines not on this page · raw message
debug_editor.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef DEBUG_EDITOR_H_ +#define DEBUG_EDITOR_H_ + +svn_error_t *svn_delta__get_debug_editor (const svn_delta_editor_t **editor, +void **edit_baton, +const svn_delta_editor_t *wrapped_editor, +void *wrapped_edit_baton, +apr_pool_t *pool); + +#endif
Signature · 1 line
1.7.1
Re: [PATCH 03/13] Add debug editor from Subversion trunk
Hi again,
Quoted 2 lines · Ramkumar Ramachandra
Add the debug editor from
subversion/libsvn_delta/debug_editor.calong with a header to expose thesvn_delta__get_debug_editorfunction.
The description does not tell what the debug editor is for. Is it for tracing?
In what follows, I am going to pretend this is all new code, since for someone unfamiliar to svn like me, that is easier than reviewing the differences. Upshot: you can probably ignore most of what I say. :)
debug_editor.c line 3
Quoted 5 lines
+++
b/debug_editor.cdebug_editor.c new file +3
-0@@ -0,0 +1,402 @@ +/* Licensed under a two-clause BSD-style license. +* See LICENSE for details. +*/
Is this true?
Quoted 7 lines
debug_editor.c new file +7
-0+ +#include "svn_pools.h" +#include "svn_cmdline.h" +#include "svn_client.h" +#include "svn_ra.h" + +#include "debug_editor.h"
debug_editor.c line 20
Quoted 10 lines
debug_editor.c new file +10
-0+ +struct edit_baton +{ +const svn_delta_editor_t *wrapped_editor; +void *wrapped_edit_baton; + +int indent_level; + +svn_stream_t *out; +};
This object represents context while describing changes in a revision. The indent_level gets incremented whenever we move to a subdirectory, wrapped_editor is a set of callbacks to actually do something with the changes, wrapped_edit_baton its state cookie, and out a stream to write the debugging information to.
debug_editor.c line 26
Quoted 6 lines
debug_editor.c new file +6
-0+ +struct dir_baton +{ +void *edit_baton; +void *wrapped_dir_baton; +};
Context when traversing a directory.
Maybe the debugger’s state should be consistently before or consistently after the wrapped state. But this is just nitpicking.
Another nitpick: Is the prevailing style in subversion to use void * for related context objects like edit_baton? If not, I would suggest using struct edit_baton * to document that that is always its type; but if so, nothing to see here, please carry on.
debug_editor.c line 32
Quoted 5 lines
debug_editor.c new file +5
-0+struct file_baton +{ +void *edit_baton; +void *wrapped_file_baton; +};
Similar.
[...]
Quoted 4 lines
debug_editor.c new file +4
-0+static svn_error_t *set_target_revision (void *edit_baton, +svn_revnum_t target_revision, +apr_pool_t *pool) +{
debug_editor.c line 57
Quoted 10 lines
debug_editor.c new file +10
-0+struct edit_baton *eb = edit_baton; + +SVN_ERR (write_indent (eb, pool)); +SVN_ERR (svn_stream_printf (eb->out, pool,"set_target_revision : %ld\n" , + target_revision)); + +return eb->wrapped_editor->set_target_revision (eb->wrapped_edit_baton, + target_revision, + pool); +}
This is unfortunately long for how little it does.
C question (I’m just curious): would it be allowed to use
static svn_Error_t *set_target_revision(struct edit_baton *eb,
etc
In other words, does C allow a function with struct foo * argument to be called through a pointer to function with void * argument?
Quoted 15 lines
debug_editor.c new file +15
-0+ +static svn_error_t *open_root (void *edit_baton, +svn_revnum_t base_revision, +apr_pool_t *pool, +void **root_baton) +{ +struct edit_baton *eb = edit_baton; +struct dir_baton *dir_baton =apr_palloc (pool,sizeof (*dir_baton)); + +SVN_ERR (write_indent (eb, pool)); +SVN_ERR (svn_stream_printf (eb->out, pool,"open_root : %ld\n" , + base_revision)); + eb->indent_level++; + + SVN_ERR(eb->wrapped_editor->open_root(eb->wrapped_edit_baton,
debug_editor.c line 82
Quoted 10 lines
debug_editor.c new file +10
-0+ base_revision, + pool, + &dir_baton->wrapped_dir_baton)); + + dir_baton->edit_baton = edit_baton; + + *root_baton = dir_baton; + +return SVN_NO_ERROR ; +}
Similar. Maybe:
static svn_error_t *open_root(...
{
struct edit_baton *eb = edit_baton;
struct dir_baton *dir_baton;
SVN_ERR(write_indent...
SVN_ERR(svn_stream_printf...
dir_baton = apr_palloc(...
dir_baton->edit_baton = eb;
SVN_ERR(eb->wrapped_editor->open_root(...
*root_baton = dir_baton;
eb->indent_level++;
return SVN_NO_ERROR;
}[...]
Quoted 1 line
+static
svn_error_t*add_directory(const char *path,
[...]
Quoted 1 line
+static
svn_error_t*open_directory(const char *path,
[...]
Quoted 1 line
+static
svn_error_t*add_file(const char *path,
[...]
Quoted 1 line
+static
svn_error_t*open_file(const char *path,
Similar.
Quoted 8 lines
debug_editor.c new file +8
-0+static svn_error_t *close_file (void *file_baton, +const char *text_checksum, +apr_pool_t *pool) +{ +struct file_baton *fb = file_baton; +struct edit_baton *eb = fb->edit_baton; + + eb->indent_level--;
debug_editor.c line 257
Quoted 10 lines
debug_editor.c new file +10
-0+ +SVN_ERR (write_indent (eb, pool)); +SVN_ERR (svn_stream_printf (eb->out, pool,"close_file : %s\n" , + text_checksum)); + +SVN_ERR (eb->wrapped_editor->close_file (fb->wrapped_file_baton, + text_checksum, pool)); + +return SVN_NO_ERROR ; +}
The context pointers for each file and directory in each revision are collected in a single pool and not freed, well, ever. I assume that is not a problem in practice; if it is, one can always start making subpools later.
Quoted 4 lines
debug_editor.c new file +4
-0+svn_error_t *svn_delta__get_debug_editor(const svn_delta_editor_t **editor, + void **edit_baton, + const svn_delta_editor_t *wrapped_editor, + void *wrapped_edit_baton,
debug_editor.c line 373
Quoted 10 lines
debug_editor.c new file +10
-0+ apr_pool_t *pool) +{ +svn_delta_editor_t *tree_editor =svn_delta_default_editor (pool); +struct edit_baton *eb =apr_palloc (pool,sizeof (*eb)); +apr_file_t *errfp; +svn_stream_t *out; + +apr_status_t apr_err =apr_file_open_stderr (&errfp, pool); +if (apr_err) +return svn_error_wrap_apr (apr_err,"Problem opening stderr" );
Is there no function for this that returns svn_error_t *?
[...]
debug_editor.h line 8
Quoted 10 lines
+++
b/debug_editor.hdebug_editor.h new file +8
-0@@ -0,0 +1,10 @@ +#ifndef DEBUG_EDITOR_H_ +#define DEBUG_EDITOR_H_ + +svn_error_t *svn_delta__get_debug_editor (const svn_delta_editor_t **editor, +void **edit_baton, +const svn_delta_editor_t *wrapped_editor, +void *wrapped_edit_baton, +apr_pool_t *pool);
Usable from other code. Caller provides the pool. No example user yet.
Well, it looks like it should work. :)
PATCH 4/13 Add skeleton dump editor
In reply to Ramkumar RamachandraAdd a dump editor and write out skeleton callback functions according to the API documentation of svn_delta_editor_t. Also expose get_dump_editor through a header.
--- Makefile | 4 +- dump_editor.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dump_editor.h | 8 +++ dumpr_util.h | 29 ++++++++++++ 4 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 dump_editor.c create mode 100644 dump_editor.h create mode 100644 dumpr_util.h
Makefile +2 -2
@@ -1,8 +1,8 @@ svndumpr: *.c *.h - $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c debug_editor.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 + $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c debug_editor.c dump_editor.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 svndumpr_bench: *.c *.h - $(CC) -O2 -o $@ svndumpr.c debug_editor.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 + $(CC) -O2 -o $@ svndumpr.c debug_editor.c dump_editor.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 clean: $(RM) svndumpr svndumpr_bench
dump_editor.c new file +143 -0
143 lines not on this page · raw message
dump_editor.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef DUMP_EDITOR_H_ +#define DUMP_EDITOR_H_ + +svn_error_t *get_dump_editor (const svn_delta_editor_t **editor, +void **edit_baton, +svn_revnum_t to_rev, +apr_pool_t *pool); +#endif
dumpr_util.h new file +29 -0
@@ -0,0 +1,29 @@ +#ifndef DUMPR_UTIL_H_ +#define DUMPR_UTIL_H_ + +struct edit_baton { +/* The stream to dump to: stdout */ +svn_stream_t *stream; + +/* pool is for per-edit-session allocations */ +apr_pool_t *pool; + +svn_revnum_t current_rev; + +/* Store the properties that changed */ +apr_hash_t *properties; +apr_hash_t *del_properties;/* Value is always 0x1 */ +svn_stringbuf_t *propstring; + +/* Path of changed file */ +const char *changed_path; + +/* Was a copy command issued? */ +svn_boolean_t is_copy; + +/* Temporary file to write delta to along with its checksum */ +char *temp_filepath; +svn_checksum_t *checksum; +}; + +#endif
Signature · 1 line
1.7.1
Re: [PATCH 04/13] Add skeleton dump editor
Quoted 3 lines · Ramkumar Ramachandra
Add a dump editor and write out skeleton callback functions according to the API documentation of
svn_delta_editor_t. Also exposeget_dump_editorthrough a header.
This commit message tells me nothing... Maybe:
Add a no-op svn_editor. The function to retrieve it is called get_dump_editor because it is planned to tweak it to write a dumpfile. But for now it is more useful when used with the debug_editor, to get a list of editor operations printed to stderr.
It could make sense to squash this with patch 5 as a demo.
Quoted 7 lines
dump_editor.c new file +4
-0@@ -0,0 +1,143 @@ +/* Licensed under a two-clause BSD-style license. +* See LICENSE for details. +*/ +
dump_editor.c line 14
Quoted 10 lines
dump_editor.c new file +10
-0+#include "svn_pools.h" +#include "svn_error.h" +#include "svn_iter.h" +#include "svn_repos.h" +#include "svn_string.h" +#include "svn_dirent_uri.h" +#include "svn_path.h" +#include "svn_time.h" +#include "svn_checksum.h" +#include "svn_props.h"
Are these all needed?
[...]
dump_editor.c line 24
Quoted 7 lines
dump_editor.c new file +7
-0+svn_error_t *open_root (void *edit_baton, +svn_revnum_t base_revision, +apr_pool_t *pool, +void **root_baton) +{ +return SVN_NO_ERROR ; +}
Might make sense to use
*root_baton = NULL;
for easier debugging.
[...]
Quoted 1 line
dump_editor.c new file +1
-0+svn_error_t *add_directory(const char *path,
[...]
Quoted 1 line
+svn_error_t *open_directory(const char *path,
[...]
Quoted 1 line
+svn_error_t *add_file(const char *path,
[...]
Quoted 1 line
+svn_error_t *open_file(const char *path,
[...]
Quoted 1 line
+svn_error_t *apply_textdelta(void
*file_baton, const char*base_checksum,
Likewise.
[...]
dump_editor.c line 4
Quoted 6 lines
+++
b/dumpr_util.hdump_editor.c new file +4
-0@@ -0,0 +1,29 @@ +#ifndef DUMPR_UTIL_H_ +#define DUMPR_UTIL_H_ + +struct edit_baton {
A more specific name might be nice (or might not, depending on the prevailing style in svn; I ought to check but I am too lazy).
dump_editor.c line 9
Quoted 5 lines
dump_editor.c new file +5
-0+/* The stream to dump to: stdout */ +svn_stream_t *stream; + +/* pool is for per-edit-session allocations */ +apr_pool_t *pool;
Unused; probably should delay adding these until there is a user to explain them.
dump_editor.c line 11
Quoted 2 lines
dump_editor.c new file +2
-0+ +svn_revnum_t current_rev;
Used.
Quoted 5 lines
dump_editor.c new file +5
-0+ +/* Store the properties that changed */ +apr_hash_t *properties; +apr_hash_t *del_properties;/* Value is always 0x1 */ +svn_stringbuf_t *propstring;
dump_editor.c line 26
Quoted 10 lines
dump_editor.c new file +10
-0+ +/* Path of changed file */ +const char *changed_path; + +/* Was a copy command issued? */ +svn_boolean_t is_copy; + +/* Temporary file to write delta to along with its checksum */ +char *temp_filepath; +svn_checksum_t *checksum;
All unused.
Quoted 1 line
dump_editor.c new file +1
-0+};
Re: [PATCH 04/13] Add skeleton dump editor
Hi,
Quoted 6 lines · Jonathan Nieder
Quoted 3 lines · Ramkumar Ramachandra
Add a dump editor and write out skeleton callback functions according to the API documentation of
svn_delta_editor_t. Also exposeget_dump_editorthrough a header.
Quoted 7 lines
This commit message tells me nothing... Maybe:
Add a no-op
svn_editor. The function to retrieve it is calledget_dump_editorbecause it is planned to tweak it to write a dumpfile. But for now it is more useful when used with thedebug_editor, to get a list of editor operations printed to stderr.
Fixed.
Quoted 1 line
It could make sense to squash this with patch 5 as a demo.
Hm, I'm not too competent with handling lots of conflicts during an interactive rebase: I'll try this out in a new branch and let you know how it went.
Quoted 11 lines
Quoted 11 lines
dump_editor.c new file +8
-0@@ -0,0 +1,143 @@ +/* Licensed under a two-clause BSD-style license. +* See LICENSE for details. +*/ + +#include "svn_pools.h" +#include "svn_error.h" +#include "svn_iter.h" +#include "svn_repos.h"
Quoted 8 lines
dump_editor.c line 14
Quoted 6 lines
dump_editor.c new file +6
-0+#include "svn_string.h" +#include "svn_dirent_uri.h" +#include "svn_path.h" +#include "svn_time.h" +#include "svn_checksum.h" +#include "svn_props.h" Are these all needed?
I figured that adding some implies adding some others. Fixed.
Quoted 19 lines
[...]
dump_editor.c
Quoted 7 lines
dump_editor.c new file +7
-0+svn_error_t *open_root (void *edit_baton, +svn_revnum_t base_revision, +apr_pool_t *pool, +void **root_baton) +{ +return SVN_NO_ERROR ; +}Might make sense to use
*root_baton = NULL;for easier debugging.
[...]
Quoted 1 line
+svn_error_t *add_directory(const char *path,
[...]
Quoted 1 line
+svn_error_t *open_directory(const char *path,
Quoted 8 lines
[...]
Quoted 1 line
+svn_error_t *add_file(const char *path,
[...]
Quoted 1 line
+svn_error_t *open_file(const char *path,
[...]
Quoted 1 line
+svn_error_t *apply_textdelta(void
*file_baton, const char*base_checksum,Likewise.
Fixed. Excellent suggestion.
Quoted 34 lines
[...]
dump_editor.c line 4
Quoted 6 lines
+++
b/dumpr_util.hdump_editor.c new file +4
-0@@ -0,0 +1,29 @@ +#ifndef DUMPR_UTIL_H_ +#define DUMPR_UTIL_H_ + +struct edit_baton {A more specific name might be nice (or might not, depending on the prevailing style in svn; I ought to check but I am too lazy).
dump_editor.c line 9
Quoted 5 lines
dump_editor.c new file +5
-0+/* The stream to dump to: stdout */ +svn_stream_t *stream; + +/* pool is for per-edit-session allocations */ +apr_pool_t *pool;Unused; probably should delay adding these until there is a user to explain them.
dump_editor.c line 11
Quoted 2 lines
dump_editor.c new file +2
-0+ +svn_revnum_t current_rev;Used.
Quoted 9 lines
dump_editor.c new file +9
-0+ +/* Store the properties that changed */ +apr_hash_t *properties; +apr_hash_t *del_properties;/* Value is always 0x1 */ +svn_stringbuf_t *propstring; + +/* Path of changed file */ +const char *changed_path; +
Quoted 10 lines
dump_editor.c line 26
Quoted 6 lines
dump_editor.c new file +6
-0+/* Was a copy command issued? */ +svn_boolean_t is_copy; + +/* Temporary file to write delta to along with its checksum */ +char *temp_filepath; +svn_checksum_t *checksum;All unused.
Quoted 1 line
dump_editor.c new file +1
-0+};
Here's the diff after your review. It took me quite a long time to get the interactive rebase right.
Add skeleton dump editor
Add a no-op svn_editor and expose the function get_dump_editor; this dump editor will later be filled in to write the dumpfile. Currently, it is more useful to wrap it in the debug_editor to get a list of editor operations printed to stderr.
dump_editor.c +7 -6
@@ -3,14 +3,8 @@*/ #include "svn_pools.h" -#include "svn_error.h" -#include "svn_iter.h" #include "svn_repos.h" -#include "svn_string.h" -#include "svn_dirent_uri.h" #include "svn_path.h" -#include "svn_time.h" -#include "svn_checksum.h" #include "svn_props.h" #include "dumpr_util.h"
@@ -20,6 +14,7 @@ svn_error_t *open_root(void *edit_baton, apr_pool_t *pool, void **root_baton) { + *root_baton =NULL ;return SVN_NO_ERROR ; }
@@ -38,6 +33,7 @@ svn_error_t *add_directory(const char *path, apr_pool_t *pool, void **child_baton) { + *child_baton =NULL ;return SVN_NO_ERROR ; }
@@ -47,6 +43,7 @@ svn_error_t *open_directory(const char *path, apr_pool_t *pool, void **child_baton) { + *child_baton =NULL ;return SVN_NO_ERROR ; }
@@ -63,6 +60,7 @@ svn_error_t *add_file(const char *path, apr_pool_t *pool, void **file_baton) { + *file_baton =NULL ;return SVN_NO_ERROR ; }
@@ -72,6 +70,7 @@ svn_error_t *open_file(const char *path, apr_pool_t *pool, void **file_baton) { + *file_baton =NULL ;return SVN_NO_ERROR ; }
@@ -96,6 +95,8 @@ svn_error_t *apply_textdelta(void *file_baton, const char *base_checksum, svn_txdelta_window_handler_t *handler, void **handler_baton) { + *handler = svn_delta_noop_window_handler; + *handler_baton =NULL ;return SVN_NO_ERROR ; }
dumpr_util.h +0 -20
@@ -2,28 +2,8 @@#define DUMPR_UTIL_H_ struct edit_baton { -/* The stream to dump to: stdout */ svn_stream_t *stream; - -/* pool is for per-edit-session allocations */ -apr_pool_t *pool; -svn_revnum_t current_rev; - -/* Store the properties that changed */ -apr_hash_t *properties; -apr_hash_t *del_properties;/* Value is always 0x1 */ -svn_stringbuf_t *propstring; - -/* Path of changed file */ -const char *changed_path; - -/* Was a copy command issued? */ -svn_boolean_t is_copy; - -/* Temporary file to write delta to along with its checksum */ -char *temp_filepath; -svn_checksum_t *checksum; };#endif
PATCH 5/13 Drive the debug editor
In reply to Ramkumar RamachandraWrap the dummy dump editor in the debug editor and drive the debug editor to print out all the actions that occur during the replay to stderr.
--- dump_editor.c | 2 +- dumpr_util.h | 5 +++++ svndumpr.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletions(-)
dump_editor.c +1 -1
@@ -128,7 +128,7 @@ svn_error_t *get_dump_editor(const svn_delta_editor_t **editor, de->close_directory = close_directory; de->change_dir_prop = change_dir_prop; de->change_file_prop = change_file_prop; - de->apply_textdelta = apply_textdelta; +/* de->apply_textdelta = apply_textdelta; */ de->add_file = add_file; de->open_file = open_file; de->close_file = close_file;
dumpr_util.h +5 -0
@@ -1,6 +1,11 @@ #ifndef DUMPR_UTIL_H_ #define DUMPR_UTIL_H_ +struct replay_baton { + const svn_delta_editor_t *editor; + void *baton; +}; + struct edit_baton { /* The stream to dump to: stdout */ svn_stream_t *stream;
svndumpr.c +49 -0
65 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [PATCH 05/13] Drive the debug editor
dump_editor.c svn_error_t *get_dump_editor(const svn_delta_editor_t **editor, · line 131
Quoted 7 lines · Ramkumar Ramachandra
+++
b/dump_editor.cdump_editor.c +1
-1@@ -128,7 +128,7 @@ svn_error_t *get_dump_editor(const svn_delta_editor_t **editor, de->close_directory = close_directory; de->change_dir_prop = change_dir_prop; de->change_file_prop = change_file_prop; - de->apply_textdelta = apply_textdelta; +/* de->apply_textdelta = apply_textdelta; */
Hmm...
[...]
dumpr_util.h line 8
Quoted 10 lines
dumpr_util.h +6
-0+++ b/dumpr_util.h@@ -1,6 +1,11 @@#ifndef DUMPR_UTIL_H_ #define DUMPR_UTIL_H_ +struct replay_baton { +const svn_delta_editor_t *editor; +void *baton; +}; +
Context during svnsync-like replay ops:
- a diff replayer
- its context object
Maybe "void *edit_baton" would be clearer.
dumpr_util.h line 9
Quoted 1 line
dumpr_util.h +0
-0struct edit_baton {
Which might involve renaming this to dump_edit_baton to avoid confusion.
Quoted 2 lines
(quoted diff) +1
-0+++ b/svndumpr.c@@ -8,10 +8,40 @@
[...]
svndumpr.c line 24
Quoted 6 lines
svndumpr.c +6
-0+static svn_error_t *replay_revstart (svn_revnum_t revision, +void *replay_baton, +const svn_delta_editor_t **editor, +void **edit_baton, +apr_hash_t *rev_props, +apr_pool_t *pool)
This function is called to acquire an editor to replay one revision.
svndumpr.c line 27
Quoted 3 lines
svndumpr.c +3
-0+{ +/* Extract editor and editor_baton from the replay_baton and +set them so that the editor callbacks can use them */
This comment just paraphrases the code. What in particular requires explanation here?
Quoted 6 lines
svndumpr.c +6
-0+struct replay_baton *rb = replay_baton; + *editor = rb->editor; + *edit_baton = rb->baton; + +return SVN_NO_ERROR ; +}
[...]
Quoted 4 lines
svndumpr.c +0
-0@@ -47,6 +77,25 @@ svn_error_t *open_connection(const char *url)svn_error_t *replay_range (svn_revnum_t start_revision,svn_revnum_t end_revision) {
[...]
svndumpr.c svn_error_t *open_connection(const char *url) · line 95
Quoted 2 lines
svndumpr.c +2
-0+SVN_ERR (svn_cmdline_printf (pool,SVN_REPOS_DUMPFILE_MAGIC_HEADER ": %d\n" , +SVN_REPOS_DUMPFILE_FORMAT_VERSION ));
Did this sneak in from a later patch?
svndumpr.c svn_error_t *open_connection(const char *url) · line 98
Quoted 3 lines
svndumpr.c +3
-0+SVN_ERR (svn_ra_replay_range (session, start_revision, end_revision, +0 , TRUE, replay_revstart, replay_revend, + replay_baton, pool));
Makes sense.
Re: [PATCH 05/13] Drive the debug editor
Hi Jonathan,
Quoted 11 lines · Jonathan Nieder
dump_editor.c svn_error_t *get_dump_editor(const svn_delta_editor_t **editor, · line 131
Quoted 7 lines · Ramkumar Ramachandra
+++
b/dump_editor.cdump_editor.c +1
-1@@ -128,7 +128,7 @@ svn_error_t *get_dump_editor(const svn_delta_editor_t **editor, de->close_directory = close_directory; de->change_dir_prop = change_dir_prop; de->change_file_prop = change_file_prop; - de->apply_textdelta = apply_textdelta; +/* de->apply_textdelta = apply_textdelta; */ Hmm...
Without this, the program segfaults because the necessary setup for applying a text delta hasn't been set up. Perhaps I should explain this in my commit message?
Quoted 17 lines
[...]
dumpr_util.h line 8
Quoted 10 lines
+++
b/dumpr_util.hdumpr_util.h +5
-0@@ -1,6 +1,11 @@#ifndef DUMPR_UTIL_H_ #define DUMPR_UTIL_H_ +struct replay_baton { +const svn_delta_editor_t *editor; +void *baton; +}; +Context during svnsync-like replay ops:
- a diff replayer
- its context object
Quoted 6 lines
Maybe "void
*edit_baton" would be clearer.dumpr_util.h line 9
Quoted 1 line
dumpr_util.h +0
-0struct edit_baton {Which might involve renaming this to
dump_edit_batonto avoid confusion.
Done. I renamed both.
Quoted 10 lines
Quoted 2 lines
(quoted diff) +1
-0+++ b/svndumpr.c@@ -8,10 +8,40 @@[...]
svndumpr.c line 24
Quoted 6 lines
svndumpr.c +6
-0+static svn_error_t *replay_revstart (svn_revnum_t revision, +void *replay_baton, +const svn_delta_editor_t **editor, +void **edit_baton, +apr_hash_t *rev_props, +apr_pool_t *pool)
Quoted 8 lines
This function is called to acquire an editor to replay one revision.
svndumpr.c line 27
Quoted 3 lines
svndumpr.c +3
-0+{ +/* Extract editor and editor_baton from the replay_baton and +set them so that the editor callbacks can use them */ This comment just paraphrases the code. What in particular requires explanation here?
This concept took me some time to wrap my head around: I had to stuff the replay_baton with the editor/ editor_baton so that I could set them for use in the callback functions. Comment moved to a later patch.
Quoted 10 lines
Quoted 6 lines
svndumpr.c +6
-0+struct replay_baton *rb = replay_baton; + *editor = rb->editor; + *edit_baton = rb->baton; + +return SVN_NO_ERROR ; +}[...]
Quoted 2 lines
(quoted diff) +0
-0@@ -47,6 +77,25 @@ svn_error_t *open_connection(const char *url)
Quoted 7 lines
Quoted 2 lines
svndumpr.c +0
-0svn_error_t *replay_range (svn_revnum_t start_revision,svn_revnum_t end_revision) {[...]
svndumpr.c svn_error_t *open_connection(const char *url) · line 95
Quoted 2 lines
svndumpr.c +2
-0+SVN_ERR (svn_cmdline_printf (pool,SVN_REPOS_DUMPFILE_MAGIC_HEADER ": %d\n" , +SVN_REPOS_DUMPFILE_FORMAT_VERSION ));Did this sneak in from a later patch?
Yes. Fixed now. I moved it this change to the next patch.
Quoted 5 lines
svndumpr.c svn_error_t *open_connection(const char *url) · line 98
Quoted 3 lines
svndumpr.c +3
-0+SVN_ERR (svn_ra_replay_range (session, start_revision, end_revision, +0 , TRUE, replay_revstart, replay_revend, + replay_baton, pool));Makes sense.
Thanks for the excellent review.
-- Ram
Re: [PATCH 05/13] Drive the debug editor
Quoted 5 lines · Ramkumar Ramachandra
Quoted 4 lines · Jonathan Nieder
Quoted 2 lines · Ramkumar Ramachandra
dump_editor.c +1
-1- de->apply_textdelta = apply_textdelta; +/* de->apply_textdelta = apply_textdelta; */
[...]
Quoted 3 lines
Without this, the program segfaults because the necessary setup for applying a text delta hasn't been set up. Perhaps I should explain this in my commit message?
Is the default apply_textdelta not a no-op? What work does it have to do, and can the skeleton editor be convinced to do the same in patch 4?
Quoted 10 lines
Quoted 6 lines
svndumpr.c line 27
Quoted 3 lines
svndumpr.c +3
-0+{ +/* Extract editor and editor_baton from the replay_baton and +set them so that the editor callbacks can use them */ This comment just paraphrases the code. What in particular requires explanation here?
This concept took me some time to wrap my head around: I had to stuff the
replay_batonwith the editor/editor_batonso that I could set them for use in the callback functions.
Ah, okay. Then I suppose it belongs in the commit message.
Alternatively: why does the tree editor have to persist between calls replaying the various revisions? That information could help the reader understand what is going on.
Re: [PATCH 05/13] Drive the debug editor
Quoted 7 lines · Jonathan Nieder
Quoted 5 lines · Ramkumar Ramachandra
Quoted 4 lines · Jonathan Nieder
Quoted 2 lines · Ramkumar Ramachandra
dump_editor.c +1
-1- de->apply_textdelta = apply_textdelta; +/* de->apply_textdelta = apply_textdelta; */ [...]
Quoted 6 lines
Quoted 3 lines
Without this, the program segfaults because the necessary setup for applying a text delta hasn't been set up. Perhaps I should explain this in my commit message?
Is the default
apply_textdeltanot a no-op? What work does it have to do, and can the skeleton editor be convinced to do the same in patch 4?
The default editor does this:
*handler = svn_delta_noop_window_handler;
*handler_baton = NULL;
return SVN_NO_ERROR;
Fixed.
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
svndumpr.c line 27
Quoted 3 lines
svndumpr.c +3
-0+{ +/* Extract editor and editor_baton from the replay_baton and +set them so that the editor callbacks can use them */ This comment just paraphrases the code. What in particular requires explanation here?
This concept took me some time to wrap my head around: I had to stuff the
replay_batonwith the editor/editor_batonso that I could set them for use in the callback functions.
Quoted 5 lines
Ah, okay. Then I suppose it belongs in the commit message.
Alternatively: why does the tree editor have to persist between calls replaying the various revisions? That information could help the reader understand what is going on.
Right. The editor_baton is the key item that's guaranteed to be passed around. Fixed.
-- Ram
PATCH 6/13 Dump the revprops at the start of every revision
In reply to Ramkumar RamachandraFill in replay_revstart to dump the revprops at the start of every revision. Add an additional write_hash_to_stringbuf helper function.
--- Makefile | 4 +- dumpr_util.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dumpr_util.h | 5 ++++ svndumpr.c | 38 ++++++++++++++++++++++++++++++++- 4 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 dumpr_util.c
Makefile +2 -2
@@ -1,8 +1,8 @@ svndumpr: *.c *.h - $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c debug_editor.c dump_editor.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 + $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c debug_editor.c dump_editor.c dumpr_util.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 svndumpr_bench: *.c *.h - $(CC) -O2 -o $@ svndumpr.c debug_editor.c dump_editor.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 + $(CC) -O2 -o $@ svndumpr.c debug_editor.c dump_editor.c dumpr_util.c -lsvn_client-1 -I. -I/usr/local/include/subversion-1 -I/usr/include/apr-1.0 clean: $(RM) svndumpr svndumpr_bench
dumpr_util.c new file +64 -0
64 lines not on this page · raw message
dumpr_util.h +5 -0
@@ -31,4 +31,9 @@ struct edit_baton { svn_checksum_t *checksum; }; +void write_hash_to_stringbuf (apr_hash_t *properties, +svn_boolean_t deleted, +svn_stringbuf_t **strbuf, +apr_pool_t *pool); +#endif
svndumpr.c +36 -2
@@ -23,6 +23,37 @@ static svn_error_t *replay_revstart(svn_revnum_t revision, apr_hash_t *rev_props, apr_pool_t *pool) { +/* Editing this revision has just started; dump the revprops +before invoking the editor callbacks */ +svn_stringbuf_t *propstring =svn_stringbuf_create ("" , pool); +svn_stream_t *stdout_stream; + +/* Create an stdout stream */ +svn_stream_for_stdout (&stdout_stream, pool); + +/* Print revision number and prepare the propstring */ +SVN_ERR (svn_stream_printf (stdout_stream, pool, +SVN_REPOS_DUMPFILE_REVISION_NUMBER +": %ld\n" , revision)); +write_hash_to_stringbuf (rev_props, FALSE, &propstring, pool); +svn_stringbuf_appendbytes (propstring,"PROPS-END\n" ,10 ); + +/* prop-content-length header */ +SVN_ERR (svn_stream_printf (stdout_stream, pool, +SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH +": %" APR_SIZE_T_FMT "\n" , propstring->len)); + +/* content-length header */ +SVN_ERR (svn_stream_printf (stdout_stream, pool, +SVN_REPOS_DUMPFILE_CONTENT_LENGTH +": %" APR_SIZE_T_FMT "\n\n" , propstring->len)); + +/* Print the revprops now */ +SVN_ERR (svn_stream_write (stdout_stream, propstring->data, + &(propstring->len))); + +svn_stream_close (stdout_stream); +/* Extract editor and editor_baton from the replay_baton and set them so that the editor callbacks can use them */ struct replay_baton *rb = replay_baton;
@@ -39,6 +70,9 @@ static svn_error_t *replay_revend(svn_revnum_t revision, apr_hash_t *rev_props, apr_pool_t *pool) { +/* Editor has finished for this revision and close_edit has +been called; do nothing: just continue to the next +revision */ return SVN_NO_ERROR ; }
@@ -89,8 +123,8 @@ svn_error_t *replay_range(svn_revnum_t start_revision, svn_revnum_t end_revision dump_baton, pool));struct replay_baton *replay_baton =apr_palloc (pool,sizeof (struct replay_baton )); - replay_baton->editor = debug_editor; - replay_baton->baton = debug_baton; + replay_baton->editor = dump_editor; + replay_baton->baton = dump_baton;SVN_ERR (svn_cmdline_printf (pool,SVN_REPOS_DUMPFILE_MAGIC_HEADER ": %d\n" ,SVN_REPOS_DUMPFILE_FORMAT_VERSION )); SVN_ERR(svn_ra_replay_range(session, start_revision, end_revision,
Signature · 1 line
1.7.1
Re: [PATCH 06/13] Dump the revprops at the start of every revision
Quoted 2 lines · Ramkumar Ramachandra
Fill in
replay_revstartto dump the revprops at the start of every revision. Add an additionalwrite_hash_to_stringbufhelper function.
A write_hash_to_stringbuf helper does the work of converting the property hashtable to dumpfile format.
Quoted 1 line
+++
b/dumpr_util.c
[...]
dumpr_util.c line 16
Quoted 4 lines
dumpr_util.c new file +4
-0+void write_hash_to_stringbuf (apr_hash_t *properties, +svn_boolean_t deleted, +svn_stringbuf_t **strbuf, +apr_pool_t *pool)
This function looks like:
void write_hash_to_stringbuf(...
{
if (!deleted) {
for (each prop) {
append the new value of the prop;
}
} else {
for (each prop) {
mention that it has been deleted;
}
}
}It would be simpler to put the body of the loop in its own function, like this:
static void write_prop_to_stringbuf(...
{
if (deleted) {
append deletion notice;
return;
}
append new value of prop;
}
void write_hash_to_stringbuf(...
{
for (each prop)
write_prop_to_stringbuf(...
}Or even:
static void write_prop(...
static void write_deleted_prop(...
void write_prop_data_to_stringbuf(...
{
for (each prop)
write_prop(...
}
void write_deleted_prop_data_to_stringbuf(...
{
for (each prop)
write_deleted_prop(...
}which would make the arguments from the caller less opaque.
I did not check whether the "return early in the simpler case" is idiomatic for svn code. Of course you should respect whatever convention is prevalent.
Quoted 10 lines
dumpr_util.c new file +10
-0+{ +apr_hash_index_t *this; +const void *key; +void *val; +apr_ssize_t keylen; +svn_string_t *value; + +if (!deleted) { +for (this =apr_hash_first (pool, properties); this; + this =apr_hash_next (this)) {
dumpr_util.c line 36
Quoted 10 lines
dumpr_util.c new file +10
-0+/* Get this key and val. */ +apr_hash_this (this, &key, &keylen, &val); + value = val; + +/* Output name length, then name. */ +svn_stringbuf_appendcstr (*strbuf, +apr_psprintf (pool,"K %" APR_SSIZE_T_FMT "\n" , + keylen)); + +svn_stringbuf_appendbytes (*strbuf, (const char *) key, keylen);
Is the cast needed? (The answer might be "yes" if this code is meant to be usable with C++ compilers.)
svndumpr.c static svn_error_t *replay_revstart(svn_revnum_t revision, · line 29
Quoted 9 lines
+++
b/svndumpr.csvndumpr.c +4
-0@@ -23,6 +23,37 @@ static svn_error_t *replay_revstart(svn_revnum_t revision, apr_hash_t *rev_props, apr_pool_t *pool) { +/* Editing this revision has just started; dump the revprops +before invoking the editor callbacks */ +svn_stringbuf_t *propstring =svn_stringbuf_create ("" , pool); +svn_stream_t *stdout_stream;
Style: better to say in comments what we are trying to do than what we actually do. So:
/* First, dump revision properties. */
Maybe dumping revision properties should be its own function to make that comment unnecessary (and make replay_revstart() less daunting as it grows).
svndumpr.c static svn_error_t *replay_revstart(svn_revnum_t revision, · line 32
Quoted 3 lines
svndumpr.c +3
-0+ +/* Create an stdout stream */ +svn_stream_for_stdout (&stdout_stream, pool);
Useless comment.
svndumpr.c static svn_error_t *replay_revstart(svn_revnum_t revision, · line 39
Quoted 7 lines
svndumpr.c +7
-0+ +/* Print revision number and prepare the propstring */ +SVN_ERR (svn_stream_printf (stdout_stream, pool, +SVN_REPOS_DUMPFILE_REVISION_NUMBER +": %ld\n" , revision)); +write_hash_to_stringbuf (rev_props, FALSE, &propstring, pool); +svn_stringbuf_appendbytes (propstring,"PROPS-END\n" ,10 );
Unhelpful comment. Maybe:
/* Revision-number: 19 */ SVN_ERR(svn_stream_printf(stdout_stream, pool, SVN_REPOS_DUMPFILE_REVISION_NUMBER ": %ld\n", revision)); write_hash_to_stringbuf(rev_props, FALSE, &propstring, pool); svn_stringbuf_appendbytes(propstring, "PROPS-END\n", 10); /* Prop-content-length: 13 */ SVN_ERR(svn_stream_printf(stdout_stream, pool, SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH ": %" APR_SIZE_T_FMT "\n", propstring->len)); ...
This would make it particularly easy to grep for a particular header (even if grepping for SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH is not that hard).
[...]
svndumpr.c static svn_error_t *replay_revstart(svn_revnum_t revision, · line 53
Quoted 3 lines
svndumpr.c +3
-0+/* Print the revprops now */ +SVN_ERR (svn_stream_write (stdout_stream, propstring->data, + &(propstring->len)));
Maybe:
/* Property data. */ SVN_ERR(svn_stream_write(stdout_stream, propstring->data, &(propstring->len)));
The whole function so far has been about printing revprops.
Review static svn_error_t *replay_revstart(svn_revnum_t revision, · line 44
Quoted 2 lines
(quoted diff) +2
-0+ + svn_stream_close(stdout_stream);
This does not actually fclose(stdout), does it?
svndumpr.c static svn_error_t *replay_revend(svn_revnum_t revision, · line 75
Quoted 7 lines
svndumpr.c +3
-0@@ -39,6 +70,9 @@ static svn_error_t *replay_revend(svn_revnum_t revision, apr_hash_t *rev_props, apr_pool_t *pool) { +/* Editor has finished for this revision and close_edit has +been called; do nothing: just continue to the next +revision */
I’d leave out the comment, or:
/* No resources to free. */
HTH,
Jonathan
Re: [PATCH 06/13] Dump the revprops at the start of every revision
Hi Jonathan,
I stashed this review away while working on some other important changes. I finally got around to responding to this review- sorry that it took so long.
Quoted 6 lines · Jonathan Nieder
Quoted 2 lines
Fill in
replay_revstartto dump the revprops at the start of every revision. Add an additionalwrite_hash_to_stringbufhelper function.A
write_hash_to_stringbufhelper does the work of converting the property hashtable to dumpfile format.
Quoted 6 lines
Quoted 1 line
+++
b/dumpr_util.c[...]
dumpr_util.c line 16
Quoted 4 lines
dumpr_util.c new file +4
-0+void write_hash_to_stringbuf (apr_hash_t *properties, +svn_boolean_t deleted, +svn_stringbuf_t **strbuf, +apr_pool_t *pool)
[...]
Fixed, but not exactly in the way you've suggested.
Quoted 9 lines
dumpr_util.c line 36
Quoted 6 lines
dumpr_util.c new file +6
-0+/* Output name length, then name. */ +svn_stringbuf_appendcstr (*strbuf, +apr_psprintf (pool,"K %" APR_SSIZE_T_FMT "\n" , + keylen)); + +svn_stringbuf_appendbytes (*strbuf, (const char *) key, keylen);Is the cast needed? (The answer might be "yes" if this code is meant to be usable with C++ compilers.)
These casts are all over in the source tree, so I'm guessing the answer is "yes".
Quoted 4 lines
Style: better to say in comments what we are trying to do than what we actually do. So:
/* First, dump revision properties. */
I've fixed all the comments in the entire source tree. Thanks :)
-- Ram
Re: [PATCH 06/13] Dump the revprops at the start of every revision
Quoted 1 line · Ramkumar Ramachandra
Jonathan Nieder writes:
[...]
Quoted 10 lines
Quoted 9 lines
dumpr_util.c line 36
Quoted 6 lines
dumpr_util.c new file +6
-0+/* Output name length, then name. */ +svn_stringbuf_appendcstr (*strbuf, +apr_psprintf (pool,"K %" APR_SSIZE_T_FMT "\n" , + keylen)); + +svn_stringbuf_appendbytes (*strbuf, (const char *) key, keylen);Is the cast needed? (The answer might be "yes" if this code is meant to be usable with C++ compilers.)
Quoted 2 lines
These casts are all over in the source tree, so I'm guessing the answer is "yes".
Actually no - Subversion C code is not intended to be compilable as C++ and that cast is not needed. (Other casts that you see in Subversion code are for different situations.)
- Julian
Re: [PATCH 06/13] Dump the revprops at the start of every revision
Hi Julian,
Quoted 13 lines · Julian Foad
Quoted 1 line · Ramkumar Ramachandra
Jonathan Nieder writes:
[...]
Quoted 10 lines
Quoted 9 lines
dumpr_util.c line 36
Quoted 6 lines
dumpr_util.c new file +6
-0+/* Output name length, then name. */ +svn_stringbuf_appendcstr (*strbuf, +apr_psprintf (pool,"K %" APR_SSIZE_T_FMT "\n" , + keylen)); + +svn_stringbuf_appendbytes (*strbuf, (const char *) key, keylen);Is the cast needed? (The answer might be "yes" if this code is meant to be usable with C++ compilers.)
Quoted 6 lines
Quoted 2 lines
These casts are all over in the source tree, so I'm guessing the answer is "yes".
Actually no - Subversion C code is not intended to be compilable as C++ and that cast is not needed. (Other casts that you see in Subversion code are for different situations.)
Thanks for pointing that out. I'll fix them in my future commits.
-- Ram
PATCH 7/13 Implement open_root and close_edit
In reply to Ramkumar Ramachandraopen_root first creates a special edit_baton pool, and then allocates memory from that pool to various items in edit_baton. Then it creates a new directory baton to set as the root_baton. close_edit destroys the special edit_baton pool (hence destroying all the items that were allocated there), and increments current_rev. Add related make_dir_baton function and dir_baton_t structure.
--- dump_editor.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dumpr_util.h | 30 ++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 0 deletions(-)
dump_editor.c +70 -0
@@ -15,11 +15,77 @@#include "dumpr_util.h" + +/* Make a directory baton to represent the directory was path +(relative to EDIT_BATON's path) is PATH. + +CMP_PATH/CMP_REV are the path/revision against which this directory +should be compared for changes. If either is omitted (NULL for the +path, SVN_INVALID_REVNUM for the rev), just compare this directory +PATH against itself in the previous revision. + +PARENT_DIR_BATON is the directory baton of this directory's parent, +or NULL if this is the top-level directory of the edit. ADDED +indicated if this directory is newly added in this revision. +Perform all allocations in POOL. */ +struct dir_baton *make_dir_baton (const char *path, +const char *cmp_path, +svn_revnum_t cmp_rev, +void *edit_baton, +void *parent_dir_baton, +svn_boolean_t added, +apr_pool_t *pool) +{ +struct edit_baton *eb = edit_baton; +struct dir_baton *pb = parent_dir_baton; +struct dir_baton *new_db =apr_pcalloc (pool,sizeof (*new_db)); +const char *full_path; +apr_array_header_t *compose_path =apr_array_make (pool,2 ,sizeof (const char *)); + +/* A path relative to nothing? I don't think so. */ +SVN_ERR_ASSERT_NO_RETURN (!path || pb); + +/* Construct the full path of this node. */ +if (pb) { + APR_ARRAY_PUSH(compose_path, const char *) = "/"; + APR_ARRAY_PUSH(compose_path, const char *) = path; + full_path =svn_path_compose (compose_path, pool); + } +else + full_path =apr_pstrdup (pool,"/" ); + +/* Remove leading slashes from copyfrom paths. */ +if (cmp_path) + cmp_path = ((*cmp_path =='/' ) ? cmp_path +1 : cmp_path); + + new_db->eb = eb; + new_db->parent_dir_baton = pb; + new_db->path = full_path; + new_db->cmp_path = cmp_path ?apr_pstrdup (pool, cmp_path) :NULL ; + new_db->cmp_rev = cmp_rev; + new_db->added = added; + new_db->written_out = FALSE; + new_db->deleted_entries =apr_hash_make (pool); + new_db->pool = pool; + +return new_db; +}svn_error_t *open_root (void *edit_baton,svn_revnum_t base_revision,apr_pool_t *pool,void **root_baton) { +/* Allocate a special pool for the edit_baton to avoid pool +lifetime issues */ +struct edit_baton *eb = edit_baton; + eb->pool =svn_pool_create (pool); + eb->properties =apr_hash_make (eb->pool); + eb->del_properties =apr_hash_make (eb->pool); + eb->propstring =svn_stringbuf_create ("" , eb->pool); + eb->is_copy = FALSE; + + *root_baton =make_dir_baton (NULL ,NULL ,SVN_INVALID_REVNUM , + edit_baton,NULL , FALSE, pool);return SVN_NO_ERROR ; }
@@ -108,6 +174,10 @@ svn_error_t *close_file(void *file_baton,svn_error_t *close_edit (void *edit_baton,apr_pool_t *pool) { +struct edit_baton *eb = edit_baton; +svn_pool_destroy (eb->pool); + (eb->current_rev) ++; +return SVN_NO_ERROR ; }
dumpr_util.h +30 -0
@@ -31,6 +31,36 @@ struct edit_baton {svn_checksum_t *checksum; }; +struct dir_baton { +struct edit_baton *eb; +struct dir_baton *parent_dir_baton; + +/* is this directory a new addition to this revision? */ +svn_boolean_t added; + +/* has this directory been written to the output stream? */ +svn_boolean_t written_out; + +/* the absolute path to this directory */ +const char *path; + +/* the comparison path and revision of this directory. if both of +these are valid, use them as a source against which to compare +the directory instead of the default comparison source of PATH in +the previous revision. */ +const char *cmp_path; +svn_revnum_t cmp_rev; + +/* hash of paths that need to be deleted, though some -might- be +replaced. maps const char * paths to this dir_baton. (they're +full paths, because that's what the editor driver gives us. but +really, they're all within this directory.) */ +apr_hash_t *deleted_entries; + +/* pool to be used for deleting the hash items */ +apr_pool_t *pool; +}; + void write_hash_to_stringbuf(apr_hash_t *properties, svn_boolean_t deleted, svn_stringbuf_t **strbuf,
Signature · 1 line
1.7.1
PATCH 8/13 Implement dump_node
In reply to Ramkumar RamachandraAdd a new dump_node function to dump node headers Node-path, Node-kind, Node-action and set the right variables to trigger dumping properties. Copies are also handled appropriately using eb->is_copy, copyfrom_path, copyfrom_rev informatino from the caller. Also add a related dump_props helper function that uses write_hash_to_stringbuf to dump properties.
--- dump_editor.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dumpr_util.c | 48 +++++++++++++++++++++ dumpr_util.h | 5 ++ 3 files changed, 185 insertions(+), 0 deletions(-)
dump_editor.c +132 -0
@@ -15,6 +15,10 @@#include "dumpr_util.h" +#define ARE_VALID_COPY_ARGS (p,r) ((p) && SVN_IS_VALID_REVNUM(r)) + +svn_boolean_t must_dump_props = FALSE, must_dump_text = FALSE, + dump_props_pending = FALSE;/* Make a directory baton to represent the directory was path (relative to EDIT_BATON's path) is PATH.
@@ -70,6 +74,134 @@ struct dir_baton *make_dir_baton(const char *path,return new_db; } +/* +* Write out a node record for PATH of type KIND under EB->FS_ROOT. +* ACTION describes what is happening to the node (see enum svn_node_action). +* Write record to writable EB->STREAM, using EB->BUFFER to write in chunks. +* +* If the node was itself copied, IS_COPY is TRUE and the +* path/revision of the copy source are in CMP_PATH/CMP_REV. If +* IS_COPY is FALSE, yet CMP_PATH/CMP_REV are valid, this node is part +* of a copied subtree. +*/ +svn_error_t *dump_node (struct edit_baton *eb, +const char *path,/* an absolute path. */ +svn_node_kind_t kind, +enum svn_node_action action, +const char *cmp_path, +svn_revnum_t cmp_rev, +apr_pool_t *pool) +{ +/* Some pending properties to dump? */ +SVN_ERR (dump_props (eb, &dump_props_pending, TRUE, pool)); + +/* Write out metadata headers for this file node. */ +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_NODE_PATH ": %s\n" , + (*path =='/' ) ? path +1 : path)); + +if (kind == svn_node_file) +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_NODE_KIND ": file\n" )); +else if (kind == svn_node_dir) +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_NODE_KIND ": dir\n" )); + +/* Remove leading slashes from copyfrom paths. */ +if (cmp_path) + cmp_path = ((*cmp_path =='/' ) ? cmp_path +1 : cmp_path); + +switch (action) { +/* Appropriately handle the four svn_node_action actions */ + +case svn_node_action_change: +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_NODE_ACTION +": change\n" )); +break ; + +case svn_node_action_replace: +if (!eb->is_copy) { +/* a simple delete+add, implied by a single 'replace' action. */ +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_NODE_ACTION +": replace\n" )); + +/* definitely need to dump all content for a replace. */ + must_dump_props = TRUE; +break ; + } +/* More complex case: eb->is_copy is true, and +cmp_path/ cmp_rev are present: delete the original, +and then re-add it */ + +/* the path & kind headers have already been printed; just +add a delete action, and end the current record.*/ +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_NODE_ACTION +": delete\n\n" )); + +/* recurse: print an additional add-with-history record. */ +SVN_ERR (dump_node (eb, path, kind, svn_node_action_add, + cmp_path, cmp_rev, pool)); + +/* we can leave this routine quietly now, don't need to dump +any content; that was already done in the second record. */ + must_dump_props = FALSE; + eb->is_copy = FALSE; +break ; + +case svn_node_action_delete: +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_NODE_ACTION +": delete\n" )); + +/* we can leave this routine quietly now, don't need to dump +any content. */ +SVN_ERR (svn_stream_printf (eb->stream, pool,"\n\n" )); + must_dump_props = FALSE; +break ; + +case svn_node_action_add: +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_NODE_ACTION ": add\n" )); + +if (!eb->is_copy) { +/* If it's a file or directory not copied from +somewhere, wait for change_file_prop or +change_directory_prop */ + dump_props_pending = TRUE; +break ; + } + +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_NODE_COPYFROM_REV +": %ld\n" +SVN_REPOS_DUMPFILE_NODE_COPYFROM_PATH +": %s\n" , + cmp_rev, cmp_path)); + +/* Dump the text only if apply_textdelta sets +must_dump_text */ + +/* UGLY hack: If a directory was copied from a +previous revision, nothing else can be done, and +close_file won't be called to write two blank +lines; write them here */ +if (kind == svn_node_dir) +SVN_ERR (svn_stream_printf (eb->stream, pool,"\n\n" )); + + eb->is_copy = FALSE; + +break ; + } + +/* Dump property headers */ +SVN_ERR (dump_props (eb, &must_dump_props, FALSE, pool)); + +return SVN_NO_ERROR ; +} + svn_error_t *open_root(void *edit_baton, svn_revnum_t base_revision, apr_pool_t *pool,
dumpr_util.c +48 -0
51 lines not on this page · raw message
dumpr_util.h +5 -0
@@ -66,4 +66,9 @@ void write_hash_to_stringbuf(apr_hash_t *properties, svn_stringbuf_t **strbuf, apr_pool_t *pool); +svn_error_t *dump_props (struct edit_baton *eb, +svn_boolean_t *trigger_var, +svn_boolean_t dump_data_too, +apr_pool_t *pool); +#endif
Signature · 1 line
1.7.1
PATCH 9/13 Implement directory-related functions
In reply to Ramkumar RamachandraImplement open_directory, add_directory, change_dir_prop and close_directory. All of them involve adding and removing entries from the directory_baton and dumping the related node information. Note that open_directory doesn't need any corresponding node information to be printed.
--- dump_editor.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 101 insertions(+), 0 deletions(-)
dump_editor.c +101 -0
@@ -226,6 +226,12 @@ svn_error_t *delete_entry(const char *path,void *parent_baton, apr_pool_t *pool) { + struct dir_baton *pb = parent_baton; +const char *mypath =apr_pstrdup (pb->pool, path); + +/* remember this path needs to be deleted */ +apr_hash_set (pb->deleted_entries, mypath,APR_HASH_KEY_STRING , pb); +return SVN_NO_ERROR ; }
@@ -236,6 +242,32 @@ svn_error_t *add_directory(const char *path, apr_pool_t *pool, void **child_baton) { +struct dir_baton *pb = parent_baton; +void *val; +struct dir_baton *new_db + =make_dir_baton (path, copyfrom_path, copyfrom_rev, pb->eb, pb, TRUE, pool); + +/* This might be a replacement -- is the path already deleted? */ + val =apr_hash_get (pb->deleted_entries, path,APR_HASH_KEY_STRING ); + +/* Detect an add-with-history */ + pb->eb->is_copy =ARE_VALID_COPY_ARGS (copyfrom_path, copyfrom_rev); + +/* Dump the node */ +SVN_ERR (dump_node (pb->eb, path, + svn_node_dir, + val ? svn_node_action_replace : svn_node_action_add, + pb->eb->is_copy ? copyfrom_path :NULL , + pb->eb->is_copy ? copyfrom_rev :SVN_INVALID_REVNUM , + pool)); + +if (val) +/* Delete the path, it's now been dumped */ +apr_hash_set (pb->deleted_entries, path,APR_HASH_KEY_STRING ,NULL ); + + new_db->written_out = TRUE; + + *child_baton = new_db;return SVN_NO_ERROR ; }
@@ -245,12 +277,53 @@ svn_error_t *open_directory(const char *path, apr_pool_t *pool, void **child_baton) { +struct dir_baton *pb = parent_baton; +struct dir_baton *new_db; +const char *cmp_path =NULL ; +svn_revnum_t cmp_rev =SVN_INVALID_REVNUM ; +apr_array_header_t *compose_path =apr_array_make (pool,2 ,sizeof (const char *)); + +/* If the parent directory has explicit comparison path and rev, +record the same for this one. */ +if (pb &&ARE_VALID_COPY_ARGS (pb->cmp_path, pb->cmp_rev)) { + APR_ARRAY_PUSH(compose_path, const char *) = pb->cmp_path; + APR_ARRAY_PUSH(compose_path, const char *) = svn_dirent_basename(path, pool); + cmp_path =svn_path_compose (compose_path, pool); + cmp_rev = pb->cmp_rev; + } + + new_db =make_dir_baton (path, cmp_path, cmp_rev, pb->eb, pb, FALSE, pool); + *child_baton = new_db;return SVN_NO_ERROR ; }svn_error_t *close_directory (void *dir_baton,apr_pool_t *pool) { +struct dir_baton *db = dir_baton; +struct edit_baton *eb = db->eb; +apr_hash_index_t *hi; +apr_pool_t *subpool =svn_pool_create (pool); + +/* Some pending properties to dump? */ +SVN_ERR (dump_props (eb, &dump_props_pending, TRUE, pool)); + +/* Dump the directory entries */ +for (hi =apr_hash_first (pool, db->deleted_entries); hi; + hi =apr_hash_next (hi)) { +const void *key; +const char *path; +apr_hash_this (hi, &key,NULL ,NULL ); + path = key; + +svn_pool_clear (subpool); + +SVN_ERR (dump_node (db->eb, path, + svn_node_unknown, svn_node_action_delete, +NULL ,SVN_INVALID_REVNUM , subpool)); + } + +svn_pool_destroy (subpool);return SVN_NO_ERROR ; }
@@ -278,6 +351,34 @@ svn_error_t *change_dir_prop(void *parent_baton,const svn_string_t *value, apr_pool_t *pool) { + struct dir_baton *db = parent_baton; + +if (svn_property_kind (NULL , name) != svn_prop_regular_kind) +return SVN_NO_ERROR ; + + value ?apr_hash_set (db->eb->properties,apr_pstrdup (pool, name), +APR_HASH_KEY_STRING ,svn_string_dup (value, pool)) : +apr_hash_set (db->eb->del_properties,apr_pstrdup (pool, name), +APR_HASH_KEY_STRING , (void *)0x1 ); + +/* This function is what distinguishes between a directory that is +opened to merely get somewhere, vs. one that is opened because it +actually changed by itself */ +if (! db->written_out) { +SVN_ERR (dump_node (db->eb, db->path, + svn_node_dir, svn_node_action_change, + db->cmp_path, db->cmp_rev, pool)); + +/* If dump_props_pending was set, it means that the +node information corresponding to add_directory has already +been written; just don't unset it and dump_node will dump +the properties before doing anything else. If it wasn't +set, node information hasn't been written yet: so dump the +node itself before dumping the props */ + +SVN_ERR (dump_props (db->eb,NULL , TRUE, pool)); + db->written_out = TRUE; + }return SVN_NO_ERROR ; }
Signature · 1 line
1.7.1
PATCH 10/13 Implement file-related functions
In reply to Ramkumar RamachandraImplement add_file, open_file and change_file_prop. All of them involve dumping the corresponding node information and setting up the file_baton for apply_textdelta and close_file to use.
--- dump_editor.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-)
dump_editor.c +62 -0
@@ -334,6 +334,31 @@ svn_error_t *add_file(const char *path, apr_pool_t *pool, void **file_baton) { +struct dir_baton *pb = parent_baton; +void *val; + +/* This might be a replacement -- is the path already deleted? */ + val =apr_hash_get (pb->deleted_entries, path,APR_HASH_KEY_STRING ); + +/* Detect add-with-history. */ + pb->eb->is_copy =ARE_VALID_COPY_ARGS (copyfrom_path, copyfrom_rev); + +/* Dump the node. */ +SVN_ERR (dump_node (pb->eb, path, + svn_node_file, + val ? svn_node_action_replace : svn_node_action_add, + pb->eb->is_copy ? copyfrom_path :NULL , + pb->eb->is_copy ? copyfrom_rev :SVN_INVALID_REVNUM , + pool)); + +if (val) +/* delete the path, it's now been dumped. */ +apr_hash_set (pb->deleted_entries, path,APR_HASH_KEY_STRING ,NULL ); + +/* Build a nice file baton to pass to change_file_prop and apply_textdelta */ + pb->eb->changed_path = path; + *file_baton = pb->eb; +return SVN_NO_ERROR ; }
@@ -343,6 +368,28 @@ svn_error_t *open_file(const char *path, apr_pool_t *pool, void **file_baton) { +struct dir_baton *pb = parent_baton; +const char *cmp_path =NULL ; +svn_revnum_t cmp_rev =SVN_INVALID_REVNUM ; + +apr_array_header_t *compose_path =apr_array_make (pool,2 ,sizeof (const char *)); +/* If the parent directory has explicit comparison path and rev, +record the same for this one. */ +if (pb &&ARE_VALID_COPY_ARGS (pb->cmp_path, pb->cmp_rev)) { + APR_ARRAY_PUSH(compose_path, const char *) = pb->cmp_path; + APR_ARRAY_PUSH(compose_path, const char *) = svn_dirent_basename(path, pool); + cmp_path =svn_path_compose (compose_path, pool); + cmp_rev = pb->cmp_rev; + } + +SVN_ERR (dump_node (pb->eb, path, + svn_node_file, svn_node_action_change, + cmp_path, cmp_rev, pool)); + +/* Build a nice file baton to pass to change_file_prop and apply_textdelta */ + pb->eb->changed_path = path; + *file_baton = pb->eb; +return SVN_NO_ERROR ; }
@@ -387,6 +434,21 @@ svn_error_t *change_file_prop(void *file_baton,const svn_string_t *value, apr_pool_t *pool) { + struct edit_baton *eb = file_baton; + +if (svn_property_kind (NULL , name) != svn_prop_regular_kind) +return SVN_NO_ERROR ; + + value ?apr_hash_set (eb->properties,apr_pstrdup (pool, name), +APR_HASH_KEY_STRING ,svn_string_dup (value, pool)) : +apr_hash_set (eb->del_properties,apr_pstrdup (pool, name), +APR_HASH_KEY_STRING , (void *)0x1 ); + +/* Dump the property headers and wait; close_file might need +to write text headers too depending on whether +apply_textdelta is called */ + dump_props_pending = TRUE; +return SVN_NO_ERROR ; }
Signature · 1 line
1.7.1
PATCH 11/13 Implement apply_textdelta
In reply to Ramkumar Ramachandraapply_textdelta picks up information from the file_baton (set by add_file or open_file) and sets handler/ handler_baton to write a text delta. It uses a temporary file because the content length of the delta needs to be determined. Also add a related window_handler helper function gets the path of the temporary file written and cleans up after apply_textdelta. The text and prop deltas will finally be dumped in close_file.
--- dump_editor.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- dumpr_util.h | 15 ++++++++++++++ 2 files changed, 74 insertions(+), 1 deletions(-)
dump_editor.c +59 -1
@@ -452,11 +452,69 @@ svn_error_t *change_file_prop(void *file_baton,return SVN_NO_ERROR ; } +svn_error_t *window_handler (svn_txdelta_window_t *window,void *baton) +{ +struct handler_baton *hb = baton; +struct edit_baton *eb = hb->eb; +svn_error_t *err; + + err = hb->apply_handler (window, hb->apply_baton); +if (window !=NULL && !err) +return SVN_NO_ERROR ; + +if (err) +SVN_ERR (err); + +/* Write information about the filepath to hb->eb */ + eb->temp_filepath =apr_pstrdup (eb->pool, + hb->temp_filepath); + +/* Cleanup */ +SVN_ERR (svn_io_file_close (hb->temp_file, hb->pool)); +SVN_ERR (svn_stream_close (hb->temp_filestream)); +svn_pool_destroy (hb->pool); +return SVN_NO_ERROR ; +} +svn_error_t *apply_textdelta (void *file_baton,const char *base_checksum,apr_pool_t *pool,svn_txdelta_window_handler_t *handler,void **handler_baton) { +svn_stream_t *source_stream; +struct edit_baton *eb = file_baton; +apr_status_t apr_err; + +/* Custom handler_baton allocated in a separate pool */ +apr_pool_t *handler_pool =svn_pool_create (pool); +struct handler_baton *hb =apr_pcalloc (handler_pool,sizeof (*hb)); + hb->pool = handler_pool; + hb->eb = eb; + +/* Unset both handlers: To be set by two different functions later */ + hb->apply_handler =NULL ; + +/* Use a temporary file to measure the text-content-length */ + hb->temp_filepath =apr_psprintf (eb->pool,"/tmp/svn-fe/XXXXXX" ); + apr_err =apr_file_mktemp (&(hb->temp_file), hb->temp_filepath, +APR_CREATE |APR_READ |APR_WRITE |APR_EXCL , + hb->pool); +if (apr_err !=APR_SUCCESS ) +SVN_ERR (svn_error_wrap_apr (apr_err,NULL )); + + hb->temp_filestream =svn_stream_from_aprfile2 (hb->temp_file, TRUE, hb->pool); + source_stream =svn_stream_empty (hb->pool); + +/* Prepare to write the delta to the temporary file */ +svn_txdelta_to_svndiff2 (&(hb->apply_handler), &(hb->apply_baton), + hb->temp_filestream,0 , hb->pool); + must_dump_text = TRUE; + +/* The actual writing takes place when this function has finished */ +/* Set the handler and handler_baton */ + *handler = window_handler; + *handler_baton = hb; +return SVN_NO_ERROR ; }
@@ -493,7 +551,7 @@ svn_error_t *get_dump_editor(const svn_delta_editor_t **editor, de->close_directory = close_directory; de->change_dir_prop = change_dir_prop; de->change_file_prop = change_file_prop; -/* de->apply_textdelta = apply_textdelta; */ + de->apply_textdelta = apply_textdelta; de->add_file = add_file; de->open_file = open_file; de->close_file = close_file;
dumpr_util.h +15 -0
@@ -61,6 +61,21 @@ struct dir_baton {apr_pool_t *pool; }; +struct handler_baton +{ +svn_txdelta_window_handler_t apply_handler; +void *apply_baton; +apr_pool_t *pool; + +/* Information about the path of the tempoarary file used */ +char *temp_filepath; +apr_file_t *temp_file; +svn_stream_t *temp_filestream; + +/* To fill in the edit baton fields */ +struct edit_baton *eb; +}; + void write_hash_to_stringbuf(apr_hash_t *properties, svn_boolean_t deleted, svn_stringbuf_t **strbuf,
Signature · 1 line
1.7.1
PATCH 12/13 Implement close_file
In reply to Ramkumar Ramachandraclose_file measures the length of the temporary file to write text headers and full text before cleaning up the temporary file. It also writes props and prop deltas if necessary.
--- dump_editor.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 76 insertions(+), 0 deletions(-)
dump_editor.c +76 -0
@@ -522,6 +522,82 @@ svn_error_t *close_file(void *file_baton,const char *text_checksum, apr_pool_t *pool) { + struct edit_baton *eb = file_baton; +apr_file_t *temp_file; +svn_stream_t *temp_filestream; +apr_finfo_t *info =apr_pcalloc (pool,sizeof (apr_finfo_t)); + +/* We didn't write the property headers because we were +waiting for file_prop_change; write them now */ +SVN_ERR (dump_props (eb, &dump_props_pending, FALSE, pool)); + +/* The prop headers have already been dumped in dump_node */ +/* Dump the text headers */ +if (must_dump_text) { +/* text-delta header */ +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_TEXT_DELTA +": true\n" )); + +/* Measure the length */ +SVN_ERR (svn_io_stat (info, eb->temp_filepath,APR_FINFO_SIZE , pool)); + +/* text-content-length header */ +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_TEXT_CONTENT_LENGTH +": %lu\n" , + (unsigned long )info->size)); +/* text-content-md5 header */ +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_TEXT_CONTENT_MD5 +": %s\n" , + text_checksum)); + } + +/* content-length header: if both text and props are absent, +skip this block */ +if (must_dump_props || dump_props_pending) +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_CONTENT_LENGTH +": %ld\n\n" , + (unsigned long )info->size + eb->propstring->len)); +else if (must_dump_text) +SVN_ERR (svn_stream_printf (eb->stream, pool, +SVN_REPOS_DUMPFILE_CONTENT_LENGTH +": %ld\n\n" , + (unsigned long )info->size)); + +/* Dump the props; the propstring should have already been +written in dump_node or above */ +if (must_dump_props || dump_props_pending) { +SVN_ERR (svn_stream_write (eb->stream, eb->propstring->data, + &(eb->propstring->len))); + +/* Cleanup */ + must_dump_props = dump_props_pending = FALSE; +apr_hash_clear (eb->properties); +apr_hash_clear (eb->del_properties); + } + +/* Dump the text */ +if (must_dump_text) { + +/* Open the temporary file, map it to a stream, copy +the stream to eb->stream, close and delete the +file */ +SVN_ERR (svn_io_file_open (&temp_file, eb->temp_filepath,APR_READ ,0600 , pool)); + temp_filestream =svn_stream_from_aprfile2 (temp_file, TRUE, pool); +SVN_ERR (svn_stream_copy3 (temp_filestream, eb->stream,NULL ,NULL , pool)); + +/* Cleanup */ +SVN_ERR (svn_io_file_close (temp_file, pool)); +SVN_ERR (svn_stream_close (temp_filestream)); +SVN_ERR (svn_io_remove_file2 (eb->temp_filepath, TRUE, pool)); + must_dump_text = FALSE; + } + +SVN_ERR (svn_stream_printf (eb->stream, pool,"\n\n" )); +return SVN_NO_ERROR ; }
Signature · 1 line
1.7.1
PATCH 13/13 Add a validation script
In reply to Ramkumar RamachandraAdd a validation script along with a .gitignore. Using an existing dump known to be correct (possibly generated using svnsync and svnadmin dump --deltas), it compares the outputs produced by svnadmin load when fed with this dump and the dump from the program.
--- .gitignore | 4 ++++ validate.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 0 deletions(-) create mode 100644 .gitignore create mode 100755 validate.sh
.gitignore new file +4 -0
@@ -0,0 +1,4 @@ +*~ +t/ +svndumpr +svndumpr_bench
validate.sh new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
1.7.1
Hi,
Quoted 4 lines · Ramkumar Ramachandra
Please note that it has been built and tested only against the Subversion trunk: for Subversion 1.6, you can try using my ra-svn-1.6. Also, there seems to be some unresolved issue on 64-bit systems. We're working on fixing this.
This is fixed. I'm currently running a large validation on Avar's server.
NOTE to reviewers: The must_dump_props and dump_props_pending variables in patches 7-12 are very confusing. I've fixed this and added a long explanatory note in the latest commits. Please ignore it for the moment and review the rest of the series.
-- Ram