Skip to content

Commit

Permalink
SVN dump parser
Browse files Browse the repository at this point in the history
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.

[rr: allow input from files other than stdin]
[jn: with test, more error reporting]

Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
barrbrain authored and gitster committed Aug 15, 2010
1 parent c0e6c23 commit 21746aa
Show file tree
Hide file tree
Showing 8 changed files with 372 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -175,6 +175,7 @@
/test-sha1
/test-sigchain
/test-string-pool
/test-svn-fe
/test-treap
/common-cmds.h
*.tar.gz
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Expand Up @@ -417,6 +417,7 @@ TEST_PROGRAMS_NEED_X += test-run-command
TEST_PROGRAMS_NEED_X += test-sha1
TEST_PROGRAMS_NEED_X += test-sigchain
TEST_PROGRAMS_NEED_X += test-string-pool
TEST_PROGRAMS_NEED_X += test-svn-fe
TEST_PROGRAMS_NEED_X += test-treap
TEST_PROGRAMS_NEED_X += test-index-version

Expand Down Expand Up @@ -1745,7 +1746,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)
Expand Down Expand Up @@ -1871,7 +1872,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 = \
Expand Down Expand Up @@ -2026,6 +2028,8 @@ test-parse-options$X: parse-options.o

test-string-pool$X: vcs-svn/lib.a

test-svn-fe$X: vcs-svn/lib.a

.PRECIOUS: $(TEST_OBJS)

test-%$X: test-%.o $(GITLIBS)
Expand Down
1 change: 1 addition & 0 deletions contrib/svn-fe/svn-fe.c
Expand Up @@ -10,6 +10,7 @@ int main(int argc, char **argv)
{
svndump_init(NULL);
svndump_read((argc > 1) ? argv[1] : NULL);
svndump_deinit();
svndump_reset();
return 0;
}
32 changes: 32 additions & 0 deletions t/t9010-svn-fe.sh
@@ -0,0 +1,32 @@
#!/bin/sh

test_description='check svn dumpfile importer'

. ./lib-git-svn.sh

test_dump() {
label=$1
dump=$2
test_expect_success "$dump" '
svnadmin create "$label-svn" &&
svnadmin load "$label-svn" < "$TEST_DIRECTORY/$dump" &&
svn_cmd export "file://$(pwd)/$label-svn" "$label-svnco" &&
git init "$label-git" &&
test-svn-fe "$TEST_DIRECTORY/$dump" >"$label.fe" &&
(
cd "$label-git" &&
git fast-import < ../"$label.fe"
) &&
(
cd "$label-svnco" &&
git init &&
git add . &&
git fetch "../$label-git" master &&
git diff --exit-code FETCH_HEAD
)
'
}

test_dump simple t9111/svnsync.dump

test_done
17 changes: 17 additions & 0 deletions test-svn-fe.c
@@ -0,0 +1,17 @@
/*
* test-svn-fe: Code to exercise the svn import lib
*/

#include "git-compat-util.h"
#include "vcs-svn/svndump.h"

int main(int argc, char *argv[])
{
if (argc != 2)
usage("test-svn-fe <file>");
svndump_init(argv[1]);
svndump_read(NULL);
svndump_deinit();
svndump_reset();
return 0;
}
4 changes: 4 additions & 0 deletions vcs-svn/LICENSE
Expand Up @@ -4,6 +4,10 @@ All rights reserved.
Copyright (C) 2008 Jason Evans <jasone@canonware.com>.
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:
Expand Down

0 comments on commit 21746aa

Please sign in to comment.