Skip to content

Commit bf9b46c

Browse files
committed
Merge branch 'jn/svn-fe' (early part)
* 'jn/svn-fe' (early part): vcs-svn: Error out for v3 dumps Conflicts: t/t9010-svn-fe.sh
2 parents d3cae60 + b3e5bce commit bf9b46c

File tree

2 files changed

+47
-25
lines changed

2 files changed

+47
-25
lines changed

t/t9010-svn-fe.sh

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,44 @@ svn_cmd () {
2020
svn "$subcommand" --config-dir "$svnconf" "$@"
2121
}
2222

23-
test_dump () {
24-
label=$1
25-
dump=$2
26-
test_expect_success "$dump" '
27-
svnadmin create "$label-svn" &&
28-
svnadmin load "$label-svn" < "$TEST_DIRECTORY/$dump" &&
29-
svn_cmd export "file://$PWD/$label-svn" "$label-svnco" &&
30-
git init "$label-git" &&
31-
test-svn-fe "$TEST_DIRECTORY/$dump" >"$label.fe" &&
32-
(
33-
cd "$label-git" &&
34-
git fast-import < ../"$label.fe"
35-
) &&
36-
(
37-
cd "$label-svnco" &&
38-
git init &&
39-
git add . &&
40-
git fetch "../$label-git" master &&
41-
git diff --exit-code FETCH_HEAD
42-
)
43-
'
23+
reinit_git () {
24+
rm -fr .git &&
25+
git init
4426
}
4527

46-
test_dump simple t9135/svn.dump
28+
>empty
29+
30+
test_expect_success 'empty dump' '
31+
reinit_git &&
32+
echo "SVN-fs-dump-format-version: 2" >input &&
33+
test-svn-fe input >stream &&
34+
git fast-import <stream
35+
'
36+
37+
test_expect_success 'v3 dumps not supported' '
38+
reinit_git &&
39+
echo "SVN-fs-dump-format-version: 3" >input &&
40+
test_must_fail test-svn-fe input >stream &&
41+
test_cmp empty stream
42+
'
43+
44+
test_expect_success 't9135/svn.dump' '
45+
svnadmin create simple-svn &&
46+
svnadmin load simple-svn <"$TEST_DIRECTORY/t9135/svn.dump" &&
47+
svn_cmd export "file://$PWD/simple-svn" simple-svnco &&
48+
git init simple-git &&
49+
test-svn-fe "$TEST_DIRECTORY/t9135/svn.dump" >simple.fe &&
50+
(
51+
cd simple-git &&
52+
git fast-import <../simple.fe
53+
) &&
54+
(
55+
cd simple-svnco &&
56+
git init &&
57+
git add . &&
58+
git fetch ../simple-git master &&
59+
git diff --exit-code FETCH_HEAD
60+
)
61+
'
4762

4863
test_done

vcs-svn/svndump.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ static struct {
5151
} rev_ctx;
5252

5353
static struct {
54-
uint32_t uuid, url;
54+
uint32_t version, uuid, url;
5555
} dump_ctx;
5656

5757
static struct {
5858
uint32_t svn_log, svn_author, svn_date, svn_executable, svn_special, uuid,
5959
revision_number, node_path, node_kind, node_action,
6060
node_copyfrom_path, node_copyfrom_rev, text_content_length,
61-
prop_content_length, content_length;
61+
prop_content_length, content_length, svn_fs_dump_format_version;
6262
} keys;
6363

6464
static void reset_node_ctx(char *fname)
@@ -85,6 +85,7 @@ static void reset_rev_ctx(uint32_t revision)
8585
static void reset_dump_ctx(uint32_t url)
8686
{
8787
dump_ctx.url = url;
88+
dump_ctx.version = 1;
8889
dump_ctx.uuid = ~0;
8990
}
9091

@@ -105,6 +106,7 @@ static void init_keys(void)
105106
keys.text_content_length = pool_intern("Text-content-length");
106107
keys.prop_content_length = pool_intern("Prop-content-length");
107108
keys.content_length = pool_intern("Content-length");
109+
keys.svn_fs_dump_format_version = pool_intern("SVN-fs-dump-format-version");
108110
}
109111

110112
static void read_props(void)
@@ -206,7 +208,12 @@ void svndump_read(const char *url)
206208
*val++ = '\0';
207209
key = pool_intern(t);
208210

209-
if (key == keys.uuid) {
211+
if (key == keys.svn_fs_dump_format_version) {
212+
dump_ctx.version = atoi(val);
213+
if (dump_ctx.version > 2)
214+
die("expected svn dump format version <= 2, found %d",
215+
dump_ctx.version);
216+
} else if (key == keys.uuid) {
210217
dump_ctx.uuid = pool_intern(val);
211218
} else if (key == keys.revision_number) {
212219
if (active_ctx == NODE_CTX)

0 commit comments

Comments
 (0)