@matheusbsbs / matheus-bagliano / commits / e75316de53
Fork 0

vcs-svn: simplify repo_modify_path and repo_copy

Restrict the repo_tree API to functions that are actually needed. - decouple reading the mode and content of dirents from other operations. - remove repo_modify_path. It is only used to read the mode from dirents. - remove the ability to use repo_read_mode on a missing path. The existing code only errors out in that case, anyway. 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 00:53 UTC e75316de5340e0ba3ac75937c59fa2c9d6ab48d7
3 files changed +13 -22
vcs-svn/repo_tree.c
+10 -17
@@ -106,7 +106,7 @@ static struct repo_dirent *repo_read_dirent(uint32_t revision,
106 return dent;
107 }
108
109 -static void repo_write_dirent(uint32_t *path, uint32_t mode,
109 +static void repo_write_dirent(const uint32_t *path, uint32_t mode,
110 uint32_t content_offset, uint32_t del)
111 {
112 uint32_t name, revision, dir_o = ~0, parent_dir_o = ~0;
@@ -167,7 +167,15 @@ uint32_t repo_read_path(const uint32_t *path)
167 return content_offset;
168 }
169
170 -uint32_t repo_copy(uint32_t revision, uint32_t *src, uint32_t *dst)
170 +uint32_t repo_read_mode(const uint32_t *path)
171 +{
172 + struct repo_dirent *dent = repo_read_dirent(active_commit, path);
173 + if (dent == NULL)
174 + die("invalid dump: path to be modified is missing");
175 + return dent->mode;
176 +}
177 +
178 +void repo_copy(uint32_t revision, const uint32_t *src, const uint32_t *dst)
179 {
180 uint32_t mode = 0, content_offset = 0;
181 struct repo_dirent *src_dent;
@@ -177,7 +185,6 @@ uint32_t repo_copy(uint32_t revision, uint32_t *src, uint32_t *dst)
185 content_offset = src_dent->content_offset;
186 repo_write_dirent(dst, mode, content_offset, 0);
187 }
180 - return mode;
188 }
189
190 void repo_add(uint32_t *path, uint32_t mode, uint32_t blob_mark)
@@ -185,20 +192,6 @@ void repo_add(uint32_t *path, uint32_t mode, uint32_t blob_mark)
192 repo_write_dirent(path, mode, blob_mark, 0);
193 }
194
188 -uint32_t repo_modify_path(uint32_t *path, uint32_t mode, uint32_t blob_mark)
189 -{
190 - struct repo_dirent *src_dent;
191 - src_dent = repo_read_dirent(active_commit, path);
192 - if (!src_dent)
193 - return 0;
194 - if (!blob_mark)
195 - blob_mark = src_dent->content_offset;
196 - if (!mode)
197 - mode = src_dent->mode;
198 - repo_write_dirent(path, mode, blob_mark, 0);
199 - return mode;
200 -}
201 -
195 void repo_delete(uint32_t *path)
196 {
197 repo_write_dirent(path, 0, 0, 1);
vcs-svn/repo_tree.h
+2 -2
@@ -12,10 +12,10 @@
12 #define REPO_MAX_PATH_DEPTH 1000
13
14 uint32_t next_blob_mark(void);
15 -uint32_t repo_copy(uint32_t revision, uint32_t *src, uint32_t *dst);
15 +void repo_copy(uint32_t revision, const uint32_t *src, const uint32_t *dst);
16 void repo_add(uint32_t *path, uint32_t mode, uint32_t blob_mark);
17 -uint32_t repo_modify_path(uint32_t *path, uint32_t mode, uint32_t blob_mark);
17 uint32_t repo_read_path(const uint32_t *path);
18 +uint32_t repo_read_mode(const uint32_t *path);
19 void repo_delete(uint32_t *path);
20 void repo_commit(uint32_t revision, uint32_t author, char *log, uint32_t uuid,
21 uint32_t url, long unsigned timestamp);
vcs-svn/svndump.c
+1 -3
@@ -235,9 +235,7 @@ static void handle_node(void)
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");
238 + mode = repo_read_mode(node_ctx.dst);
239 if (mode == REPO_MODE_DIR && type != REPO_MODE_DIR)
240 die("invalid dump: cannot modify a directory into a file");
241 if (mode != REPO_MODE_DIR && type == REPO_MODE_DIR)