Skip to contentSkip to conversation

Get svnrdump merged into git.git

PATCH In review Ramkumar Ramachandra 5 participants 26 messages Jun 15, 2016 1 message not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

cover Get svnrdump merged into git.git

Hi,

For the convinience of fellow Git developers, here's a series to get svnrdump merged into git.git. Although the series is in excellent shape (thanks to reviewers), I'd like to make a special request to relax conformance guidelines a little bit for this series. I'll be getting commit access to the ASF repository soon; I will commit it there and make subsequent improvements in Subversion-land. As you can imagine, due to whitespace and style differences, it's too painful to backport the changes here. Once there's a release of Subversion with svnrdump merged in, I will remove it from git.git.

The series incorporates suggestions by Jonathan, Bert, and Daniel. However, it does not address the recent review by Stefan, and does not attempt to; Stefan's review will be addressed in future commits I make to svnrdump in the ASF repository.

Again, I'd request reviewers not to hold up this series for git.git:
suggestions will be incorporated as commits to the ASF. If something does not work, I'll quickly post fixup patches while the series is still in pu.

Thanks for reading.

-- Ram

Ramkumar Ramachandra (8):
Add LICENSE
Add skeleton SVN client and Makefile
Add debug editor from Subversion trunk Drive the debug editor
Dump the revprops at the start of every revision Implement directory-related functions Implement file-related functions Implement close_file

Will Palmer (1):
Add a validation script

 vcs-svn/LICENSE        |   26 ++
 vcs-svn/Makefile       |    8 +
 vcs-svn/debug_editor.c |  421 +++++++++++++++++++++++++++++++
 vcs-svn/debug_editor.h |   10 +
 vcs-svn/dump_editor.c  |  652 ++++++++++++++++++++++++++++++++++++++++++++++++
 vcs-svn/dump_editor.h  |    8 +
 vcs-svn/dumpr_util.c   |  112 +++++++++
 vcs-svn/dumpr_util.h   |   92 +++++++
 vcs-svn/svnrdump.c     |  185 ++++++++++++++
 vcs-svn/validate.sh    |  226 +++++++++++++++++
 10 files changed, 1740 insertions(+), 0 deletions(-)
 create mode 100644 vcs-svn/LICENSE
 create mode 100644 vcs-svn/Makefile
 create mode 100644 vcs-svn/debug_editor.c
 create mode 100644 vcs-svn/debug_editor.h
 create mode 100644 vcs-svn/dump_editor.c
 create mode 100644 vcs-svn/dump_editor.h
 create mode 100644 vcs-svn/dumpr_util.c
 create mode 100644 vcs-svn/dumpr_util.h
 create mode 100644 vcs-svn/svnrdump.c
 create mode 100755 vcs-svn/validate.sh
#1 lore raw

PATCH 1/9 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
new file mode 100644
index 0000000..4367b7c
@@ -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
#2 lore raw

Re: [PATCH 1/9] Add LICENSE

