@matheusbsbs / matheus-bagliano / commits / 462e1f51a5
Fork 0

vcs-svn: Use mark to indicate nodes with included text

Allocate a mark if needed as soon as possible so later code can use "if (mark)" to check if this node has text attached rather than explicitly checking for Text-content-length. While at it, reject directory nodes with text attached; the presence of such a node would indicate a bug in the dump generator or svn-fe's understanding. In the long term, it would be nice to be able to continue parsing and save the error for later, but for now it is simpler to error out right away. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Nov 19, 2010 at 18:48 UTC 462e1f51a5648ce9d7ca26d44ed86327c454889a
1 file changed +8 -8
vcs-svn/svndump.c
+8 -8
@@ -156,15 +156,17 @@ static void handle_node(void)
156 if (node_ctx.text_delta || node_ctx.prop_delta)
157 die("text and property deltas not supported");
158
159 + if (node_ctx.textLength != LENGTH_UNKNOWN)
160 + mark = next_blob_mark();
161 +
162 if (have_props && node_ctx.propLength)
163 read_props();
164
165 if (node_ctx.srcRev)
166 old_mode = repo_copy(node_ctx.srcRev, node_ctx.src, node_ctx.dst);
167
165 - if (node_ctx.textLength != LENGTH_UNKNOWN &&
166 - node_ctx.type != REPO_MODE_DIR)
167 - mark = next_blob_mark();
168 + if (mark && node_ctx.type == REPO_MODE_DIR)
169 + die("invalid dump: directories cannot have text attached");
170
171 if (node_ctx.action == NODEACT_DELETE) {
172 repo_delete(node_ctx.dst);
@@ -175,15 +177,15 @@ static void handle_node(void)
177 repo_replace(node_ctx.dst, mark);
178 else if (have_props)
179 repo_modify(node_ctx.dst, node_ctx.type, mark);
178 - else if (node_ctx.textLength != LENGTH_UNKNOWN)
180 + else if (mark)
181 old_mode = repo_replace(node_ctx.dst, mark);
182 } else if (node_ctx.action == NODEACT_ADD) {
183 if (node_ctx.srcRev && have_props)
184 repo_modify(node_ctx.dst, node_ctx.type, mark);
183 - else if (node_ctx.srcRev && node_ctx.textLength != LENGTH_UNKNOWN)
185 + else if (node_ctx.srcRev && mark)
186 old_mode = repo_replace(node_ctx.dst, mark);
187 else if ((node_ctx.type == REPO_MODE_DIR && !node_ctx.srcRev) ||
186 - node_ctx.textLength != LENGTH_UNKNOWN)
188 + mark)
189 repo_add(node_ctx.dst, node_ctx.type, mark);
190 }
191
@@ -192,8 +194,6 @@ static void handle_node(void)
194
195 if (mark)
196 fast_export_blob(node_ctx.type, mark, node_ctx.textLength);
195 - else if (node_ctx.textLength != LENGTH_UNKNOWN)
196 - buffer_skip_bytes(node_ctx.textLength);
197 }
198
199 static void handle_revision(void)