Skip to contentSkip to conversation

Subversion dump parsing library

PATCH In review Jonathan Nieder 3 participants 35 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover Subversion dump parsing library

Hi gitsters,

Ram last sent this series a couple of weeks ago[1], and it was merged to pu then as rr/svn-export. Here’s another iteration of the same for discussion, now including David Barr’s program that demonstrates the functionality.

Patch 1 is not so closely related; it just modifies parse_date_toffset() to keep me a little saner while using it.

Patches 2-8 are very similar to the versions Ram sent. I expanded the commit messages, took the latest code from
git://github.com/barrbrain/svn-dump-fast-export where possible, and added a simple example build system so one can see the result of compiling with

make vcs-svn/lib.a

Probably more interesting is what the patches do not do:

- they do not include any tests

- they do not remove the persistent object pool functionality. If you try this code out, be sure to remove all the .bin files from the current directory after each run.

- they are not guaranteed to have fewer bugs than the version Ram sent. In fact, the opposite is more likely, since the code is only lightly tested

You can try it out with

; cd contrib/svn-fe
; wget http://github.com/barrbrain/svn-dump-fast-export/raw/master/test.dump
; make svn-fe
; ./svn-fe <test.dump

or

; make svn-fe.1
; man ./svn-fe.1

and go from there.

Any feedback is appreciated, especially on how to make this fit better with git. I would be particularly interested in making vcs-svn/lib.a self-sufficient --- that is, would there be a simple way to pull out the required code from date.c?

David Barr (5):
Add memory pool library
Add string-specific memory pool
Add stream helper library
Add infrastructure to write revisions in fast-export format Add SVN dump parser

Jason Evans (1):
Add treap implementation

Jonathan Nieder (3):
Export parse_date_basic() to convert a date string to timestamp Introduce vcs-svn lib
Add a sample user for the svndump library

 Makefile                  |   12 ++-
 cache.h                   |    1 +
 contrib/svn-fe/.gitignore |    3 +
 contrib/svn-fe/Makefile   |   63 +++++++++
 contrib/svn-fe/svn-fe.c   |   43 ++++++
 contrib/svn-fe/svn-fe.txt |   56 ++++++++
 date.c                    |   14 +-
 vcs-svn/LICENSE           |   33 +++++
 vcs-svn/fast_export.c     |   75 ++++++++++
 vcs-svn/fast_export.h     |   14 ++
 vcs-svn/line_buffer.c     |   93 +++++++++++++
 vcs-svn/line_buffer.h     |   14 ++
 vcs-svn/obj_pool.h        |   80 +++++++++++
 vcs-svn/repo_tree.c       |  335 +++++++++++++++++++++++++++++++++++++++++++++
 vcs-svn/repo_tree.h       |   26 ++++
 vcs-svn/string_pool.c     |  114 +++++++++++++++
 vcs-svn/string_pool.h     |   15 ++
 vcs-svn/svndump.c         |  289 ++++++++++++++++++++++++++++++++++++++
 vcs-svn/svndump.h         |    8 +
 vcs-svn/trp.h             |  220 +++++++++++++++++++++++++++++
 vcs-svn/trp.txt           |   90 ++++++++++++
 21 files changed, 1589 insertions(+), 9 deletions(-)
 create mode 100644 contrib/svn-fe/.gitignore
 create mode 100644 contrib/svn-fe/Makefile
 create mode 100644 contrib/svn-fe/svn-fe.c
 create mode 100644 contrib/svn-fe/svn-fe.txt
 create mode 100644 vcs-svn/LICENSE
 create mode 100644 vcs-svn/fast_export.c
 create mode 100644 vcs-svn/fast_export.h
 create mode 100644 vcs-svn/line_buffer.c
 create mode 100644 vcs-svn/line_buffer.h
 create mode 100644 vcs-svn/obj_pool.h
 create mode 100644 vcs-svn/repo_tree.c
 create mode 100644 vcs-svn/repo_tree.h
 create mode 100644 vcs-svn/string_pool.c
 create mode 100644 vcs-svn/string_pool.h
 create mode 100644 vcs-svn/svndump.c
 create mode 100644 vcs-svn/svndump.h
 create mode 100644 vcs-svn/trp.h
 create mode 100644 vcs-svn/trp.txt

[1] http://thread.gmane.org/gmane.comp.version-control.git/148866

#1 lore raw

PATCH v2 1/9 Export parse_date_basic() to convert a date string to timestamp

approxidate() is not appropriate for reading machine-written dates because it guesses instead of erroring out on malformed dates. parse_date() is less convenient since it returns its output as a string. So export the underlying function that writes a timestamp.

While at it, change the return value to match the usual convention:
return 0 for success and -1 for failure.

---
 cache.h |    1 +
 date.c  |   14 ++++++--------
 2 files changed, 7 insertions(+), 8 deletions(-)
cache.h +1 -0
index ff4a7c2..4566501 100644
@@ -800,6 +800,7 @@ const char *show_date_relative(unsigned long time, int tz,
 			       char *timebuf,
 			       size_t timebuf_size);
 int parse_date(const char *date, char *buf, int bufsize);
+int parse_date_basic(const char *date, unsigned long *timestamp, int *offset);
 void datestamp(char *buf, int bufsize);
 #define approxidate(s) approxidate_careful((s), NULL)
 unsigned long approxidate_careful(const char *, int *);
date.c +6 -8
index 68cdcaa..383706d 100644
@@ -586,7 +586,7 @@ static int date_string(unsigned long date, int offset, char *buf, int len)
 
 /* Gr. strptime is crap for this; it doesn't have a way to require RFC2822
    (i.e. English) day/month names, and it doesn't work correctly with %z. */
-int parse_date_toffset(const char *date, unsigned long *timestamp, int *offset)
+int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
 {
 	struct tm tm;
 	int tm_gmt;
@@ -642,17 +642,16 @@ int parse_date_toffset(const char *date, unsigned long *timestamp, int *offset)
 
 	if (!tm_gmt)
 		*timestamp -= *offset * 60;
-	return 1; /* success */
+	return 0; /* success */
 }
 
 int parse_date(const char *date, char *result, int maxlen)
 {
 	unsigned long timestamp;
 	int offset;
-	if (parse_date_toffset(date, &timestamp, &offset) > 0)
-		return date_string(timestamp, offset, result, maxlen);
-	else
+	if (parse_date_basic(date, &timestamp, &offset))
 		return -1;
+	return date_string(timestamp, offset, result, maxlen);
 }
 
 enum date_mode parse_date_format(const char *format)
