mirror of
https://github.com/git/git.git
synced 2024-11-24 18:33:43 +08:00
Create a note for every imported commit containing svn metadata
To provide metadata from svn dumps for further processing, e.g. branch detection, attach a note to each imported commit that stores additional information. The notes are currently hard-coded in refs/notes/svn/revs. Currently the following lines from the svn dump are directly accumulated in the note. This can be refined as needed. - "Revision-number" - "Node-path" - "Node-kind" - "Node-action" - "Node-copyfrom-path" - "Node-copyfrom-rev" Signed-off-by: Florian Achleitner <florian.achleitner.2.6.31@gmail.com> Acked-by: David Michael Barr <b@rr-dav.id.au> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3c23953fb2
commit
a9a55613cb
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user