[ are all of these CCs really necessary? that's another thing I almost never see over at dev@svn ]

Ramkumar Ramachandra wrote on Wed, Jul 14, 2010 at 01:36:08 +0200:

Quoted 4 lines

License the project under a two-clause BSD-style license. A dual license will be required later when attempting to merge into Subversion.

If it ends in svn trunk as subversion/svnrdump/ (and not as a tools/ utility), it's going to have to be licensed under the Apache License v2.

Daniel
(AFAIK)

Quoted 41 lines
---
 LICENSE |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
 create mode 100644 LICENSE
LICENSE new file +26 -0
new file mode 100644
index 0000000..4367b7c
@@ -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
#3 lore raw

Re: [PATCH 1/9] Add LICENSE

Hi Daniel,

Quoted 2 lines · Daniel Shahaf

[ are all of these CCs really necessary? that's another thing I almost never see over at dev@svn ]

It's Git culture. Since our list is so high volume, many people aren't subscribed to the list. Even those who are subscribed often cannot read all the emails. When I CC someone on a list email, I'm implicitly telling them "Please review this patch" or "Please comment on this" or simply "You were involved with this work; just FYI, this is where it's going". Most email clients have convinient markers to tell people if they're marked on the To or Cc fields, or are simply receiving it because they're subscribed to a list.

Quoted 2 lines

If it ends in svn trunk as subversion/svnrdump/ (and not as a tools/ utility), it's going to have to be licensed under the Apache License v2.

Yes, I know. PATCH v2 is licensed appropriately. My intial idea was to dual-license it: two-clause BSD for the git.git version and Apache for the ASF version, but it seems like too much work now.

-- Ram

#4 lore raw

PATCH 2/9 Add skeleton SVN client and Makefile

In reply to Ramkumar Ramachandra

Add 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 +++++
 svnrdump.c |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+), 0 deletions(-)
 create mode 100644 Makefile
 create mode 100644 svnrdump.c
Makefile new file +8 -0
new file mode 100644
index 0000000..55f28e5
@@ -0,0 +1,8 @@
+svnrdump: *.c
+	$(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svnrdump.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
+
+svnrdump_bench: *.c
+	$(CC) -O2 -o $@ svnrdump.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
+
+clean:
+	$(RM) svnrdump svnrdump_bench
svnrdump.c new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
1.7.1
#5 lore raw

PATCH 3/9 Add debug editor from Subversion trunk

In reply to Ramkumar Ramachandra

Add the debug editor from subversion/libsvn_delta/debug_editor.c along with a header to expose the svn_delta__get_debug_editor function. It is used for wrapping other editors, and prints the operations it does to stderr making debugging easier.

---
 Makefile       |    8 +-
 debug_editor.c |  421 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 debug_editor.h |   10 ++
 dump_editor.c  |  144 +++++++++++++++++++
 dump_editor.h  |    8 +
 dumpr_util.h   |    9 ++
 6 files changed, 596 insertions(+), 4 deletions(-)
 create mode 100644 debug_editor.c
 create mode 100644 debug_editor.h
 create mode 100644 dump_editor.c
 create mode 100644 dump_editor.h
 create mode 100644 dumpr_util.h
Makefile +4 -4
index 55f28e5..3561909 100644
@@ -1,8 +1,8 @@
-svnrdump: *.c
-	$(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svnrdump.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
+svnrdump: *.c *.h
+	$(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svnrdump.c debug_editor.c dump_editor.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
 
-svnrdump_bench: *.c
-	$(CC) -O2 -o $@ svnrdump.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
+svnrdump_bench: *.c *.h
+	$(CC) -O2 -o $@ svnrdump.c debug_editor.c dump_editor.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
 
 clean:
 	$(RM) svnrdump svnrdump_bench
debug_editor.c new file +421 -0

421 lines not on this page · raw message

debug_editor.h new file +10 -0
new file mode 100644
index 0000000..a0d412a
@@ -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
dump_editor.c new file +144 -0

144 lines not on this page · raw message

dump_editor.h new file +8 -0
new file mode 100644
index 0000000..9c70b74
@@ -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 +9 -0
new file mode 100644
index 0000000..199c9c4
@@ -0,0 +1,9 @@
+#ifndef DUMPR_UTIL_H_
+#define DUMPR_UTIL_H_
+
+struct dump_edit_baton {
+	svn_stream_t *stream;
+	svn_revnum_t current_rev;
+};
+
+#endif
Signature · 1 line
1.7.1
#6 lore raw

PATCH 4/9 Drive the debug editor

In reply to Ramkumar Ramachandra

Wrap 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. In replay_revstart, extract and set editor/ edit_baton from the replay_baton; they must persist across all the callback functions while replaying a revision.

---
 dumpr_util.h |    5 +++++
 svnrdump.c   |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
dumpr_util.h +5 -0
index 199c9c4..8f494c1 100644
@@ -1,6 +1,11 @@
 #ifndef DUMPR_UTIL_H_
 #define DUMPR_UTIL_H_
 
+struct replay_baton {
+	const svn_delta_editor_t *editor;
+	void *edit_baton;
+};
+
 struct dump_edit_baton {
 	svn_stream_t *stream;
 	svn_revnum_t current_rev;
svnrdump.c +47 -0

64 lines not on this page · raw message

Signature · 1 line
1.7.1
#7 lore raw

PATCH 5/9 Dump the revprops at the start of every revision

In reply to Ramkumar Ramachandra

Fill in replay_revstart to dump the revprops at the start of every revision. Add an additional write_hash_to_stringbuf helper function.

---
 Makefile      |    4 +-
 dump_editor.c |  207 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 dumpr_util.c  |  112 +++++++++++++++++++++++++++++++
 dumpr_util.h  |   63 +++++++++++++++++
 svnrdump.c    |   40 +++++++++++-
 5 files changed, 421 insertions(+), 5 deletions(-)
 create mode 100644 dumpr_util.c
Makefile +2 -2
index 3561909..6a5a101 100644
@@ -1,8 +1,8 @@
 svnrdump: *.c *.h
-	$(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svnrdump.c debug_editor.c dump_editor.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 $@ svnrdump.c debug_editor.c dump_editor.c dumpr_util.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
 
 svnrdump_bench: *.c *.h
-	$(CC) -O2 -o $@ svnrdump.c debug_editor.c dump_editor.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
+	$(CC) -O2 -o $@ svnrdump.c debug_editor.c dump_editor.c dumpr_util.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
 
 clean:
 	$(RM) svnrdump svnrdump_bench
dump_editor.c +206 -1

224 lines not on this page · raw message

dumpr_util.c new file +112 -0

112 lines not on this page · raw message

dumpr_util.h +63 -0

69 lines not on this page · raw message

svnrdump.c +38 -2
index e184fee..d7c1eea 100644
@@ -25,6 +25,39 @@ 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;
 	*editor = rb->editor;
 	*edit_baton = rb->edit_baton;
@@ -39,6 +72,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;
 }
 
@@ -73,8 +109,8 @@ static svn_error_t *replay_range(svn_revnum_t start_revision, svn_revnum_t end_r
 	                                    dump_baton, pool));
 
 	struct replay_baton *replay_baton = apr_palloc(pool, sizeof(struct replay_baton));
-	replay_baton->editor = debug_editor;
-	replay_baton->edit_baton = debug_baton;
+	replay_baton->editor = dump_editor;
+	replay_baton->edit_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
#8 lore raw

PATCH 6/9 Implement directory-related functions

In reply to Ramkumar Ramachandra

Implement 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 |  112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 110 insertions(+), 2 deletions(-)
dump_editor.c +110 -2
index 0506966..7fafa8b 100644
@@ -225,6 +225,15 @@ static 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);
+
+	/* Some pending properties to dump? */
+	SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), TRUE, pool));
+
+	/* remember this path needs to be deleted */
+	apr_hash_set(pb->deleted_entries, mypath, APR_HASH_KEY_STRING, pb);
+
 	return SVN_NO_ERROR;
 }
 
