@matheusbsbs / matheus-bagliano / commits / 5a38b186d3
Fork 0

vcs-svn: handle_node: use repo_read_path

svn-fe processes each commit in two stages: first decide on the correct content for all paths and export the relevant blobs, then export a commit with the result. But we can keep less state and simplify svn-fe a great deal by exporting the commit in one step: use 'inline' blobs for each path and remember nothing. This way, the repo_tree structure could be eliminated, and we would get support for incremental imports 'for free'. Reorganize handle_node along these lines. This is just a code cleanup; the changes in repo_tree and handle_revision will come later. [db: backported to apply without text delta support] Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: David Barr <david.barr@cordelta.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

Jonathan Nieder committed Dec 10, 2010 at 04:28 UTC 5a38b186d3ac5840d6ae78511d6dccab8367f242
1 file changed +23 -10
vcs-svn/svndump.c
+23 -10
@@ -201,13 +201,14 @@ static void handle_node(void)
201 uint32_t mark = 0;
202 const uint32_t type = node_ctx.type;
203 const int have_props = node_ctx.propLength != LENGTH_UNKNOWN;
204 + const int have_text = node_ctx.textLength != LENGTH_UNKNOWN;
205
206 if (node_ctx.text_delta)
207 die("text deltas not supported");
207 - if (node_ctx.textLength != LENGTH_UNKNOWN)
208 + if (have_text)
209 mark = next_blob_mark();
210 if (node_ctx.action == NODEACT_DELETE) {
210 - if (mark || have_props || node_ctx.srcRev)
211 + if (have_text || have_props || node_ctx.srcRev)
212 die("invalid dump: deletion node has "
213 "copyfrom info, text, or properties");
214 return repo_delete(node_ctx.dst);
@@ -221,13 +222,20 @@ static void handle_node(void)
222 if (node_ctx.action == NODEACT_ADD)
223 node_ctx.action = NODEACT_CHANGE;
224 }
224 - if (mark && type == REPO_MODE_DIR)
225 + if (have_text && type == REPO_MODE_DIR)
226 die("invalid dump: directories cannot have text attached");
227 +
228 + /*
229 + * Decide on the new content (mark) and mode (node_ctx.type).
230 + */
231 if (node_ctx.action == NODEACT_CHANGE && !~*node_ctx.dst) {
232 if (type != REPO_MODE_DIR)
233 die("invalid dump: root of tree is not a regular file");
234 } else if (node_ctx.action == NODEACT_CHANGE) {
230 - uint32_t mode = repo_modify_path(node_ctx.dst, 0, mark);
235 + uint32_t mode;
236 + if (!have_text)
237 + mark = repo_read_path(node_ctx.dst);
238 + mode = repo_modify_path(node_ctx.dst, 0, 0);
239 if (!mode)
240 die("invalid dump: path to be modified is missing");
241 if (mode == REPO_MODE_DIR && type != REPO_MODE_DIR)
@@ -236,22 +244,27 @@ static void handle_node(void)
244 die("invalid dump: cannot modify a file into a directory");
245 node_ctx.type = mode;
246 } else if (node_ctx.action == NODEACT_ADD) {
239 - if (!mark && type != REPO_MODE_DIR)
247 + if (!have_text && type != REPO_MODE_DIR)
248 die("invalid dump: adds node without text");
241 - repo_add(node_ctx.dst, type, mark);
249 } else {
250 die("invalid dump: Node-path block lacks Node-action");
251 }
252 +
253 + /*
254 + * Adjust mode to reflect properties.
255 + */
256 if (have_props) {
246 - const uint32_t old_mode = node_ctx.type;
257 if (!node_ctx.prop_delta)
258 node_ctx.type = type;
259 if (node_ctx.propLength)
260 read_props();
251 - if (node_ctx.type != old_mode)
252 - repo_modify_path(node_ctx.dst, node_ctx.type, mark);
261 }
254 - if (mark)
262 +
263 + /*
264 + * Save the result.
265 + */
266 + repo_add(node_ctx.dst, node_ctx.type, mark);
267 + if (have_text)
268 fast_export_blob(node_ctx.type, mark,
269 node_ctx.textLength, &input);
270 }