git-svn: Always create a new RA when calling do_switch for svn://
Not doing so caused the "Malformed network data" error when a directoy was deleted and replaced with a copy from an older version. Signed-off-by: Alec Berryman <alec@thened.net> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alec Berryman committed
Sep 14, 2008 at 17:14 UTC
ad0a82bae0e08819520ab7442dd3a7eb7532bbe6
3 files changed
+235
-13
git-svn.perl
+12
-13
@@ -3969,20 +3969,19 @@ sub gs_do_switch {
3969
my $old_url = $full_url;
3970
$full_url .= '/' . escape_uri_only($path) if length $path;
3971
my ($ra, $reparented);
3972
- if ($old_url ne $full_url) {
3973
- if ($old_url !~ m#^svn(\+ssh)?://#) {
3974
- SVN::_Ra::svn_ra_reparent($self->{session}, $full_url,
3975
- $pool);
3976
- $self->{url} = $full_url;
3977
- $reparented = 1;
3978
- } else {
3979
- $_[0] = undef;
3980
- $self = undef;
3981
- $RA = undef;
3982
- $ra = Git::SVN::Ra->new($full_url);
3983
- $ra_invalid = 1;
3984
- }
3972
+
3973
+ if ($old_url =~ m#^svn(\+ssh)?://#) {
3974
+ $_[0] = undef;
3975
+ $self = undef;
3976
+ $RA = undef;
3977
+ $ra = Git::SVN::Ra->new($full_url);
3978
+ $ra_invalid = 1;
3979
+ } elsif ($old_url ne $full_url) {
3980
+ SVN::_Ra::svn_ra_reparent($self->{session}, $full_url, $pool);
3981
+ $self->{url} = $full_url;
3982
+ $reparented = 1;
3983
}
3984
+
3985
$ra ||= $self;
3986
my $reporter = $ra->do_switch($rev_b, '', 1, $url_b, $editor, $pool);
3987
my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
t/t9126-git-svn-follow-deleted-readded-directory.sh
new
+22
@@ -0,0 +1,22 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2008 Alec Berryman
4
+
5
+test_description='git svn fetch repository with deleted and readded directory'
6
+
7
+. ./lib-git-svn.sh
8
+
9
+# Don't run this by default; it opens up a port.
10
+require_svnserve
11
+
12
+test_expect_success 'load repository' '
13
+ svnadmin load -q "$rawsvnrepo" < "$TEST_DIRECTORY"/t9126/follow-deleted-readded.dump
14
+ '
15
+
16
+test_expect_success 'fetch repository' '
17
+ start_svnserve &&
18
+ git svn init svn://127.0.0.1:$SVNSERVE_PORT &&
19
+ git svn fetch
20
+ '
21
+
22
+test_done
t/t9126/follow-deleted-readded.dump
new
+201
@@ -0,0 +1,201 @@
1
+SVN-fs-dump-format-version: 2
2
+
3
+UUID: 1807dc6f-c693-4cda-9710-00e1be8c1f21
4
+
5
+Revision-number: 0
6
+Prop-content-length: 56
7
+Content-length: 56
8
+
9
+K 8
10
+svn:date
11
+V 27
12
+2008-09-14T19:53:13.006748Z
13
+PROPS-END
14
+
15
+Revision-number: 1
16
+Prop-content-length: 111
17
+Content-length: 111
18
+
19
+K 7
20
+svn:log
21
+V 12
22
+Create trunk
23
+K 10
24
+svn:author
25
+V 4
26
+alec
27
+K 8
28
+svn:date
29
+V 27
30
+2008-09-14T19:53:13.239689Z
31
+PROPS-END
32
+
33
+Node-path: trunk
34
+Node-kind: dir
35
+Node-action: add
36
+Prop-content-length: 10
37
+Content-length: 10
38
+
39
+PROPS-END
40
+
41
+
42
+Revision-number: 2
43
+Prop-content-length: 119
44
+Content-length: 119
45
+
46
+K 7
47
+svn:log
48
+V 20
49
+Create trunk/project
50
+K 10
51
+svn:author
52
+V 4
53
+alec
54
+K 8
55
+svn:date
56
+V 27
57
+2008-09-14T19:53:13.548860Z
58
+PROPS-END
59
+
60
+Node-path: trunk/project
61
+Node-kind: dir
62
+Node-action: add
63
+Prop-content-length: 10
64
+Content-length: 10
65
+
66
+PROPS-END
67
+
68
+
69
+Revision-number: 3
70
+Prop-content-length: 111
71
+Content-length: 111
72
+
73
+K 7
74
+svn:log
75
+V 12
76
+add new file
77
+K 10
78
+svn:author
79
+V 4
80
+alec
81
+K 8
82
+svn:date
83
+V 27
84
+2008-09-14T19:53:15.433630Z
85
+PROPS-END
86
+
87
+Node-path: trunk/project/foo
88
+Node-kind: file
89
+Node-action: add
90
+Prop-content-length: 10
91
+Text-content-length: 4
92
+Text-content-md5: d3b07384d113edec49eaa6238ad5ff00
93
+Content-length: 14
94
+
95
+PROPS-END
96
+foo
97
+
98
+
99
+Revision-number: 4
100
+Prop-content-length: 116
101
+Content-length: 116
102
+
103
+K 7
104
+svn:log
105
+V 17
106
+change foo to bar
107
+K 10
108
+svn:author
109
+V 4
110
+alec
111
+K 8
112
+svn:date
113
+V 27
114
+2008-09-14T19:53:17.339884Z
115
+PROPS-END
116
+
117
+Node-path: trunk/project/foo
118
+Node-kind: file
119
+Node-action: change
120
+Text-content-length: 4
121
+Text-content-md5: c157a79031e1c40f85931829bc5fc552
122
+Content-length: 4
123
+
124
+bar
125
+
126
+
127
+Revision-number: 5
128
+Prop-content-length: 114
129
+Content-length: 114
130
+
131
+K 7
132
+svn:log
133
+V 15
134
+don't like that
135
+K 10
136
+svn:author
137
+V 4
138
+alec
139
+K 8
140
+svn:date
141
+V 27
142
+2008-09-14T19:53:19.335001Z
143
+PROPS-END
144
+
145
+Node-path: trunk/project
146
+Node-action: delete
147
+
148
+
149
+Revision-number: 6
150
+Prop-content-length: 110
151
+Content-length: 110
152
+
153
+K 7
154
+svn:log
155
+V 11
156
+reset trunk
157
+K 10
158
+svn:author
159
+V 4
160
+alec
161
+K 8
162
+svn:date
163
+V 27
164
+2008-09-14T19:53:19.845897Z
165
+PROPS-END
166
+
167
+Node-path: trunk/project
168
+Node-kind: dir
169
+Node-action: add
170
+Node-copyfrom-rev: 4
171
+Node-copyfrom-path: trunk/project
172
+
173
+
174
+Revision-number: 7
175
+Prop-content-length: 113
176
+Content-length: 113
177
+
178
+K 7
179
+svn:log
180
+V 14
181
+change to quux
182
+K 10
183
+svn:author
184
+V 4
185
+alec
186
+K 8
187
+svn:date
188
+V 27
189
+2008-09-14T19:53:21.367947Z
190
+PROPS-END
191
+
192
+Node-path: trunk/project/foo
193
+Node-kind: file
194
+Node-action: change
195
+Text-content-length: 5
196
+Text-content-md5: d3b07a382ec010c01889250fce66fb13
197
+Content-length: 5
198
+
199
+quux
200
+
201
+