@@ -1004,9 +1003,8 @@ unsigned long approxidate_relative(const char *date, const struct timeval *tv)
 	int offset;
 	int errors = 0;
 
-	if (parse_date_toffset(date, &timestamp, &offset) > 0)
+	if (!parse_date_basic(date, &timestamp, &offset))
 		return timestamp;
-
 	return approxidate_str(date, tv, &errors);
 }
 
@@ -1019,7 +1017,7 @@ unsigned long approxidate_careful(const char *date, int *error_ret)
 	if (!error_ret)
 		error_ret = &dummy;
 
-	if (parse_date_toffset(date, &timestamp, &offset) > 0) {
+	if (!parse_date_basic(date, &timestamp, &offset)) {
 		*error_ret = 0;
 		return timestamp;
 	}
Signature · 1 line
1.7.1
Acked-by on v2 1/9
#2 lore raw

Re: [PATCH 1/9] Export parse_date_basic() to convert a date string to timestamp

Hi Jonathan,

This specific patch is clear. I have some issues with some of the other parts in the series.

Quoted 4 lines · Jonathan Nieder

approxidate() is not appropriate for reading machine-written dates because it guesses instead of erroring out on malformed dates. parse_date() is less convenient since it returns its output as a string.  So export the underlying function that writes a timestamp.

Right. I couldn't justify exposing it in the series that's in master now.

Quoted 2 lines

While at it, change the return value to match the usual convention:
return 0 for success and -1 for failure.

Since I'm to blame for this change,

-- Ram

#3 lore raw

PATCH v2 2/9 Introduce vcs-svn lib

In reply to Jonathan Nieder

Teach the build system to build a separate library for the upcoming subversion interop support.

The resulting vcs-svn/lib.a does not contain any code, nor is it built during a normal build. This is just scaffolding for later changes.

---
 Makefile |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
Makefile +7 -1
index 9aca8a1..6441dcb 100644
@@ -468,6 +468,7 @@ export PYTHON_PATH
 
 LIB_FILE=libgit.a
 XDIFF_LIB=xdiff/lib.a
+VCSSVN_LIB=vcs-svn/lib.a
 
 LIB_H += advice.h
 LIB_H += archive.h
@@ -1739,7 +1740,8 @@ ifndef NO_CURL
 endif
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
-OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
+VCSSVN_OBJS =
+OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)
 
 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
 dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
@@ -1860,6 +1862,8 @@ http.o http-walker.o http-push.o remote-curl.o: http.h
 xdiff-interface.o $(XDIFF_OBJS): \
 	xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
 	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
+
+$(VCSSVN_OBJS):
 endif
 
 exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
@@ -1908,6 +1912,8 @@ $(LIB_FILE): $(LIB_OBJS)
 $(XDIFF_LIB): $(XDIFF_OBJS)
 	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
 
+$(VCSSVN_LIB): $(VCSSVN_OBJS)
+	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(VCSSVN_OBJS)
 
 doc:
 	$(MAKE) -C Documentation all
Signature · 1 line
1.7.1
Acked-by on v2 2/9
#4 lore raw

Re: [PATCH 2/9] Introduce vcs-svn lib

Hi,

Quoted 6 lines · Jonathan Nieder

Teach the build system to build a separate library for the upcoming subversion interop support.

The resulting vcs-svn/lib.a does not contain any code, nor is it built during a normal build.  This is just scaffolding for later changes.

This is very elegant indeed!

-- Ram

#5 lore raw

PATCH v2 3/9 Add memory pool library

In reply to Jonathan Nieder

From: David Barr <[email protected]>

Add a memory pool library implemented using C macros. The obj_pool_gen() macro creates a type-specific memory pool API.

The memory pool library is distinguished from the existing specialized allocators in alloc.c by using a contiguous block for all allocations. This means that on one hand, long-lived pointers have to be written as offsets, since the base address changes as the pool grows, but on the other hand, the entire pool can be easily written to the file system. This allows the memory pool to persist between runs of an application.

For the svn importer, such a facility is useful because each svn revision can copy trees and files from any previous revision. The relevant information for all revisions has to persist somehow to support incremental runs, and for now it is simplest to avoid relying on the target VCS for that.

obj_pool_gen(pre, obj_t, initial_capability)

pre: Prefix for generated functions (example: string).
obj_t: Type for treap data structure (example: char).
initial_capacity: Initial size of the memory pool (example: 4096).

void pre_init(void);

Read values from a previous run to initialize the pool. If this function is not called, the pool begins valid but empty.

uint32_t pre_alloc(uint32_t nmemb);

Reserve space for a few objects in the pool and return an offset to the first one.

uint32_t pre_free(uint32_t nmemb);

Unreserve the last few objects reserved.

uint32_t pre_offset(obj_t *pointer);
obj_t *pre_pointer(uint32_t offset);

Convert between pointers into the in-memory pool and offsets from the beginning (or ~0 for the NULL pointer). Pointers are not guaranteed to remain valid after a pre_alloc() operation or pre_reset() followed by pre_init(), but offsets are.

void pre_commit(void);

Write the pool to file. A pre_reset() followed by pre_init() (pehaps with exit() in between) will return the pool to the last committed state.

void pre_reset(void);

Deinitialize the pool, freeing any associated memory and file handles.

---
 Makefile           |    3 +-
 vcs-svn/LICENSE    |   26 +++++++++++++++++
 vcs-svn/obj_pool.h |   80 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+), 1 deletions(-)
 create mode 100644 vcs-svn/LICENSE
 create mode 100644 vcs-svn/obj_pool.h
Makefile +2 -1
index 6441dcb..fc31ee0 100644
@@ -1863,7 +1863,8 @@ xdiff-interface.o $(XDIFF_OBJS): \
 	xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
 	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
 
-$(VCSSVN_OBJS):
+$(VCSSVN_OBJS): \
+	vcs-svn/obj_pool.h
 endif
 
 exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
vcs-svn/LICENSE new file +26 -0
new file mode 100644
index 0000000..6e52372
@@ -0,0 +1,26 @@
+Copyright (C) 2010 David Barr <[email protected]>.
+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.
vcs-svn/obj_pool.h new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
1.7.1
#6 lore raw

Re: [PATCH 3/9] Add memory pool library

Hi Jonathan,

Quoted 4 lines · Jonathan Nieder

From: David Barr <[email protected]>

Add a memory pool library implemented using C macros. The obj_pool_gen() macro creates a type-specific memory pool API.