@@ -235,7 +244,35 @@ static svn_error_t *add_directory(const char *path,
 				  apr_pool_t *pool,
 				  void **child_baton)
 {
-	*child_baton = NULL;
+	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);
+
+	/* Some pending properties to dump? */
+	SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), 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,13 +282,56 @@ static svn_error_t *open_directory(const char *path,
 				   apr_pool_t *pool,
 				   void **child_baton)
 {
-	*child_baton = NULL;
+	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 *));
+
+	/* Some pending properties to dump? */
+	SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), TRUE, pool));
+
+	/* 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_relpath_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;
 }
 
 static svn_error_t *close_directory(void *dir_baton,
 				    apr_pool_t *pool)
 {
+	struct dir_baton *db = dir_baton;
+	struct dump_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, &(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;
 }
 
@@ -281,6 +361,34 @@ static 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) {
+		/* If eb->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_node(db->eb, db->path,
+		                  svn_node_dir, svn_node_action_change,
+		                  db->cmp_path, db->cmp_rev, pool));
+
+		SVN_ERR(dump_props(db->eb, NULL, TRUE, pool));
+		db->written_out = TRUE;
+	}
 	return SVN_NO_ERROR;
 }
 
Signature · 1 line
1.7.1
#9 lore raw

PATCH 7/9 Implement file-related functions

In reply to Ramkumar Ramachandra

Implement 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 |  127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 dumpr_util.h  |   15 +++++++
 2 files changed, 138 insertions(+), 4 deletions(-)
dump_editor.c +123 -4
index 7fafa8b..8b0a830 100644
@@ -342,7 +342,34 @@ static svn_error_t *add_file(const char *path,
 			     apr_pool_t *pool,
 			     void **file_baton)
 {
-	*file_baton = NULL;
+	struct dir_baton *pb = parent_baton;
+	void *val;
+
+	/* Some pending properties to dump? */
+	SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), 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 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;
 }
 
@@ -352,7 +379,31 @@ static svn_error_t *open_file(const char *path,
 			      apr_pool_t *pool,
 			      void **file_baton)
 {
-	*file_baton = NULL;
+	struct dir_baton *pb = parent_baton;
+	const char *cmp_path = NULL;
+	svn_revnum_t cmp_rev = SVN_INVALID_REVNUM;
+
+	/* Some pending properties to dump? */
+	SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), TRUE, pool));
+
+	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_relpath_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;
 }
 
@@ -397,6 +448,44 @@ static svn_error_t *change_file_prop(void *file_baton,
 				     const svn_string_t *value,
 				     apr_pool_t *pool)
 {
+	struct dump_edit_baton *eb = file_baton;
+
+	if (svn_property_kind(NULL, name) != svn_prop_regular_kind)
+		return SVN_NO_ERROR;
+
+	apr_hash_set(eb->properties, apr_pstrdup(pool, name),
+		     APR_HASH_KEY_STRING, value ?
+		     svn_string_dup(value, pool): (void *)0x1);
+
+	/* Dump the property headers and wait; close_file might need
+	   to write text headers too depending on whether
+	   apply_textdelta is called */
+	eb->dump_props_pending = TRUE;
+
+	return SVN_NO_ERROR;
+}
+
+static svn_error_t *window_handler(svn_txdelta_window_t *window, void *baton)
+{
+	struct handler_baton *hb = baton;
+	struct dump_edit_baton *eb = hb->eb;
+	static 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;
 }
 
