@matheusbsbs / matheus-bagliano / commits / 1c7bb31616
Fork 0

vcs-svn: Delay read of per-path properties

The mode for each file in an svn-format dump is kept in the properties section. The properties section is read as soon as possible to allow the correct mode to be filled in when registering the file with the repo_tree lib. To support nodes with a missing properties section, svn-fe determines the mode in three stages: - The kind (directory or file) of the node is read from the dump and used to make an initial estimate (040000 or 100644). - Properties are read in and allowed to override this for symlinks and executables. - If there is no properties section, the mode from the previous content of the path is left alone, overriding the above considerations. This is a bit of a mess, and worse, it would get even more complicated once we start to support property deltas. If we could only register the file with a provisional value for mode and then change it later when properties say so, the procedure would be much simpler. ... oh, right, we can. 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:52 UTC 1c7bb316169c700df0d1711555564f86c9cb9366
1 file changed +18 -22
vcs-svn/svndump.c
+18 -22
@@ -150,7 +150,8 @@ static void read_props(void)
150
151 static void handle_node(void)
152 {
153 - uint32_t old_mode = 0, mark = 0;
153 + uint32_t mark = 0;
154 + const uint32_t type = node_ctx.type;
155 const int have_props = node_ctx.propLength != LENGTH_UNKNOWN;
156
157 if (node_ctx.text_delta || node_ctx.prop_delta)
@@ -171,33 +172,28 @@ static void handle_node(void)
172 node_ctx.action = NODEACT_ADD;
173 }
174
174 - if (have_props && node_ctx.propLength)
175 - read_props();
176 -
177 - if (node_ctx.srcRev)
178 - old_mode = repo_copy(node_ctx.srcRev, node_ctx.src, node_ctx.dst);
175 + if (node_ctx.srcRev) {
176 + repo_copy(node_ctx.srcRev, node_ctx.src, node_ctx.dst);
177 + node_ctx.action = NODEACT_CHANGE;
178 + }
179
180 - if (mark && node_ctx.type == REPO_MODE_DIR)
180 + if (mark && type == REPO_MODE_DIR)
181 die("invalid dump: directories cannot have text attached");
182
183 - if (node_ctx.action == NODEACT_CHANGE) {
184 - if (have_props)
183 + if (node_ctx.action == NODEACT_CHANGE)
184 + node_ctx.type = repo_modify_path(node_ctx.dst, 0, mark);
185 + else /* Node-action: add */
186 + repo_add(node_ctx.dst, type, mark);
187 +
188 + if (have_props) {
189 + const uint32_t old_mode = node_ctx.type;
190 + node_ctx.type = type;
191 + if (node_ctx.propLength)
192 + read_props();
193 + if (node_ctx.type != old_mode)
194 repo_modify_path(node_ctx.dst, node_ctx.type, mark);
186 - else if (mark)
187 - old_mode = repo_modify_path(node_ctx.dst, 0, mark);
188 - } else if (node_ctx.action == NODEACT_ADD) {
189 - if (node_ctx.srcRev && have_props)
190 - repo_modify_path(node_ctx.dst, node_ctx.type, mark);
191 - else if (node_ctx.srcRev && mark)
192 - old_mode = repo_modify_path(node_ctx.dst, 0, mark);
193 - else if ((node_ctx.type == REPO_MODE_DIR && !node_ctx.srcRev) ||
194 - mark)
195 - repo_add(node_ctx.dst, node_ctx.type, mark);
195 }
196
198 - if (!have_props && old_mode)
199 - node_ctx.type = old_mode;
200 -
197 if (mark)
198 fast_export_blob(node_ctx.type, mark, node_ctx.textLength);
199 }