Until some sort of mmap is implemented, I doubt we can do much better than this. By marking all the generated functions MAYBE_UNUSED, we're actually suppressing more warnings than intended. Maybe we can avoid it and somehow find a way to mark only those functions that are really unused? Perhaps an extra parameter in obj_pool_gen?

-- Ram

#7 lore raw

Re: [PATCH 3/9] Add memory pool library

Hi Ram,

Quoted 4 lines · Ramkumar Ramachandra

By marking all the generated functions MAYBE_UNUSED, we're actually suppressing more warnings than intended. Maybe we can avoid it and somehow find a way to mark only those functions that are really unused?

If we used templates instead of macros, a smart compiler would notice which functions are _never_ used. But sticking to C, I think it is fine to rely on humans checking by hand for now. (FWIW no obj_pool functions are unused at the moment.)

I tried leaving out the MAYBE_UNUSED for foo_init() before I realized that calling it is optional.

Quoted 1 line

Perhaps an extra parameter in obj_pool_gen?

Filling out such a list for each caller sounds to me like more trouble than it’s worth.

Jonathan

#8 lore raw

Re: [PATCH 3/9] Add memory pool library

Hi Jonathan,

Quoted 7 lines · Jonathan Nieder

If we used templates instead of macros, a smart compiler would notice which functions are _never_ used.  But sticking to C, I think it is fine to rely on humans checking by hand for now.  (FWIW no obj_pool functions are unused at the moment.)

Filling out such a list for each caller sounds to me like more trouble than it’s worth.

Okay, I have an idea. We'll document it as a comment so people will be able to see which exact functions were unused in this import. The following functions are unused: blob_init, blob_offset, blob_commit, commit_free, commit_offset, dir_free, node_init, node_commit, string_offset, tree_first, tree_next, tree_remove, log_init, log_offset, and log_commit.

-- Ram

#9 lore raw

Re: [PATCH 3/9] Add memory pool library

Quoted 5 lines · Ramkumar Ramachandra

The
following functions are unused: blob_init, blob_offset, blob_commit, commit_free, commit_offset, dir_free, node_init, node_commit, string_offset, tree_first, tree_next, tree_remove, log_init, log_offset, and log_commit.

Thanks for this list. Do you think it’s worth automating its production? i.e., a masochistic person could write a script to compile with the __attribute__((unused)) suppressed, parse warnings to find unused functions, and then take an intersection of sets to confirm that no family of functions is unused.

Jonathan

#10 lore raw

Re: [PATCH 3/9] Add memory pool library

Hi again,

Quoted 5 lines · Jonathan Nieder

Thanks for this list.  Do you think it’s worth automating its production?  i.e., a masochistic person could write a script to compile with the __attribute__((unused)) suppressed, parse warnings to find unused functions, and then take an intersection of sets to confirm that no family of functions is unused.

Er, I think that's a bit of an overkill :p
Someone editing the code can always suppress MAYBE_UNUSED and check with our list of unused functions in the comment by hand.

-- Ram

#11 lore raw

PATCH v2 4/9 Add treap implementation

In reply to Jonathan Nieder

From: Jason Evans <[email protected]>

Provide macros to generate a type-specific treap implementation and various functions to operate on it. It uses obj_pool.h to store memory nodes in a treap. Previously committed nodes are never removed from the pool; after any *_commit operation, it is assumed (correctly, in the case of svn-fast-export) that someone else must care about them.

Treaps provide a memory-efficient binary search tree structure. Insertion/deletion/search are about as about as fast in the average case as red-black trees and the chances of worst-case behavior are vanishingly small, thanks to (pseudo-)randomness. The bad worst-case behavior is a small price to pay, given that treaps are much simpler to implement.

From http://www.canonware.com/download/trp/trp_hash/trp.h

[db: Altered to reference nodes by offset from a common base pointer] [db: Bob Jenkins' hashing implementation dropped for Knuth's] [db: Methods unnecessary for search and insert dropped]

---
 Makefile        |    2 +-
 vcs-svn/LICENSE |    3 +
 vcs-svn/trp.h   |  220 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 vcs-svn/trp.txt |   90 ++++++++++++++++++++++
 4 files changed, 314 insertions(+), 1 deletions(-)
 create mode 100644 vcs-svn/trp.h
 create mode 100644 vcs-svn/trp.txt
Makefile +1 -1
index fc31ee0..663a366 100644
@@ -1864,7 +1864,7 @@ xdiff-interface.o $(XDIFF_OBJS): \
 	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
 
 $(VCSSVN_OBJS): \
-	vcs-svn/obj_pool.h
+	vcs-svn/obj_pool.h vcs-svn/trp.h
 endif
 
 exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
vcs-svn/LICENSE +3 -0
index 6e52372..a3d384c 100644
@@ -1,6 +1,9 @@
 Copyright (C) 2010 David Barr <[email protected]>.
 All rights reserved.
 
+Copyright (C) 2008 Jason Evans <[email protected]>.
+All rights reserved.
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:
vcs-svn/trp.h new file +220 -0

220 lines not on this page · raw message

vcs-svn/trp.txt new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
1.7.1
#12 lore raw

Re: [PATCH 4/9] Add treap implementation

Hi again,

Quoted 7 lines · Jonathan Nieder

From: Jason Evans <[email protected]>

Provide macros to generate a type-specific treap implementation and various functions to operate on it. It uses obj_pool.h to store memory nodes in a treap.  Previously committed nodes are never removed from the pool; after any *_commit operation, it is assumed (correctly, in the case of svn-fast-export) that someone else must care about them.

This is likely to change in a few days. David is currently working on a Java implementation of a immutable ternary treap and will re-implement it as C macros. See the ternary-treap branch.

Quoted 3 lines

 $(VCSSVN_OBJS): \
-       vcs-svn/obj_pool.h
+       vcs-svn/obj_pool.h vcs-svn/trp.h

Interesting how you've shown this in every patch :)

Quoted 5 lines

+/*
+ * Fibonacci hash function.
+ * The multiplier is the nearest prime to (2^32 times (√5 - 1)/2).
+ * See Knuth §6.4: volume 3, 3rd ed, p518.
+ */

Um, is it alright to put non-ascii characters in a file containing code? I haven't seen such a thing in any of the other files. Will some old compilers complain while parsing?

vcs-svn/trp.txt line 1

Quoted 4 lines
vcs-svn/trp.txt new file +1 -0
@@ -0,0 +1,90 @@
+treap API

The documentation is good, but I don't see it merged into the tree. Perhaps send a patch to David? Also, you might want to include the technical explanation for using treaps from the commit message here?

-- Ram

#13 lore raw