@@ -405,8 +494,38 @@ static 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;
+	struct dump_edit_baton *eb = file_baton;
+	apr_status_t apr_err;
+	const char *tempdir;
+
+	/* 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;
+
+	/* Use a temporary file to measure the text-content-length */
+	SVN_ERR(svn_io_temp_dir(&tempdir, hb->pool));
+
+	hb->temp_filepath = svn_dirent_join(tempdir, "XXXXXX", hb->pool);
+	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);
+
+	/* 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);
+	eb->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;
 }
 
dumpr_util.h +15 -0
index 4b0d5b0..9870b0d 100644
@@ -64,6 +64,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 dump_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
#10 lore raw

PATCH 8/9 Implement close_file

In reply to Ramkumar Ramachandra

close_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
index 8b0a830..b2fd3d6 100644
@@ -533,7 +533,82 @@ static svn_error_t *close_file(void *file_baton,
 			       const char *text_checksum,
 			       apr_pool_t *pool)
 {
+	struct dump_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, &(eb->dump_props_pending), FALSE, pool));
+
+	/* The prop headers have already been dumped in dump_node */
+	/* Dump the text headers */
+	if (eb->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 (eb->must_dump_props || eb->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 (eb->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 (eb->must_dump_props || eb->dump_props_pending) {
+		SVN_ERR(svn_stream_write(eb->stream, eb->propstring->data,
+					 &(eb->propstring->len)));
+
+		/* Cleanup */
+		eb->must_dump_props = eb->dump_props_pending = FALSE;
+		apr_hash_clear(eb->properties);
+		apr_hash_clear(eb->del_properties);
+	}
+
+	/* Dump the text */
+	if (eb->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));
+		eb->must_dump_text = FALSE;
+	}
+
+	SVN_ERR(svn_stream_printf(eb->stream, pool, "\n\n"));
+
 	return SVN_NO_ERROR;
 }
 
Signature · 1 line
1.7.1
#11 lore raw

PATCH 9/9 Add a validation script

In reply to Ramkumar Ramachandra

From: Will Palmer <[email protected]>

Add a validation script. 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.

The arguments added are:

    --svnadmin-dump=<file>      existing "svnadmin dump"
    --svndumpr-dump=<file>      existing "svndumpr" dump
    --repos=<url-or-path>       SVN repos URL, or local repos
    -r<revision>                end revision to dump/cut
    --ignore-existing           regenerate svnadmin-dump even if

it already exists
--make run "make svndumpr" prior to svnrdump
generate as with the old parameter, but now
implied by default
validate as with the old parameter, but now
implied by default

The end result is that the only step technically needed to test validation is:

./validate.sh --make --repos=/path/to/local/repos

---
 validate.sh |  226 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 226 insertions(+), 0 deletions(-)
 create mode 100755 validate.sh
