summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6ee4a9b)
raw | patch | inline | side by side (parent: 6ee4a9b)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Sat, 20 Nov 2010 00:51:50 +0000 (18:51 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 24 Nov 2010 22:51:43 +0000 (14:51 -0800) |
There are two functions to change the staged content for a path in the
svn importer's active commit: repo_replace, which changes the text and
returns the mode, and repo_modify, which changes the text and mode and
returns nothing.
Worse, there are more subtle differences:
- A mark of 0 passed to repo_modify means "use the existing content".
repo_replace uses it as mark :0 and produces a corrupt stream.
- When passed a path that is not part of the active commit,
repo_replace returns without doing anything. repo_modify
transparently adds a new directory entry.
Get rid of both and introduce a new function with the best features of
both: repo_modify_path modifies the mode, content, or both for a path,
depending on which arguments are zero. If no such dirent already
exists, it does nothing and reports the error by returning 0.
Otherwise, the return value is the resulting mode.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
svn importer's active commit: repo_replace, which changes the text and
returns the mode, and repo_modify, which changes the text and mode and
returns nothing.
Worse, there are more subtle differences:
- A mark of 0 passed to repo_modify means "use the existing content".
repo_replace uses it as mark :0 and produces a corrupt stream.
- When passed a path that is not part of the active commit,
repo_replace returns without doing anything. repo_modify
transparently adds a new directory entry.
Get rid of both and introduce a new function with the best features of
both: repo_modify_path modifies the mode, content, or both for a path,
depending on which arguments are zero. If no such dirent already
exists, it does nothing and reports the error by returning 0.
Otherwise, the return value is the resulting mode.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
vcs-svn/repo_tree.c | patch | blob | history | |
vcs-svn/repo_tree.h | patch | blob | history | |
vcs-svn/svndump.c | patch | blob | history |
diff --git a/vcs-svn/repo_tree.c b/vcs-svn/repo_tree.c
index e94d91d12966562e4cd43df9c34990dddc3465c3..7214ac8d0f6c79feb443c9a485b86940e4c9f54d 100644 (file)
--- a/vcs-svn/repo_tree.c
+++ b/vcs-svn/repo_tree.c
repo_write_dirent(path, mode, blob_mark, 0);
}
-uint32_t repo_replace(uint32_t *path, uint32_t blob_mark)
+uint32_t repo_modify_path(uint32_t *path, uint32_t mode, uint32_t blob_mark)
{
- uint32_t mode = 0;
struct repo_dirent *src_dent;
src_dent = repo_read_dirent(active_commit, path);
- if (src_dent != NULL) {
- mode = src_dent->mode;
- repo_write_dirent(path, mode, blob_mark, 0);
- }
- return mode;
-}
-
-void repo_modify(uint32_t *path, uint32_t mode, uint32_t blob_mark)
-{
- struct repo_dirent *src_dent;
- src_dent = repo_read_dirent(active_commit, path);
- if (src_dent != NULL && blob_mark == 0)
+ if (!src_dent)
+ return 0;
+ if (!blob_mark)
blob_mark = src_dent->content_offset;
+ if (!mode)
+ mode = src_dent->mode;
repo_write_dirent(path, mode, blob_mark, 0);
+ return mode;
}
void repo_delete(uint32_t *path)
diff --git a/vcs-svn/repo_tree.h b/vcs-svn/repo_tree.h
index 5476175922740eaba663533a58deedfa981de659..68baeb582ff0ad8700061a78947cd186ff116536 100644 (file)
--- a/vcs-svn/repo_tree.h
+++ b/vcs-svn/repo_tree.h
uint32_t next_blob_mark(void);
uint32_t repo_copy(uint32_t revision, uint32_t *src, uint32_t *dst);
void repo_add(uint32_t *path, uint32_t mode, uint32_t blob_mark);
-uint32_t repo_replace(uint32_t *path, uint32_t blob_mark);
-void repo_modify(uint32_t *path, uint32_t mode, uint32_t blob_mark);
+uint32_t repo_modify_path(uint32_t *path, uint32_t mode, uint32_t blob_mark);
void repo_delete(uint32_t *path);
void repo_commit(uint32_t revision, uint32_t author, char *log, uint32_t uuid,
uint32_t url, long unsigned timestamp);
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index 6a6aaf92b5cd818ac4bbee0459341b33e2ffe6ef..e40be580a703f25ef072179a6f69672e8c969add 100644 (file)
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
if (node_ctx.action == NODEACT_CHANGE) {
if (have_props)
- repo_modify(node_ctx.dst, node_ctx.type, mark);
+ repo_modify_path(node_ctx.dst, node_ctx.type, mark);
else if (mark)
- old_mode = repo_replace(node_ctx.dst, mark);
+ old_mode = repo_modify_path(node_ctx.dst, 0, mark);
} else if (node_ctx.action == NODEACT_ADD) {
if (node_ctx.srcRev && have_props)
- repo_modify(node_ctx.dst, node_ctx.type, mark);
+ repo_modify_path(node_ctx.dst, node_ctx.type, mark);
else if (node_ctx.srcRev && mark)
- old_mode = repo_replace(node_ctx.dst, mark);
+ old_mode = repo_modify_path(node_ctx.dst, 0, mark);
else if ((node_ctx.type == REPO_MODE_DIR && !node_ctx.srcRev) ||
mark)
repo_add(node_ctx.dst, node_ctx.type, mark);