Re: [PATCH 4/9] Add treap implementation

Quoted 3 lines · Ramkumar Ramachandra

David is currently working on
a Java implementation of a immutable ternary treap and will re-implement it as C macros. See the ternary-treap branch.

I assume his blog post from a week or so ago[1] is relevant.

The trie-based version should be interesting but less generic (which is fine, since we only have two users and both use string keys).

Quoted 5 lines
Quoted 3 lines

 $(VCSSVN_OBJS): \
-       vcs-svn/obj_pool.h
+       vcs-svn/obj_pool.h vcs-svn/trp.h

Interesting how you've shown this in every patch :)

It would have been less messy to use

 $(VCSSVN_OBJS): \
	vcs-svn/obj_pool.h \
	vcs-svn/trp.h \
	... \

or

$(VCSSVN_OBJS): vcs-svn/obj_pool.h
$(VCSSVN_OBJS): vcs-svn/trp.h
...

I just can’t bring myself to care much. :)

Quoted 8 lines
Quoted 5 lines

+/*
+ * Fibonacci hash function.
+ * The multiplier is the nearest prime to (2^32 times (√5 - 1)/2).
+ * See Knuth §6.4: volume 3, 3rd ed, p518.
+ */

Um, is it alright to put non-ascii characters in a file containing code?

Yes, UTF-8 is sometimes used in comments for people’s names. See builtin/branch.c, for example.

Quoted 2 lines

The documentation is good, but I don't see it merged into the tree. Perhaps send a patch to David?

Yes. I should send some other patches, too, to minimize the delta.

Quoted 2 lines

Also, you might want to include the
technical explanation for using treaps from the commit message here?

Good idea, thanks!

Jonathan

[1] http://barrbrain.github.com/2010/06/19/relocatable-immutable-randomised-ternary-search-tree-part-2.html

#14 lore raw

PATCH v2 5/9 Add string-specific memory pool

In reply to Jonathan Nieder

From: David Barr <[email protected]>

Intern strings so they can be compared by address and stored without wasting space.

This library uses the macros in the obj_pool.h and trp.h to create a memory pool for strings and expose an API for handling them.

---
 Makefile              |    4 +-
 vcs-svn/string_pool.c |  114 +++++++++++++++++++++++++++++++++++++++++++++++++
 vcs-svn/string_pool.h |   15 ++++++
 3 files changed, 131 insertions(+), 2 deletions(-)
 create mode 100644 vcs-svn/string_pool.c
 create mode 100644 vcs-svn/string_pool.h
Makefile +2 -2
index 663a366..e11e588 100644
@@ -1740,7 +1740,7 @@ ifndef NO_CURL
 endif
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
-VCSSVN_OBJS =
+VCSSVN_OBJS = vcs-svn/string_pool.o
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)
 
 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
@@ -1864,7 +1864,7 @@ xdiff-interface.o $(XDIFF_OBJS): \
 	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
 
 $(VCSSVN_OBJS): \
-	vcs-svn/obj_pool.h vcs-svn/trp.h
+	vcs-svn/obj_pool.h vcs-svn/trp.h vcs-svn/string_pool.h
 endif
 
 exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
vcs-svn/string_pool.c new file +114 -0

114 lines not on this page · raw message

vcs-svn/string_pool.h new file +15 -0
new file mode 100644
index 0000000..085e6d7
@@ -0,0 +1,15 @@
+#ifndef STRING_POOL_H_
+#define STRING_POOL_H_
+
+#include "git-compat-util.h"
+
+uint32_t pool_intern(char *key);
+char *pool_fetch(uint32_t entry);
+uint32_t pool_tok_r(char *str, const char *delim, char **saveptr);
+void pool_print_seq(uint32_t len, uint32_t *seq, char delim, FILE *stream);
+uint32_t pool_tok_seq(uint32_t max, uint32_t *seq, char *delim, char *str);
+void pool_init(void);
+void pool_commit(void);
+void pool_reset(void);
+
+#endif
Signature · 1 line
1.7.1
Reviewed-by on v2 5/9
#15 lore raw

Re: [PATCH 5/9] Add string-specific memory pool

Hi,

Quoted 2 lines · Jonathan Nieder

Intern strings so they can be compared by address and stored without wasting space.

It's unlikely that this'll change much, if at all. It should go in without any issues. I'm not sure this is appropriate since I've already signed off, but anyway:

-- Ram

#16 lore raw

PATCH v2 6/9 Add stream helper library

In reply to Jonathan Nieder

From: David Barr <[email protected]>

This library provides thread-unsafe fgets()- and fread()-like functions where the caller does not have to supply a buffer. It maintains a couple of static buffers and provides an API to use them.

NEEDSWORK: what should buffer_copy_bytes do on error?

---
 Makefile              |    5 ++-
 vcs-svn/line_buffer.c |   93 +++++++++++++++++++++++++++++++++++++++++++++++++
 vcs-svn/line_buffer.h |   14 +++++++
 3 files changed, 110 insertions(+), 2 deletions(-)
 create mode 100644 vcs-svn/line_buffer.c
 create mode 100644 vcs-svn/line_buffer.h
Makefile +3 -2
index e11e588..8223d9b 100644
@@ -1740,7 +1740,7 @@ ifndef NO_CURL
 endif
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
-VCSSVN_OBJS = vcs-svn/string_pool.o
+VCSSVN_OBJS = vcs-svn/string_pool.o vcs-svn/line_buffer.o
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)
 
 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
@@ -1864,7 +1864,8 @@ xdiff-interface.o $(XDIFF_OBJS): \
 	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
 
 $(VCSSVN_OBJS): \
-	vcs-svn/obj_pool.h vcs-svn/trp.h vcs-svn/string_pool.h
+	vcs-svn/obj_pool.h vcs-svn/trp.h vcs-svn/string_pool.h \
+	vcs-svn/line_buffer.h
 endif
 
 exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
vcs-svn/line_buffer.c new file +93 -0

93 lines not on this page · raw message

vcs-svn/line_buffer.h new file +14 -0
new file mode 100644
index 0000000..631d1df
@@ -0,0 +1,14 @@
+#ifndef LINE_BUFFER_H_
+#define LINE_BUFFER_H_
+
+#include "git-compat-util.h"
+
+int buffer_init(const char *filename);
+int buffer_deinit(void);
+char *buffer_read_line(void);
+char *buffer_read_string(uint32_t len);
+void buffer_copy_bytes(uint32_t len);
+void buffer_skip_bytes(uint32_t len);
+void buffer_reset(void);
+
+#endif
Signature · 1 line
1.7.1
#17 lore raw