validate.sh new file +226 -0
new file mode 100755
index 0000000..6bdb427
@@ -0,0 +1,226 @@
+#!/bin/sh
+usage(){
+	sed 's/..//' <<USAGE
+		Usage: validate.sh [--svnadmin-dump=<file>] [--svnrdump-dump=<file>]
+		                   [--repos=<url-or-path>] [-r<revision>]
+		                   [--ignore-existing-dump] [--make]
+		                   [generate] [validate]
+USAGE
+}
+
+svnadmin_dump=
+svnrdump_dump=
+repos_url=
+repos_path=
+end_rev=
+do_make=
+do_both=1
+do_generate=1
+do_validate=1
+do_ignore_existing_svnadmin_dump=
+while test "$#" -gt 0; do
+	case "$1" in
+	--svnadmin-dump=*)
+		svnadmin_dump="${1#*=}"
+		;;
+	--svnrdump-dump=*)
+		svnrdump_dump="${1#*=}"
+		;;
+	--ignore-existing|--ignore-existing-dump)
+		do_ignore_existing_svnadmin_dump=1
+		;;
+	--repos=*)
+		repos_url="${1#*=}"
+		repos_protocol="${repos_url%://*}"
+		repos_path="${repos_url#file://}"
+		if test "$repos_protocol" = "$repos_path"; then
+			repos_protocol=
+			repos_url=
+		elif test ! "$repos_protocol" = 'file'; then
+			repos_path=
+		fi
+		;;
+	-r*)
+		end_rev="${1#-r}"
+		;;
+	--make)
+		do_make=1
+		;;
+	generate)
+		do_generate=1
+		test -n "$do_both" && do_validate=
+		do_both=
+		;;
+	validate)
+		do_validate=1
+		test -n "$do_both" && do_generate=
+		do_both=
+		;;
+	-h|--help)
+		usage
+		exit
+		;;
+	*)
+		echo "unknown option $1" >&2
+		usage >&2
+		exit 1
+	esac
+	shift
+done
+
+if test -z "$svnrdump_dump"; then
+	if test -z "$repos_url"; then
+		if test -n "$repos_path"; then
+			repos_url="file://$(readlink -f "$repos_path")"
+			if test $? -ne 0; then
+				echo "error: unable to derive repos url from path" >&2
+				echo "--svnrdump_dump=<file> or a local (file://) --repos=<url> is required" >&2
+				exit 1
+			fi
+		else
+				echo "--svnrdump_dump=<file> or a local (file://) --repos=<url> is required" >&2
+				exit 1
+		fi
+	fi
+fi
+
+svnadmin_dump_cut="t/svnadmin-$end_rev.dump"
+svnrdump_dump_cut="t/svnrdump-$end_rev.dump"
+mkdir t 2>/dev/null
+
+if test -z "$svnadmin_dump"; then
+	if test -z "$repos_path"; then
+		echo "--svnadmin_dump=<file> or a local (file://) --repos=<url> is required" >&2
+		usage >&2
+		exit 1
+	fi
+
+	svnadmin_dump="$svnadmin_dump_cut"
+	if test -z "$do_ignore_existing_svnadmin_dump" && test -r "$svnadmin_dump"; then
+		echo "Using existing $svnadmin_dump"
+	else
+		echo "Generating $svnadmin_dump ..."
+
+		r=
+		if test -n "$end_rev"; then
+			r="-r0:$end_rev"
+		else
+			r="-r0:HEAD"
+		fi
+
+		svnadmin dump --deltas $r "$repos_path" > "$svnadmin_dump"
+		if test $? -ne 0; then
+			echo "error: failed to create canonical dump for comparison" >&2
+			exit 1
+		fi
+	fi
+else
+	echo "Using specified $svnadmin_dump"
+fi
+
+if test -z "$svnrdump_dump"; then
+	svnrdump_dump="$svnrdump_dump_cut"
+
+	if test -n "$do_make"; then
+		make svnrdump > /dev/null;
+		if test $? -ne 0; then
+			echo "error: Make failed. Check the program." >&2
+			exit 1;
+		fi
+	fi
+
+	echo "Generating $svnrdump_dump ..."
+
+	r=
+	test -n "$end_rev" && r="-r0:$end_rev"
+
+	./svnrdump -v $r "$repos_url" > "$svnrdump_dump"
+	if test $? -ne 0; then
+		echo "error: failed to create dump for validation" >&2
+		exit 1
+	fi
+else
+	echo "Using specified $svnrdump_dump"
+fi
+
+cut_dump(){
+	r="$1"
+	test -z "$r" && r=-1
+
+	gawk '
+		BEGIN {
+			max='"$r"'
+			hit_max=0
+		}
+		/^Revision-number: [0-9][0-9]*$/ {
+		rev=$2
+			if (rev == max) {
+				hit_max=1
+			} else if ( hit_max ) {
+				exit
+			}
+		}
+		{ print $0 }
+		END {
+			if (max == -1 || hit_max) {
+				exit 0
+			}
+			exit 1
+		}'
+}
+
+if test ! "$svnadmin_dump" = "$svnadmin_dump_cut"; then
+	cut_dump "$end_rev" <"$svnadmin_dump" >"$svnadmin_dump_cut"
+	if test $? -ne 0; then
+		echo "error: failed to cut canonical dump $svnadmin_dump for comparison" >&2
+		exit 1
+	fi
+	echo "Successfully generated cut canonical dump $svnadmin_dump_cut for comparison" >&2
+fi
+
+echo "Comparing canonical and svnrdump-based dumps..."
+diff -au "$svnadmin_dump_cut" "$svnrdump_dump" > t/dump-diff.error
+gawk \
+	'$0 !~ "Prop-delta: true|Text-delta-base-|sha1|Text-copy-source-|^-$" && $0 ~ "^+|^-" { print; }' \
+	t/dump-diff.error >t/dump-diff-filtered.error;
+
+if test -n "$do_generate"; then
+	echo "Generating canonical import logs..."
+
+	rm -rf t/repo;
+	mkdir t/repo;
+	svnadmin create t/repo;
+
+	svnadmin load t/repo < "$svnadmin_dump_cut" \
+	    1>"$svnadmin_dump_cut.import.log" 2>"$svnadmin_dump_cut.import.error";
+	if test $? -ne 0; then
+		echo "error: Load $end_rev failed. See $svnadmin_dump_cut.import.* for details" >&2
+		exit 1
+	fi
+	echo "Successfully generated canonical repository for comparison."
+fi
+
+if test -n "$do_validate"; then
+	echo "Generating svnrdump-based import logs..."
+
+	log_prefix=t/svnrdump-$end_rev
+
+	rm -rf t/repo;
+	mkdir t/repo;
+	svnadmin create t/repo;
+
+	svnadmin load t/repo < "$svnrdump_dump" 1>"$log_prefix.import.log" 2>"$log_prefix.import.error";
+	if test $? -ne 0; then
+		echo "error: Load $end_rev failed. See $log_prefix.import.* for details" >&2
+		exit 1
+	fi
+	echo "Successfully loaded svnrdump-based repository for validation"
+
+	echo "Comparing canonical and svnrdump-based import logs..."
+	diff -au "$svnadmin_dump_cut.import.log" "$log_prefix.import.log" > t/import-diff.error;
+	if test $? -ne 0; then
+		echo "Validation failed. See t/import-diff.error for details." >&2
+		exit 1
+	fi
+	echo "Validation successful"
+fi
Signature · 1 line
1.7.1
#12 lore raw
In reply to Ramkumar Ramachandra

Hi,

Just to clarify again, I'm doing this roundabout dance because a lot of other work in the git-remote-svn toolchain (svn-fe, a new dumpfile parser I'm writing, and a future branch/ tag mapper that some people are working on) is dependent on svnrdump; compiling the Subversion trunk just for svnrdump is both inconvinient and non-trivial. It's alright if the git.git version of svnrdump rots for a few months (before a Subversion release includes it), as long as it works and doesn't halt future work.

Thanks.

-- Ram

#13 lore raw

Hi Ram,

Sorry I missed this message before.

Quoted 4 lines · Ramkumar Ramachandra

It's
alright if the git.git version of svnrdump rots for a few months (before a Subversion release includes it), as long as it works and doesn't halt future work.

