@matheusbsbs / matheus-bagliano / commits / 4f5de755a7
Fork 0

vcs-svn: introduce repo_read_path to check the content at a path

The repo_tree structure remembers, for each path in each revision, a mode (regular file, executable, symlink, or directory) and content (blob mark or directory structure). Maintaining a second copy of all this information when it's already in the target repository is wasteful, it does not persist between svn-fe invocations, and most importantly, there is no convenient way to transfer it from one machine to another. So it would be nice to get rid of it. As a first step, let's change the repo_tree API to match fast-import's read commands more closely. Currently to read the mode for a path, one uses repo_modify_path(path, new_mode, new_content); which changes the mode and content as a side effect. There is no function to read the content at a path; add one. 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 Nov 20, 2010 at 13:25 UTC 4f5de755a7931c5e15f4e7fc3d501588aa9ff88d
2 files changed +12 -1
vcs-svn/repo_tree.c
+11 -1
@@ -87,7 +87,8 @@ static struct repo_dir *repo_clone_dir(struct repo_dir *orig_dir)
87 return dir_pointer(new_o);
88 }
89
90 -static struct repo_dirent *repo_read_dirent(uint32_t revision, uint32_t *path)
90 +static struct repo_dirent *repo_read_dirent(uint32_t revision,
91 + const uint32_t *path)
92 {
93 uint32_t name = 0;
94 struct repo_dirent *key = dent_pointer(dent_alloc(1));
@@ -157,6 +158,15 @@ static void repo_write_dirent(uint32_t *path, uint32_t mode,
158 dent_remove(&dir_pointer(parent_dir_o)->entries, dent);
159 }
160
161 +uint32_t repo_read_path(const uint32_t *path)
162 +{
163 + uint32_t content_offset = 0;
164 + struct repo_dirent *dent = repo_read_dirent(active_commit, path);
165 + if (dent != NULL)
166 + content_offset = dent->content_offset;
167 + return content_offset;
168 +}
169 +
170 uint32_t repo_copy(uint32_t revision, uint32_t *src, uint32_t *dst)
171 {
172 uint32_t mode = 0, content_offset = 0;
vcs-svn/repo_tree.h
+1
@@ -15,6 +15,7 @@ uint32_t next_blob_mark(void);
15 uint32_t repo_copy(uint32_t revision, uint32_t *src, 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);
18 +uint32_t repo_read_path(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);