Re: [PATCH 6/9] Add stream helper library

Quoted 4 lines · Jonathan Nieder

This library provides thread-unsafe fgets()- and fread()-like functions where the caller does not have to supply a buffer.  It maintains a couple of static buffers and provides an API to use them.

Few (no?) changes since last time.
Just a quick reminder: eventually, we might be able to factor out this line_buffer thing completely; it's quite non-trivial though.

-- Ram

#18 lore raw

Re: [PATCH 6/9] Add stream helper library

Quoted 8 lines · Ramkumar Ramachandra
Quoted 4 lines · Jonathan Nieder

This library provides thread-unsafe fgets()- and fread()-like functions where the caller does not have to supply a buffer.  It maintains a couple of static buffers and provides an API to use them.

Few (no?) changes since last time.

I simplified it a bit by getting rid of pushback.

static uint32_t line_buffer_len = 0;
static uint32_t line_len = 0;

Sorry, I should have mentioned so.

Jonathan

#19 lore raw

PATCH v2 7/9 Add infrastructure to write revisions in fast-export format

In reply to Jonathan Nieder

From: David Barr <[email protected]>

repo_tree maintains the exporter's state and provides a facility to to call fast_export, which writes objects to stdout suitable for consumption by fast-import.

The exported functions roughly correspond to Subversion FS operations.

. repo_add adds a file to the current commit.

. repo_modify adds a replacement for an existing file;
it is implemented exactly the same way, but a check could be added later to distinguish the two cases.

. repo_copy copies a blob from a previous revision to the current
commit.

. repo_replace modifies the content of a file from the current
commit, if and only if it exists.

. repo_delete removes a file or directory from the current commit.

. repo_commit calls out to fast_export to write the current commit to
the fast-import stream in stdout.

. repo_diff is used by the fast_export module to write the changes
for a commit.

. repo_reset erases the exporter's state, so valgrind can be happy.

---
 Makefile              |    5 +-
 vcs-svn/fast_export.c |   75 +++++++++++
 vcs-svn/fast_export.h |   14 ++
 vcs-svn/repo_tree.c   |  335 +++++++++++++++++++++++++++++++++++++++++++++++++
 vcs-svn/repo_tree.h   |   26 ++++
 5 files changed, 453 insertions(+), 2 deletions(-)
 create mode 100644 vcs-svn/fast_export.c
 create mode 100644 vcs-svn/fast_export.h
 create mode 100644 vcs-svn/repo_tree.c
 create mode 100644 vcs-svn/repo_tree.h
Makefile +3 -2
index 8223d9b..7c66dcc 100644
@@ -1740,7 +1740,8 @@ ifndef NO_CURL
 endif
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
-VCSSVN_OBJS = vcs-svn/string_pool.o vcs-svn/line_buffer.o
+VCSSVN_OBJS = vcs-svn/string_pool.o vcs-svn/line_buffer.o \
+	vcs-svn/repo_tree.o vcs-svn/fast_export.o
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)
 
 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
@@ -1865,7 +1866,7 @@ xdiff-interface.o $(XDIFF_OBJS): \
 
 $(VCSSVN_OBJS): \
 	vcs-svn/obj_pool.h vcs-svn/trp.h vcs-svn/string_pool.h \
-	vcs-svn/line_buffer.h
+	vcs-svn/line_buffer.h vcs-svn/repo_tree.h vcs-svn/fast_export.h
 endif
 
 exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
vcs-svn/fast_export.c new file +75 -0

75 lines not on this page · raw message

vcs-svn/fast_export.h new file +14 -0
new file mode 100644
index 0000000..47e8f56
@@ -0,0 +1,14 @@
+#ifndef FAST_EXPORT_H_
+#define FAST_EXPORT_H_
+
+#include <stdint.h>
+#include <time.h>
+
+void fast_export_delete(uint32_t depth, uint32_t *path);
+void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode,
+			uint32_t mark);
+void fast_export_commit(uint32_t revision, uint32_t author, char *log,
+			uint32_t uuid, uint32_t url, unsigned long timestamp);
+void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len);
+
+#endif
vcs-svn/repo_tree.c new file +335 -0

335 lines not on this page · raw message

vcs-svn/repo_tree.h new file +26 -0
new file mode 100644
index 0000000..92a7a7b
@@ -0,0 +1,26 @@
+#ifndef REPO_TREE_H_
+#define REPO_TREE_H_
+
+#include "git-compat-util.h"
+
+#define REPO_MODE_DIR 0040000
+#define REPO_MODE_BLB 0100644
+#define REPO_MODE_EXE 0100755
+#define REPO_MODE_LNK 0120000
+
+#define REPO_MAX_PATH_LEN 4096
+#define REPO_MAX_PATH_DEPTH 1000
+
+uint32_t next_blob_mark(void);
+uint32_t repo_copy(uint32_t revision, uint32_t *src, uint32_t *dst);
+void repo_add(uint32_t *path, uint32_t mode, uint32_t blob_mark);
+uint32_t repo_replace(uint32_t *path, uint32_t blob_mark);
+void repo_modify(uint32_t *path, uint32_t mode, uint32_t blob_mark);
+void repo_delete(uint32_t *path);
+void repo_commit(uint32_t revision, uint32_t author, char *log, uint32_t uuid,
+                 uint32_t url, long unsigned timestamp);
+void repo_diff(uint32_t r1, uint32_t r2);
+void repo_init(void);
+void repo_reset(void);
+
+#endif
Signature · 1 line
1.7.1
#20 lore raw

Re: [PATCH 7/9] Add infrastructure to write revisions in fast-export format

Hi again,

Quoted 3 lines · Jonathan Nieder

repo_tree maintains the exporter's state and provides a facility to to call fast_export, which writes objects to stdout suitable for consumption by fast-import.

These files will also change significantly in a few days- see the ternary_treap branch.

Quoted 1 line

The exported functions roughly correspond to Subversion FS operations.

This description is sufficient for the commit message.

Quoted 14 lines

 . repo_add adds a file to the current commit.

 . repo_modify adds a replacement for an existing file; it is implemented exactly the same way, but a check could be added later to distinguish the two cases.

 . repo_copy copies a blob from a previous revision to the current commit.

 . repo_replace modifies the content of a file from the current commit, if and only if it exists.

 . repo_delete removes a file or directory from the current commit.

Quoted 7 lines

 . repo_commit calls out to fast_export to write the current commit to the fast-import stream in stdout.

 . repo_diff is used by the fast_export module to write the changes for a commit.

 . repo_reset erases the exporter's state, so valgrind can be happy.