To clarify: is that because of API differences between svn 1.6 and trunk?

If we are including a convenience copy of files that are (soon to be) in svn trunk, I don’t see much reason to diverge from the svn version except for API differences and the overhead of updating too frequently.

#14 lore raw

Hi Jonathan,

Quoted 4 lines · Jonathan Nieder

If we are including a convenience copy of files that are (soon to be) in svn trunk, I don’t see much reason to diverge from the svn version except for API differences and the overhead of updating too frequently.

Is licensing an issue? I won't be the copyright holder or the sole contributor to svnrdump when it's in ASF. Can I just copy-paste from there into the git.git tree?

-- Ram

#15 lore raw
Quoted 3 lines · Ramkumar Ramachandra

Is licensing an issue? I won't be the copyright holder or the sole contributor to svnrdump when it's in ASF. Can I just copy-paste from there into the git.git tree?

As long as the relevant licenses permit that. svnrdump only links to libsvnclient, right? So copy-pasting the code along with

- a copy of the Apache license
- prominent notices in any files that differ from the svn version
- the notices from the Subversion NOTICE file

should be okay.

#16 lore raw

Hi,

Quoted 2 lines · Jonathan Nieder

As long as the relevant licenses permit that. svnrdump only links to libsvnclient, right?

I can see another problem coming: things are likely to move around quite a bit after the code gets into the ASF. For instance, Stefan's recent review points out that write_hash_to_stringbuf should probably be in a reusable library. If these changes happen soon, svnrdump will be tightly integrated into Subversion, and it'll be hard to separate out an independent program. Then again, we don't know how soon this will happen.

If you get this series merged into git.git, Git people will be able to read and review it easily and it'll be guaranteed to compile against SVN 1.6. In other words, it won't be a moving part. The downside being that it's too painful to backport changes from the ASF version, so it'll remain outdated atleast until the next Subversion release, and we don't know how soon that'll happen and be widely available.

If the former option is preferred, I'll send one large patch to the list for mirroring the version in ASF. Also, could the Subversion people confirm that licensing isn't an issue?

-- Ram

#17 lore raw
Quoted 5 lines · Ramkumar Ramachandra

Hi,

Quoted 2 lines · Jonathan Nieder

As long as the relevant licenses permit that. svnrdump only links to libsvnclient, right?

It links against a couple of Subversion libraries and against APR.

Quoted 15 lines

I can see another problem coming: things are likely to move around quite a bit after the code gets into the ASF. For instance, Stefan's recent review points out that write_hash_to_stringbuf should probably be in a reusable library. If these changes happen soon, svnrdump will be tightly integrated into Subversion, and it'll be hard to separate out an independent program. Then again, we don't know how soon this will happen.

If you get this series merged into git.git, Git people will be able to read and review it easily and it'll be guaranteed to compile against SVN 1.6. In other words, it won't be a moving part. The downside being that it's too painful to backport changes from the ASF version, so it'll remain outdated atleast until the next Subversion release, and we don't know how soon that'll happen and be widely available.

Quoted 2 lines

If the former option is preferred, I'll send one large patch to the list for mirroring the version in ASF.

Git devs will want a version of svnrdump that compiles against the 1.6.x libraries. We'll want a version that compiles against the trunk (so we can release it with 1.7).

So depending on which APIs svnrdump is using, it's likely that you'll have to maintain 2 slightly differing versions anyway, until 1.7 is released. (The current ETA for 1.7 is autumn, BTW).

Quoted 2 lines

Also, could the Subversion
people confirm that licensing isn't an issue?

I didn't catch any licensing discussion. What's the issue?

Stefan

#18 lore raw

Hi Stefan,

Quoted 7 lines · Stefan Sperling

Git devs will want a version of svnrdump that compiles against the 1.6.x libraries. We'll want a version that compiles against the trunk (so we can release it with 1.7).

So depending on which APIs svnrdump is using, it's likely that you'll have to maintain 2 slightly differing versions anyway, until 1.7 is released. (The current ETA for 1.7 is autumn, BTW).

Right, that's alright. I'll just have a commit that I'll keep rebase --ontoing to have the 1.6-specific changes.

Quoted 4 lines
Quoted 2 lines

Also, could the Subversion
people confirm that licensing isn't an issue?

I didn't catch any licensing discussion. What's the issue?

I guess there's no issue then- sorry, I know close to nothing about licensing.

-- Ram

#19 lore raw
Quoted 5 lines · Ramkumar Ramachandra
Quoted 1 line · Stefan Sperling

I didn't catch any licensing discussion. What's the issue?

I guess there's no issue then- sorry, I know close to nothing about licensing.

Well, the only theoretical issue I can see is that the FSF says that the GPLv2 was incompatible with the Apache 2.0 licence. See http://www.apache.org/licenses/GPL-compatibility.html

So if git distributed their own version of svnrdump licensed under GPLv2, depending on who you believe, distributors of Git binaries would violate the GPLv2 by linking svnrdump to the Subversion libraries.

