diff options
Diffstat (limited to 'vcs-svn')
-rw-r--r-- | vcs-svn/fast_export.c | 14 | ||||
-rw-r--r-- | vcs-svn/fast_export.h | 2 | ||||
-rw-r--r-- | vcs-svn/svndump.c | 21 |
3 files changed, 33 insertions, 4 deletions
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c index 1ecae4b6cf..df51c59ca5 100644 --- a/vcs-svn/fast_export.c +++ b/vcs-svn/fast_export.c @@ -3,8 +3,7 @@ * See LICENSE for details. */ -#include "git-compat-util.h" -#include "strbuf.h" +#include "cache.h" #include "quote.h" #include "fast_export.h" #include "repo_tree.h" @@ -68,6 +67,17 @@ void fast_export_modify(const char *path, uint32_t mode, const char *dataref) putchar('\n'); } +void fast_export_begin_note(uint32_t revision, const char *author, + const char *log, unsigned long timestamp) +{ + size_t loglen = strlen(log); + printf("commit refs/notes/svn/revs\n"); + printf("committer %s <%s@%s> %ld +0000\n", author, author, "local", timestamp); + printf("data %"PRIuMAX"\n", (uintmax_t)loglen); + fwrite(log, loglen, 1, stdout); + fputc('\n', stdout); +} + void fast_export_note(const char *committish, const char *dataref) { printf("N %s %s\n", dataref, committish); diff --git a/vcs-svn/fast_export.h b/vcs-svn/fast_export.h index 9b32f1e6a1..c2f6f11b12 100644 --- a/vcs-svn/fast_export.h +++ b/vcs-svn/fast_export.h @@ -10,6 +10,8 @@ void fast_export_deinit(void); void fast_export_delete(const char *path); void fast_export_modify(const char *path, uint32_t mode, const char *dataref); void fast_export_note(const char *committish, const char *dataref); +void fast_export_begin_note(uint32_t revision, const char *author, + const char *log, unsigned long timestamp); void fast_export_begin_commit(uint32_t revision, const char *author, const struct strbuf *log, const char *uuid, const char *url, unsigned long timestamp, const char *local_ref); diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index c8a5b7eebb..7ec1a5b993 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -48,7 +48,7 @@ static struct { static struct { uint32_t revision; unsigned long timestamp; - struct strbuf log, author; + struct strbuf log, author, note; } rev_ctx; static struct { @@ -77,6 +77,7 @@ static void reset_rev_ctx(uint32_t revision) rev_ctx.timestamp = 0; strbuf_reset(&rev_ctx.log); strbuf_reset(&rev_ctx.author); + strbuf_reset(&rev_ctx.note); } static void reset_dump_ctx(const char *url) @@ -310,8 +311,15 @@ static void begin_revision(const char *remote_ref) static void end_revision(void) { - if (rev_ctx.revision) + struct strbuf mark = STRBUF_INIT; + if (rev_ctx.revision) { fast_export_end_commit(rev_ctx.revision); + fast_export_begin_note(rev_ctx.revision, "remote-svn", + "Note created by remote-svn.", rev_ctx.timestamp); + strbuf_addf(&mark, ":%"PRIu32, rev_ctx.revision); + fast_export_note(mark.buf, "inline"); + fast_export_buf_to_data(&rev_ctx.note); + } } void svndump_read(const char *url, const char *local_ref) @@ -358,6 +366,7 @@ void svndump_read(const char *url, const char *local_ref) end_revision(); active_ctx = REV_CTX; reset_rev_ctx(atoi(val)); + strbuf_addf(&rev_ctx.note, "%s\n", t); break; case sizeof("Node-path"): if (constcmp(t, "Node-")) @@ -369,10 +378,12 @@ void svndump_read(const char *url, const char *local_ref) begin_revision(local_ref); active_ctx = NODE_CTX; reset_node_ctx(val); + strbuf_addf(&rev_ctx.note, "%s\n", t); break; } if (constcmp(t + strlen("Node-"), "kind")) continue; + strbuf_addf(&rev_ctx.note, "%s\n", t); if (!strcmp(val, "dir")) node_ctx.type = REPO_MODE_DIR; else if (!strcmp(val, "file")) @@ -383,6 +394,7 @@ void svndump_read(const char *url, const char *local_ref) case sizeof("Node-action"): if (constcmp(t, "Node-action")) continue; + strbuf_addf(&rev_ctx.note, "%s\n", t); if (!strcmp(val, "delete")) { node_ctx.action = NODEACT_DELETE; } else if (!strcmp(val, "add")) { @@ -401,11 +413,13 @@ void svndump_read(const char *url, const char *local_ref) continue; strbuf_reset(&node_ctx.src); strbuf_addstr(&node_ctx.src, val); + strbuf_addf(&rev_ctx.note, "%s\n", t); break; case sizeof("Node-copyfrom-rev"): if (constcmp(t, "Node-copyfrom-rev")) continue; node_ctx.srcRev = atoi(val); + strbuf_addf(&rev_ctx.note, "%s\n", t); break; case sizeof("Text-content-length"): if (constcmp(t, "Text") && constcmp(t, "Prop")) @@ -475,6 +489,7 @@ static void init(int report_fd) strbuf_init(&dump_ctx.url, 4096); strbuf_init(&rev_ctx.log, 4096); strbuf_init(&rev_ctx.author, 4096); + strbuf_init(&rev_ctx.note, 4096); strbuf_init(&node_ctx.src, 4096); strbuf_init(&node_ctx.dst, 4096); reset_dump_ctx(NULL); @@ -506,6 +521,8 @@ void svndump_deinit(void) reset_rev_ctx(0); reset_node_ctx(NULL); strbuf_release(&rev_ctx.log); + strbuf_release(&rev_ctx.author); + strbuf_release(&rev_ctx.note); strbuf_release(&node_ctx.src); strbuf_release(&node_ctx.dst); if (buffer_deinit(&input)) |