This is like API documentation- should it go into the commit message? Maybe put this in a a dedicated repo_tree.txt like trp.h?

-- Ram

#21 lore raw

Re: [PATCH 7/9] Add infrastructure to write revisions in fast-export format

Quoted 2 lines · Ramkumar Ramachandra

This is like API documentation- should it go into the commit message? Maybe put this in a a dedicated repo_tree.txt like trp.h?

Good question. The answer depends on whether we want to keep it maintained.

Since this is not meant to be a general-purpose API, I thought it simplest to document it in the commit message and let future commit messages describe the purpose of future changes. We are not approaching any limit on the length of a commit object, after all.

Jonathan

#22 lore raw

Re: [PATCH 7/9] Add infrastructure to write revisions in fast-export format

In reply to Ramkumar Ramachandra
Quoted 5 lines · Ramkumar Ramachandra
Quoted 1 line · Jonathan Nieder

 . repo_reset erases the exporter's state, so valgrind can be happy.

This is like API documentation- should it go into the commit message?

A more terse summary, to save readers time:

. repo_add, repo_modify, repo_copy, repo_replace, and repo_delete
update the current commit, based roughly on the corresponding Subversion FS operation.

. repo_commit calls out to fast_export to write the current commit to
the fast-import stream in stdout.

. repo_diff is used by the fast_export module to write the changes
for a commit.

. repo_reset erases the exporter's state, so valgrind can be happy.

Jonathan

#23 lore raw

Re: [PATCH 7/9] Add infrastructure to write revisions in fast-export format

Quoted 6 lines · Jonathan Nieder

A more terse summary, to save readers time:

 . repo_add, repo_modify, repo_copy, repo_replace, and repo_delete update the current commit, based roughly on the corresponding Subversion FS operation.

Quoted 7 lines

 . repo_commit calls out to fast_export to write the current commit to the fast-import stream in stdout.

 . repo_diff is used by the fast_export module to write the changes for a commit.

 . repo_reset erases the exporter's state, so valgrind can be happy.

Looks good.

-- Ram

#24 lore raw

PATCH v2 8/9 Add SVN dump parser

In reply to Jonathan Nieder

From: David Barr <[email protected]>

svndump parses data that is in SVN dumpfile format produced by svnadmin dump with the help of line_buffer and uses repo_tree and fast_export to emit a git fast-import stream.

Based roughly on com.hydrografix.svndump 0.92 from the SvnToCCase project at <http://svn2cc.sarovar.org/>, by Stefan Hegny and others.

---
 Makefile          |    5 +-
 vcs-svn/LICENSE   |    4 +
 vcs-svn/svndump.c |  289 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 vcs-svn/svndump.h |    8 ++
 4 files changed, 304 insertions(+), 2 deletions(-)
 create mode 100644 vcs-svn/svndump.c
 create mode 100644 vcs-svn/svndump.h
Makefile +3 -2
index 7c66dcc..e7b37e0 100644
@@ -1741,7 +1741,7 @@ endif
 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o xdiff/xpatience.o
 VCSSVN_OBJS = vcs-svn/string_pool.o vcs-svn/line_buffer.o \
-	vcs-svn/repo_tree.o vcs-svn/fast_export.o
+	vcs-svn/repo_tree.o vcs-svn/fast_export.o vcs-svn/svndump.o
 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)
 
 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
@@ -1866,7 +1866,8 @@ xdiff-interface.o $(XDIFF_OBJS): \
 
 $(VCSSVN_OBJS): \
 	vcs-svn/obj_pool.h vcs-svn/trp.h vcs-svn/string_pool.h \
-	vcs-svn/line_buffer.h vcs-svn/repo_tree.h vcs-svn/fast_export.h
+	vcs-svn/line_buffer.h vcs-svn/repo_tree.h vcs-svn/fast_export.h \
+	vcs-svn/svndump.h
 endif
 
 exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
vcs-svn/LICENSE +4 -0
index a3d384c..0a5e3c4 100644
@@ -4,6 +4,10 @@ All rights reserved.
 Copyright (C) 2008 Jason Evans <[email protected]>.
 All rights reserved.
 
+Copyright (C) 2005 Stefan Hegny, hydrografix Consulting GmbH,
+Frankfurt/Main, Germany
+and others, see http://svn2cc.sarovar.org
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:
vcs-svn/svndump.c new file +289 -0

289 lines not on this page · raw message

vcs-svn/svndump.h new file +8 -0
new file mode 100644
index 0000000..38ad544
@@ -0,0 +1,8 @@
+#ifndef SVNDUMP_H_
+#define SVNDUMP_H_
+
+void svndump_init(const char *filename);
+void svndump_read(char *url);
+void svndump_reset(void);
+
+#endif
Signature · 1 line
1.7.1
Reviewed-by on v2 8/9
#25 lore raw

Re: [PATCH 8/9] Add SVN dump parser

Hi,

Quoted 3 lines · Jonathan Nieder

svndump parses data that is in SVN dumpfile format produced by svnadmin dump with the help of line_buffer and uses repo_tree and fast_export to emit a git fast-import stream.

This hasn't changed from last time, and isn't expected to change in future. Should go in without any issues, although I'd love it if we could somehow refactor the huge if-else tree. Again, I'm not sure if this is appropriate since I've already signed off:

-- Ram

#26 lore raw

PATCH v2 9/9 Add a sample user for the svndump library

In reply to Jonathan Nieder

The svn-fe tool takes a Subversion dump file as input and produces a fast-import stream as output. This can be useful as a low-level tool in building other importers, or for debugging the vcs-svn library.

make svn-fe
make svn-fe.1

to test.

NEEDSWORK: litters cwd with useless .bin files.
But I hope it is enough to show the idea.

---
Thanks for reading. Thoughts welcome.

 contrib/svn-fe/.gitignore |    3 ++
 contrib/svn-fe/Makefile   |   63 +++++++++++++++++++++++++++++++++++++++++++++
 contrib/svn-fe/svn-fe.c   |   43 ++++++++++++++++++++++++++++++
 contrib/svn-fe/svn-fe.txt |   56 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 165 insertions(+), 0 deletions(-)
 create mode 100644 contrib/svn-fe/.gitignore
 create mode 100644 contrib/svn-fe/Makefile
 create mode 100644 contrib/svn-fe/svn-fe.c
 create mode 100644 contrib/svn-fe/svn-fe.txt