Mercurial recently switched to GPLv3 for this reason. They have code that uses Subversion's Python bindings. They made this switch on their own accord, however, after consulting the Software Freedom Law Center. The Subversion project itself was not involved in that decision.

Possible workarounds are simply ignoring the FSF, or distributing all copies of svnrdump under Apache 2.0 or GPLv3 (but the svnrdump included in Subversion itself must be licensed under Apache 2.0).

Stefan

#20 lore raw
In reply to Ramkumar Ramachandra
Quoted 2 lines · Ramkumar Ramachandra

For the convinience of fellow Git developers, here's a series to get svnrdump merged into git.git.

Given you'll be maintaining a variant that can link with 1.6 subversion libraries anyway, I'd rather see you host this as an independent, related project, perhaps at repo.or.cz and/or github.com, and add a link to point at it at https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools

Thanks.

#21 lore raw

Hi Junio,

Quoted 4 lines · Junio C Hamano

Given you'll be maintaining a variant that can link with 1.6 subversion libraries anyway, I'd rather see you host this as an independent, related project, perhaps at repo.or.cz and/or github.com, and add a link to point at it at https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools

I think that sorts it out then. Thanks. I've merged this series into a new project on my GitHub [1]. I'll soon convert whitespace/ style and add some instructions, and maintain a branch that compiles against libsvn 1.6. Until svnrdump is in a re-usable library in the ASF, I'm afraid the git-remote-svn toolchain will simply have to spawn the executable and read the output from a pipe. Instructions can then be simplified to: compile svnrdump and place the executable anywhere in your $PATH.

[1]: http://github.com/artagnon/svnrdump

-- Ram

A message that is not in the archive (sent off-list or not yet received): 20100806175709.GA2683@burratino

#23 lore raw

Re: [PATCH svnrdump-standalone] Sync with upstream

Quoted 2 lines · Jonathan Nieder

