From 21c7c2d92d4b107ca854d84d4cd4d86c7993089c Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 22 Aug 2017 17:01:34 -0700 Subject: vcs-svn: remove custom mode constants In the rest of Git, these modes are spelled as S_IFDIR, S_IFREG | 0644, S_IFREG | 0755, and S_IFLNK. Use the same constants in svn-fe for simplicity and consistency. No functional change intended. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- vcs-svn/svndump.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'vcs-svn/svndump.c') diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index 7da84b2aab..c0fa4eb723 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -134,13 +134,13 @@ static void handle_property(const struct strbuf *key_buf, die("invalid dump: sets type twice"); } if (!val) { - node_ctx.type = REPO_MODE_BLB; + node_ctx.type = S_IFREG | 0644; return; } *type_set = 1; node_ctx.type = keylen == strlen("svn:executable") ? - REPO_MODE_EXE : - REPO_MODE_LNK; + (S_IFREG | 0755) : + S_IFLNK; } } @@ -219,7 +219,7 @@ static void handle_node(void) */ static const char *const empty_blob = "::empty::"; const char *old_data = NULL; - uint32_t old_mode = REPO_MODE_BLB; + uint32_t old_mode = S_IFREG | 0644; if (node_ctx.action == NODEACT_DELETE) { if (have_text || have_props || node_ctx.srcRev) @@ -237,27 +237,27 @@ static void handle_node(void) if (node_ctx.action == NODEACT_ADD) node_ctx.action = NODEACT_CHANGE; } - if (have_text && type == REPO_MODE_DIR) + if (have_text && type == S_IFDIR) die("invalid dump: directories cannot have text attached"); /* * Find old content (old_data) and decide on the new mode. */ if (node_ctx.action == NODEACT_CHANGE && !*node_ctx.dst.buf) { - if (type != REPO_MODE_DIR) + if (type != S_IFDIR) die("invalid dump: root of tree is not a regular file"); old_data = NULL; } else if (node_ctx.action == NODEACT_CHANGE) { uint32_t mode; old_data = svn_repo_read_path(node_ctx.dst.buf, &mode); - if (mode == REPO_MODE_DIR && type != REPO_MODE_DIR) + if (mode == S_IFDIR && type != S_IFDIR) die("invalid dump: cannot modify a directory into a file"); - if (mode != REPO_MODE_DIR && type == REPO_MODE_DIR) + if (mode != S_IFDIR && type == S_IFDIR) die("invalid dump: cannot modify a file into a directory"); node_ctx.type = mode; old_mode = mode; } else if (node_ctx.action == NODEACT_ADD) { - if (type == REPO_MODE_DIR) + if (type == S_IFDIR) old_data = NULL; else if (have_text) old_data = empty_blob; @@ -280,7 +280,7 @@ static void handle_node(void) /* * Save the result. */ - if (type == REPO_MODE_DIR) /* directories are not tracked. */ + if (type == S_IFDIR) /* directories are not tracked. */ return; assert(old_data); if (old_data == empty_blob) @@ -385,9 +385,9 @@ void svndump_read(const char *url, const char *local_ref, const char *notes_ref) continue; strbuf_addf(&rev_ctx.note, "%s\n", t); if (!strcmp(val, "dir")) - node_ctx.type = REPO_MODE_DIR; + node_ctx.type = S_IFDIR; else if (!strcmp(val, "file")) - node_ctx.type = REPO_MODE_BLB; + node_ctx.type = S_IFREG | 0644; else fprintf(stderr, "Unknown node-kind: %s\n", val); break; -- cgit v1.2.1 From 9b0db33506ea9b1d968d719f2fce9c208c66cd95 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 22 Aug 2017 17:02:15 -0700 Subject: vcs-svn: remove repo_delete wrapper function Since v1.7.10-rc0~118^2~4^2~4^2~3 (vcs-svn: pass paths through to fast-import, 2010-12-13) this is an alias for fast_export_delete. Remove the unnecessary layer of indirection. No functional change intended. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- vcs-svn/svndump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vcs-svn/svndump.c') diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index c0fa4eb723..41113119bd 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -225,11 +225,11 @@ static void handle_node(void) if (have_text || have_props || node_ctx.srcRev) die("invalid dump: deletion node has " "copyfrom info, text, or properties"); - svn_repo_delete(node_ctx.dst.buf); + fast_export_delete(node_ctx.dst.buf); return; } if (node_ctx.action == NODEACT_REPLACE) { - svn_repo_delete(node_ctx.dst.buf); + fast_export_delete(node_ctx.dst.buf); node_ctx.action = NODEACT_ADD; } if (node_ctx.srcRev) { -- cgit v1.2.1 From b8f43b120b4d7bd0638eb072f8527c5a33a70579 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 22 Aug 2017 17:04:47 -0700 Subject: vcs-svn: move remaining repo_tree functions to fast_export.h These used to be for manipulating the in-memory repo_tree structure, but nowadays they are convenience wrappers to handle a few git-vs-svn mismatches: 1. Git does not track empty directories but Subversion does. When looking up a path in git that Subversion thinks exists and finding nothing, we can safely assume that the path represents a directory. This is needed when a later Subversion revision modifies that directory. 2. Subversion allows deleting a file by copying. In Git fast-import we have to handle that more explicitly as a deletion. These are details of the tool's interaction with git fast-import. Move them to fast_export.c, where other such details are handled. This way the function names do not start with a repo_ prefix that would clash with the repository object introduced in v2.14.0-rc0~38^2~16 (repository: introduce the repository object, 2017-06-22) or an svn_ prefix that would clash with libsvn (in case someone wants to link this code with libsvn some day). Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- vcs-svn/svndump.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'vcs-svn/svndump.c') diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index 41113119bd..01b6ded400 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -8,7 +8,6 @@ */ #include "cache.h" -#include "repo_tree.h" #include "fast_export.h" #include "line_buffer.h" #include "strbuf.h" @@ -233,7 +232,7 @@ static void handle_node(void) node_ctx.action = NODEACT_ADD; } if (node_ctx.srcRev) { - svn_repo_copy(node_ctx.srcRev, node_ctx.src.buf, node_ctx.dst.buf); + fast_export_copy(node_ctx.srcRev, node_ctx.src.buf, node_ctx.dst.buf); if (node_ctx.action == NODEACT_ADD) node_ctx.action = NODEACT_CHANGE; } @@ -249,7 +248,7 @@ static void handle_node(void) old_data = NULL; } else if (node_ctx.action == NODEACT_CHANGE) { uint32_t mode; - old_data = svn_repo_read_path(node_ctx.dst.buf, &mode); + old_data = fast_export_read_path(node_ctx.dst.buf, &mode); if (mode == S_IFDIR && type != S_IFDIR) die("invalid dump: cannot modify a directory into a file"); if (mode != S_IFDIR && type == S_IFDIR) -- cgit v1.2.1