contrib/svn-fe/.gitignore new file +3 -0
new file mode 100644
index 0000000..27a33b6
@@ -0,0 +1,3 @@
+/*.xml
+/*.1
+/*.html
contrib/svn-fe/Makefile new file +63 -0

63 lines not on this page · raw message

contrib/svn-fe/svn-fe.c new file +43 -0

43 lines not on this page · raw message

contrib/svn-fe/svn-fe.txt new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.7.1
#27 lore raw

Re: [PATCH 9/9] Add a sample user for the svndump library

Hi Jonathan,

Quoted 2 lines · Jonathan Nieder

NEEDSWORK: litters cwd with useless .bin files.
But I hope it is enough to show the idea.

How do you propose we solve this? Maybe using a generic $TEMP_DIRECTORY like /tmp in Unix and then getting rid of the files after the export is complete?

contrib/svn-fe/Makefile line 34

Quoted 12 lines
contrib/svn-fe/Makefile new file +11 -0
+QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
+QUIET_SUBDIR1 =
 
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifndef V
+       QUIET_CC      = @echo '   ' CC $@;
+       QUIET_LINK    = @echo '   ' LINK $@;
+       QUIET_SUBDIR0 = +@subdir=
+       QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
+                       $(MAKE) $(PRINT_DIR) -C $$subdir
+endif
+endif

I saw this in the Git Makefile too, but I didn't understand the logic behind it. Could you explain it to me?
Note: I couldn't understand most of the Makefile, so I just skipped it when I found similar declarations in the Git Makefile.

contrib/svn-fe/svn-fe.c line 7

Quoted 13 lines
contrib/svn-fe/svn-fe.c new file +7 -0
new file mode 100644
index 0000000..d84dd4f
@@ -0,0 +1,43 @@
+/*
+ * Parse and rearrange a svnadmin dump.
+ * Create the dump with:
+ * svnadmin dump --incremental -r<startrev>:<endrev> <repository> >outfile
+ *
+ * Copyright (C) 2010 David Barr <[email protected]>.
+ * All rights reserved.

That's a huge license header applies just to the trivial five-line program, right? Is it necessary at all?

contrib/svn-fe/svn-fe.c line 35

Quoted 2 lines
contrib/svn-fe/svn-fe.c new file +2 -0
+#include <stdlib.h>
+#include "../../vcs-svn/svndump.h"

Inelegant. Why not include ../../vcs-svn in the path you're searching for headers?

contrib/svn-fe/svn-fe.c line 10

Quoted 1 line
contrib/svn-fe/svn-fe.c new file +1 -0
+svnadmin dump --incremental REPO | svn-fe [url] | git fast-import

If the user doesn't have a clue about SVN, they won't know what REPO is here: Without knowing anything about svnadmin, I'd naively try it with a remote repository. Maybe include a note about having to mirror a complete repository locally using svnsync (or otherwise) first?

contrib/svn-fe/svn-fe.c line 12

Quoted 2 lines
contrib/svn-fe/svn-fe.c new file +2 -0
+Converts a textual representation of a Subversion repository into
+input suitable for git-fast-import(1) and similar importers.

To be more specific, "Subversion dumpfile (version: 2)" from FILE(1).

-- Ram

#28 lore raw

Re: [PATCH 9/9] Add a sample user for the svndump library

Quoted 6 lines · Ramkumar Ramachandra
Quoted 2 lines · Jonathan Nieder

NEEDSWORK: litters cwd with useless .bin files.
But I hope it is enough to show the idea.

How do you propose we solve this?

Turn off persistence until it is ready. At that point, we will need to access the target git repo anyway, so we can keep extra metadata in the .git directory.

Quoted 15 lines

contrib/svn-fe/Makefile line 34

Quoted 12 lines
contrib/svn-fe/Makefile new file +11 -0
+QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
+QUIET_SUBDIR1 =
 
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifndef V
+       QUIET_CC      = @echo '   ' CC $@;
+       QUIET_LINK    = @echo '   ' LINK $@;
+       QUIET_SUBDIR0 = +@subdir=
+       QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
+                       $(MAKE) $(PRINT_DIR) -C $$subdir
+endif
+endif

I saw this in the Git Makefile too, but I didn't understand the logic behind it. Could you explain it to me?

See commit 74f2b2a.

Summary: this produces the

CC foo.o

lines. The idea is that long command lines distract from what is more important, which is the compiler output. The behavior can be turned off with “make V=1” or “make -s”.

Quoted 8 lines
Quoted 8 lines
contrib/svn-fe/svn-fe.c new file +2 -0
new file mode 100644
index 0000000..d84dd4f
@@ -0,0 +1,43 @@
+/*
+ * Parse and rearrange a svnadmin dump.
Quoted 8 lines

contrib/svn-fe/svn-fe.c line 7

Quoted 5 lines
contrib/svn-fe/svn-fe.c new file +5 -0
+ * Create the dump with:
+ * svnadmin dump --incremental -r<startrev>:<endrev> <repository> >outfile
+ *
+ * Copyright (C) 2010 David Barr <[email protected]>.
+ * All rights reserved.

That's a huge license header applies just to the trivial five-line program, right? Is it necessary at all?

I dunno. I included the license header instead of refering to LICENSE because this file tends to be installed in /usr/share/doc/git/contrib and LICENSE does not.

Maybe the file should get a simpler license? e.g.:

This file is in the public domain.
You may freely use, modify, distribute, and relicense it.

Quoted 5 lines

contrib/svn-fe/svn-fe.c line 35

Quoted 2 lines
contrib/svn-fe/svn-fe.c new file +2 -0
+#include <stdlib.h>
+#include "../../vcs-svn/svndump.h"

Inelegant. Why not include ../../vcs-svn in the path you're searching for headers?

Right, this should be changed to

#include <stdlib.h>
#include "vcs-svn/svndump.h"

Quoted 6 lines

contrib/svn-fe/svn-fe.c line 10

Quoted 1 line
contrib/svn-fe/svn-fe.c new file +1 -0
+svnadmin dump --incremental REPO | svn-fe [url] | git fast-import

If the user doesn't have a clue about SVN, they won't know what REPO is here: Without knowing anything about svnadmin, I'd naively try it with a remote repository. Maybe include a note about having to mirror a complete repository locally using svnsync (or otherwise) first?

Sounds reasonable. Care to suggest wording?

Quoted 4 lines

contrib/svn-fe/svn-fe.c line 12

Quoted 2 lines
contrib/svn-fe/svn-fe.c new file +2 -0
+Converts a textual representation of a Subversion repository into
+input suitable for git-fast-import(1) and similar importers.

To be more specific, "Subversion dumpfile (version: 2)" from FILE(1).

Do version 3 dumpfiles fail?

Jonathan

#29 lore raw

Re: [PATCH 9/9] Add a sample user for the svndump library

Hi again,

Quoted 3 lines · Jonathan Nieder

Turn off persistence until it is ready.  At that point, we will need to access the target git repo anyway, so we can keep extra metadata in the .git directory.

Unfortunately, turning off persistence isn't so easy now because the branch has been merged into master now, and it's difficult to sort out just the commits that correspond to persistence and rebase. Yes, the remote helper can use the .git directory, but I thought we wanted to keep this in contrib/ even after the remote helper is merged?

Quoted 9 lines

See commit 74f2b2a.

Summary: this produces the

   CC foo.o

lines.  The idea is that long command lines distract from what is more important, which is the compiler output.  The behavior can be turned off with “make V=1” or “make -s”.

Ah. Black magic :)

Quoted 4 lines

Maybe the file should get a simpler license?  e.g.:

 This file is in the public domain.
 You may freely use, modify, distribute, and relicense it.

Yes, I like this.

Quoted 1 line

Sounds reasonable.  Care to suggest wording?

Something along "REPO is a path to a Subversion repository mirrored on the local disk. Remote Subversion repositories can be mirrored on local disk using the svnsync command."

Quoted 1 line

Do version 3 dumpfiles fail?

Yes, they do. We aren't parsing the extra headers anywhere, and deltified dumps aren't supported.

-- Ram

#30 lore raw

Re: [PATCH 9/9] Add a sample user for the svndump library

Quoted 1 line · Ramkumar Ramachandra

Unfortunately, turning off persistence isn't so easy now

Hmm, couldn’t one just leave out some pool_init() calls?

Of course, that would make pool_init() and related functionality unused, and we may or may not want to remove it while at it.

Quoted 3 lines

Yes, the remote helper can use the .git directory, but I thought we wanted to keep this in contrib/ even after the remote helper is merged?

For incremental imports, I suspect the standalone svn-fe is going to need to invoke ‘git fast-import’ itself, which implies knowledge of the location of the .git directory.

For undeltified nonincremental imports, there is no problem. :)

Quoted 8 lines
Quoted 4 lines · Jonathan Nieder

Maybe the file should get a simpler license?  e.g.:

 This file is in the public domain.
 You may freely use, modify, distribute, and relicense it.

Yes, I like this.

David, would this be okay? (for the short svn-fe.c file only)

Quoted 4 lines
Quoted 1 line

Do version 3 dumpfiles fail?

Yes, they do. We aren't parsing the extra headers anywhere, and deltified dumps aren't supported.

Worth documenting indeed.

Thanks again.

#32 lore raw
In reply to Jonathan Nieder

(+CC: Junio)

Hi Jonathan,

Quoted 4 lines · Jonathan Nieder

Ram last sent this series a couple of weeks ago[1], and it was merged to pu then as rr/svn-export.  Here’s another iteration of the same for discussion, now including David Barr’s program that demonstrates the functionality.

There's a lot of work happening in the exporter and the series will probably need to be re-rolled again: I recommend the following.
1. Review this series thoroughly, but don't actually merge it because it's going to be re-rolled soon.
2. Split the series in two: The infrastructure part in vcs-svn/ will be re-rolled later. Another part for contrib/ should be made into a separate series and merged.
3. As soon as the client is complete, I'll roll a series that puts it in vcs-svn/ (infrastructure again).
4. Finally, I'll roll out a series for the remote helper itself that puts it in $GIT_ROOT.

To summarize, there should be four series:
1. David's exporter in vcs-svn/ (yet to be re-rolled): Either Jonathan or I will handle this.
2. David's independent svn-fe program in contrib/: Jonathan will handle this.
3. The RA client to generate a full-text dumpfile on-the-fly: This isn't done yet; as soon as it's finished, I'll roll a series.
4. The remote helper: This done, but it doesn't make sense to send this in before everything else has been merged.

-- Ram

#33 lore raw
Quoted 4 lines · Ramkumar Ramachandra

There's a lot of work happening in the exporter and the series will probably need to be re-rolled again: I recommend the following.
1. Review this series thoroughly, but don't actually merge it because it's going to be re-rolled soon.

To be more specific: although svndump.c, fast_export.c, and repo_tree.c may need to be a bit slushy now while we figure out the incremental import story, the rest of the series is not likely to change much in broad strokes. I get the impression that facilities like strbuf and string_list benefit greatly from early review, so in particular let me mention the facilities this series adds:

. obj_pool, an array of fixed-size records that can be written to
disk. This is just begging to be implemented with mmap; maybe in the future the compat/mmap.c shim can be tweaked to support faking it.

. treap, a multiset datastructure built on top of obj_pool. I
suspect API cleanups would be welcome here: it’s a bit more unwieldly than string_list at the moment.

. string_pool, a collection of interned strings built on top of
treap.

. line_buffer, a simple fread()/fgets() wrapper with a static buffer.

I would find feedback on these (or patches :)) especially welcome.

Jonathan

#34 lore raw
In reply to Ramkumar Ramachandra
Quoted 3 lines · Ramkumar Ramachandra

I'm in favor of the split mainly because it doesn't make sense to re-roll your contrib/ patch everytime the infrastructure in vcs-svn/ changes

[...]

Quoted 2 lines

I want to get the contrib/ patch in so people can test the infrastructure everytime it's re-rolled and goes to pu.

Yes, I agree: ideally this should be two branches:

rr/svn-export for infrastructure
xx/svn-fe for the frontend

with the latter based on the former.

#31 lore raw

Re: [PATCH 9/9] Add a sample user for the svndump library

In reply to Jonathan Nieder

contrib/svn-fe/svn-fe.txt line 44

Quoted 3 lines · Jonathan Nieder
contrib/svn-fe/svn-fe.txt new file +3 -0
+To support incremental imports, 'svn-fe' will put a `git-svn-id`
+line at the end of each commit log message if passed an url on the
+command line.  This line has the form `git-svn-id: URL@REVNO UUID`.

If you are importing from an svk mirror or svnsync mirror, it will be required to rewrite this portion.

Quoted 1 line

+Empty directories and unknown properties are silently discarded.

Yeah. These should probably be carried over in this pass. Revision properties could possibly be converted to extra RFC822-style headers in the commit message. Directory properties can go under $dir/.svnfe-props (use an empty file to mark empty directories) and $filename.svnfe-props
- it is up to the data mining phase whether it wants to actually do anything with that data later.

Sam