Delete all files and copy in newer versions from Subversion upstream (http://svn.apache.org/repos/asf/subversion/trunk@982862).

Here’s the “while at it” part:

Quoted 12 lines

While at it, port for an out-of-tree build against svn 1.6:

- include a stripped-down version of the autoconf-generated Makefile for Linux and a .gitignore file listing build products;

- use apr_hash_clear directly instead of svn_hash__clear (since the latter’s signature has changed);

- build and use an svn17_compat module for functions used that were added in Subversion 1.7.

Quoted 8 lines

In theory, the svn17_compat module could shrink over time as simpler compatibility shims are devised.

The result builds and all dump tests pass.

Caveats: Most load tests do not pass. Chances are this will only build against libsvn 1.6, not 1.7, since I did not do the appropriate identifier-renaming dance.

Most of this patch is Subversion code.

The rest, which is my own doing, I place in the public domain. You may freely use, modify, distribute, and relicense it.

 .gitignore      |    5 +
 Makefile        |   35 +++
 dump_editor.c   |    9 +-
 svn17_compat.c  |  842 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 svn17_compat.h  |  179 ++++++++++++
 svnrdump.c      |    5 +-
 svntest/main.py |   17 +-
 7 files changed, 1076 insertions(+), 16 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 Makefile
 create mode 100644 svn17_compat.c
 create mode 100644 svn17_compat.h
.gitignore new file +5 -0
new file mode 100644
index 0000000..af251b1
@@ -0,0 +1,5 @@
+*.lo
+*.o
+*.pyc
+/svn-test-work/
+/svnrdump
Makefile new file +35 -0
new file mode 100644
index 0000000..b022411
@@ -0,0 +1,35 @@
+CC=gcc
+PYTHON=python
+LIBTOOL=libtool
+LTFLAGS=--tag=CC --silent
+CFLAGS=-g -O2 -pthread -Wall -Werror=implicit-function-declaration
+EXEEXT=
+CPPFLAGS=-DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE
+LDFLAGS=
+COMPILE=$(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES)
+LINK=$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(CFLAGS)
+LT_COMPILE=$(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE) $(CFLAGS)
+
+INCLUDES=-I/usr/include/subversion-1 -I/usr/include/apr-1.0
+LIBS=-lsvn_client-1 -lsvn_ra-1 -lsvn_repos-1 -lsvn_delta-1 -lsvn_subr-1 -lapr-1
+OBJECTS=dump_editor.lo load_editor.lo svnrdump.lo svn17_compat.lo
+
+.SUFFIXES: .c .lo
+
+svnrdump$(EXEEXT): $(OBJECTS)
+	$(LINK) $(LDFLAGS) -o svnrdump$(EXEEXT) $(OBJECTS) $(LIBS)
+
+.c.lo:
+	$(LT_COMPILE) -o $@ -c $<
+
+dump_editor.lo: dump_editor.c dump_editor.h svn17_compat.h
+load_editor.lo: load_editor.c load_editor.h
+svnrdump.lo: svnrdump.c dump_editor.h load_editor.h svn17_compat.h
+svn17_compat.lo: svn17_compat.c svn17_compat.h
+
+check: svnrdump$(EXEEXT) svnrdump_tests.py
+	$(PYTHON) svnrdump_tests.py
+
+clean:
+	$(RM) svnrdump$(EXEEXT)
+	$(RM) *.lo *.o
dump_editor.c +5 -4
index dac9d15..72ad04f 100644
@@ -29,6 +29,7 @@
 #include "svn_props.h"
 #include "svn_dirent_uri.h"
 
+#include "svn17_compat.h"
 #include "dump_editor.h"
 
 #define ARE_VALID_COPY_ARGS(p,r) ((p) && SVN_IS_VALID_REVNUM(r))
@@ -166,8 +167,8 @@ dump_props(struct dump_edit_baton *eb,
       SVN_ERR(svn_stream_printf(eb->stream, pool, "\n\n"));
 
       /* Cleanup so that data is never dumped twice. */
-      svn_hash__clear(eb->props, pool);
-      svn_hash__clear(eb->deleted_props, pool);
+      apr_hash_clear(eb->props);
+      apr_hash_clear(eb->deleted_props);
       if (trigger_var)
         *trigger_var = FALSE;
     }
@@ -711,8 +712,8 @@ close_file(void *file_baton,
 
       /* Cleanup */
       eb->dump_props = eb->dump_props_pending = FALSE;
-      svn_hash__clear(eb->props, pool);
-      svn_hash__clear(eb->deleted_props, pool);
+      apr_hash_clear(eb->props);
+      apr_hash_clear(eb->deleted_props);
     }
 
   /* Dump the text */
svn17_compat.c new file +842 -0

842 lines not on this page · raw message

svn17_compat.h new file +179 -0

179 lines not on this page · raw message

svnrdump.c +2 -3
index daf826e..a320b24 100644
@@ -30,15 +30,14 @@
 #include "svn_repos.h"
 #include "svn_path.h"
 #include "svn_utf.h"
-#include "svn_private_config.h"
 #include "svn_string.h"
 #include "svn_props.h"
+#include "svn_dirent_uri.h"
 
+#include "svn17_compat.h"
 #include "dump_editor.h"
 #include "load_editor.h"
 
-#include "private/svn_cmdline_private.h"
-
 static svn_opt_subcommand_t dump_cmd, load_cmd;
 
 enum svn_svnrdump__longopt_t
svntest/main.py +8 -9
index 2c59101..3e938d6 100644
@@ -149,15 +149,14 @@ def url2pathname(path):
 # The locations of the svn, svnadmin and svnlook binaries, relative to
 # the only scripts that import this file right now (they live in ../).
 # Use --bin to override these defaults.
-svn_binary = os.path.abspath('../../svn/svn' + _exe)
-svnadmin_binary = os.path.abspath('../../svnadmin/svnadmin' + _exe)
-svnlook_binary = os.path.abspath('../../svnlook/svnlook' + _exe)
-svnrdump_binary = os.path.abspath('../../svnrdump/svnrdump' + _exe)
-svnsync_binary = os.path.abspath('../../svnsync/svnsync' + _exe)
-svnversion_binary = os.path.abspath('../../svnversion/svnversion' + _exe)
-svndumpfilter_binary = os.path.abspath('../../svndumpfilter/svndumpfilter' + \
-                                       _exe)
-entriesdump_binary = os.path.abspath('entries-dump' + _exe)
+svn_binary = 'svn'
+svnadmin_binary = 'svnadmin'
+svnlook_binary = 'svnlook'
+svnrdump_binary = os.path.abspath('./svnrdump' + _exe)
+svnsync_binary = 'svnsync'
+svnversion_binary = 'svnversion'
+svndumpfilter_binary = 'svndumpfilter'
+entriesdump_binary = 'entries-dump'
 
 # Location to the pristine repository, will be calculated from test_area_url
 # when we know what the user specified for --url.
Signature · 1 line
1.7.2.1.544.ga752d.dirty
#24 lore raw

Re: [PATCH svnrdump-standalone] Sync with upstream

In reply to a message not in the archive
Quoted 1 line · Jonathan Nieder

Caveats: Most load tests do not pass.

They pass now. Thanks for the help!

You can

git clone git://repo.or.cz/svnrdump/jrn.git

for the tree. The todo branch documents how to revive the git-svn branches.

Have fun,
Jonathan

#25 lore raw

Re: [PATCH svnrdump-standalone] Sync with upstream

Hi Jonathan,

Quoted 5 lines · Jonathan Nieder
Quoted 1 line · Jonathan Nieder

Caveats: Most load tests do not pass.

They pass now. Thanks for the help!

:)

Quoted 6 lines

You can

git clone git://repo.or.cz/svnrdump/jrn.git

for the tree. The todo branch documents how to revive the git-svn branches.

Thanks for this- I can easily maintain an out-of-trunk version that compiles against 1.6 now. Much nicer than your massive patches :)

-- Ram

#26 lore raw

Re: [PATCH svnrdump-standalone] Sync with upstream

In reply to Jonathan Nieder

Hi Jonathan,

Quoted 2 lines · Jonathan Nieder

for the tree. The todo branch documents how to revive the git-svn branches.

Thanks especially for taking the effort to import the history from SVN and write a nice NOTES file :)

-- Ram