summaryrefslogtreecommitdiff
path: root/vcs-svn
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-03-22 18:19:46 -0500
committerJonathan Nieder <jrnieder@gmail.com>2011-03-22 18:19:46 -0500
commitfa6c4bceabdb7bc4bf8946c4887f08e9765f5ff6 (patch)
tree032e619da9cece255ca86279fb18ccb87fd83371 /vcs-svn
parent5c674860eb8bfa1a8c0038fc2d32c4fc205e9d62 (diff)
parent7c5817d3ba111bb71a5d7e3c8526e0925f96c92d (diff)
downloadgit-fa6c4bceabdb7bc4bf8946c4887f08e9765f5ff6.tar.gz
Merge branch 'db/strbufs-for-metadata' into db/svn-fe-code-purge
* db/strbufs-for-metadata: vcs-svn: use strbuf for author, UUID, and URL vcs-svn: use strbuf for revision log Conflicts: vcs-svn/fast_export.c vcs-svn/fast_export.h vcs-svn/repo_tree.c vcs-svn/svndump.c
Diffstat (limited to 'vcs-svn')
-rw-r--r--vcs-svn/fast_export.c14
-rw-r--r--vcs-svn/fast_export.h5
-rw-r--r--vcs-svn/repo_tree.h5
-rw-r--r--vcs-svn/svndump.c71
4 files changed, 47 insertions, 48 deletions
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c
index 32f0c8cfcc..a64a3c5633 100644
--- a/vcs-svn/fast_export.c
+++ b/vcs-svn/fast_export.c
@@ -59,25 +59,25 @@ void fast_export_modify(uint32_t depth, const uint32_t *path, uint32_t mode,
}
static char gitsvnline[MAX_GITSVN_LINE_LEN];
-void fast_export_begin_commit(uint32_t revision, uint32_t author, char *log,
- uint32_t uuid, uint32_t url,
+void fast_export_begin_commit(uint32_t revision, const char *author, char *log,
+ const char *uuid, const char *url,
unsigned long timestamp)
{
if (!log)
log = "";
- if (~uuid && ~url) {
+ if (*uuid && *url) {
snprintf(gitsvnline, MAX_GITSVN_LINE_LEN,
"\n\ngit-svn-id: %s@%"PRIu32" %s\n",
- pool_fetch(url), revision, pool_fetch(uuid));
+ url, revision, uuid);
} else {
*gitsvnline = '\0';
}
printf("commit refs/heads/master\n");
printf("mark :%"PRIu32"\n", revision);
printf("committer %s <%s@%s> %ld +0000\n",
- ~author ? pool_fetch(author) : "nobody",
- ~author ? pool_fetch(author) : "nobody",
- ~uuid ? pool_fetch(uuid) : "local", timestamp);
+ *author ? author : "nobody",
+ *author ? author : "nobody",
+ *uuid ? uuid : "local", timestamp);
printf("data %"PRIu32"\n%s%s\n",
(uint32_t) (strlen(log) + strlen(gitsvnline)),
log, gitsvnline);
diff --git a/vcs-svn/fast_export.h b/vcs-svn/fast_export.h
index 633d21944e..fc14242420 100644
--- a/vcs-svn/fast_export.h
+++ b/vcs-svn/fast_export.h
@@ -11,8 +11,9 @@ void fast_export_reset(void);
void fast_export_delete(uint32_t depth, const uint32_t *path);
void fast_export_modify(uint32_t depth, const uint32_t *path,
uint32_t mode, const char *dataref);
-void fast_export_begin_commit(uint32_t revision, uint32_t author, char *log,
- uint32_t uuid, uint32_t url, unsigned long timestamp);
+void fast_export_begin_commit(uint32_t revision, const char *author, char *log,
+ const char *uuid, const char *url,
+ unsigned long timestamp);
void fast_export_end_commit(uint32_t revision);
void fast_export_data(uint32_t mode, uint32_t len, struct line_buffer *input);
diff --git a/vcs-svn/repo_tree.h b/vcs-svn/repo_tree.h
index d690784fbb..29887f9765 100644
--- a/vcs-svn/repo_tree.h
+++ b/vcs-svn/repo_tree.h
@@ -17,8 +17,9 @@ void repo_add(uint32_t *path, uint32_t mode, uint32_t blob_mark);
const char *repo_read_path(const uint32_t *path);
uint32_t repo_read_mode(const uint32_t *path);
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);
+void repo_commit(uint32_t revision, const char *author,
+ char *log, const char *uuid, const char *url,
+ long unsigned timestamp);
void repo_diff(uint32_t r1, uint32_t r2);
void repo_init(void);
void repo_reset(void);
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index ff985fe9e6..f5de49cbeb 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -11,8 +11,8 @@
#include "repo_tree.h"
#include "fast_export.h"
#include "line_buffer.h"
-#include "obj_pool.h"
#include "string_pool.h"
+#include "strbuf.h"
#define REPORT_FILENO 3
@@ -37,22 +37,8 @@
#define LENGTH_UNKNOWN (~0)
#define DATE_RFC2822_LEN 31
-/* Create memory pool for log messages */
-obj_pool_gen(log, char, 4096)
-
static struct line_buffer input = LINE_BUFFER_INIT;
-#define REPORT_FILENO 3
-
-static char *log_copy(uint32_t length, const char *log)
-{
- char *buffer;
- log_free(log_pool.size);
- buffer = log_pointer(log_alloc(length));
- strncpy(buffer, log, length);
- return buffer;
-}
-
static struct {
uint32_t action, propLength, textLength, srcRev, type;
uint32_t src[REPO_MAX_PATH_DEPTH], dst[REPO_MAX_PATH_DEPTH];
@@ -60,13 +46,14 @@ static struct {
} node_ctx;
static struct {
- uint32_t revision, author;
+ uint32_t revision;
unsigned long timestamp;
- char *log;
+ struct strbuf log, author;
} rev_ctx;
static struct {
- uint32_t version, uuid, url;
+ uint32_t version;
+ struct strbuf uuid, url;
} dump_ctx;
static void reset_node_ctx(char *fname)
@@ -86,15 +73,17 @@ static void reset_rev_ctx(uint32_t revision)
{
rev_ctx.revision = revision;
rev_ctx.timestamp = 0;
- rev_ctx.log = NULL;
- rev_ctx.author = ~0;
+ strbuf_reset(&rev_ctx.log);
+ strbuf_reset(&rev_ctx.author);
}
-static void reset_dump_ctx(uint32_t url)
+static void reset_dump_ctx(const char *url)
{
- dump_ctx.url = url;
+ strbuf_reset(&dump_ctx.url);
+ if (url)
+ strbuf_addstr(&dump_ctx.url, url);
dump_ctx.version = 1;
- dump_ctx.uuid = ~0;
+ strbuf_reset(&dump_ctx.uuid);
}
static void handle_property(const struct strbuf *key_buf,
@@ -110,13 +99,15 @@ static void handle_property(const struct strbuf *key_buf,
break;
if (!val)
die("invalid dump: unsets svn:log");
- /* Value length excludes terminating nul. */
- rev_ctx.log = log_copy(len + 1, val);
+ strbuf_reset(&rev_ctx.log);
+ strbuf_add(&rev_ctx.log, val, len);
break;
case sizeof("svn:author"):
if (constcmp(key, "svn:author"))
break;
- rev_ctx.author = pool_intern(val);
+ strbuf_reset(&rev_ctx.author);
+ if (val)
+ strbuf_add(&rev_ctx.author, val, len);
break;
case sizeof("svn:date"):
if (constcmp(key, "svn:date"))
@@ -311,8 +302,9 @@ static void begin_revision(void)
{
if (!rev_ctx.revision) /* revision 0 gets no git commit. */
return;
- fast_export_begin_commit(rev_ctx.revision, rev_ctx.author, rev_ctx.log,
- dump_ctx.uuid, dump_ctx.url, rev_ctx.timestamp);
+ fast_export_begin_commit(rev_ctx.revision, rev_ctx.author.buf,
+ rev_ctx.log.buf, dump_ctx.uuid.buf, dump_ctx.url.buf,
+ rev_ctx.timestamp);
}
static void end_revision(void)
@@ -328,7 +320,7 @@ void svndump_read(const char *url)
uint32_t active_ctx = DUMP_CTX;
uint32_t len;
- reset_dump_ctx(pool_intern(url));
+ reset_dump_ctx(url);
while ((t = buffer_read_line(&input))) {
val = strstr(t, ": ");
if (!val)
@@ -348,7 +340,8 @@ void svndump_read(const char *url)
case sizeof("UUID"):
if (constcmp(t, "UUID"))
continue;
- dump_ctx.uuid = pool_intern(val);
+ strbuf_reset(&dump_ctx.uuid);
+ strbuf_addstr(&dump_ctx.uuid, val);
break;
case sizeof("Revision-number"):
if (constcmp(t, "Revision-number"))
@@ -463,7 +456,11 @@ int svndump_init(const char *filename)
if (buffer_init(&input, filename))
return error("cannot open %s: %s", filename, strerror(errno));
fast_export_init(REPORT_FILENO);
- reset_dump_ctx(~0);
+ strbuf_init(&dump_ctx.uuid, 4096);
+ strbuf_init(&dump_ctx.url, 4096);
+ strbuf_init(&rev_ctx.log, 4096);
+ strbuf_init(&rev_ctx.author, 4096);
+ reset_dump_ctx(NULL);
reset_rev_ctx(0);
reset_node_ctx(NULL);
return 0;
@@ -471,11 +468,11 @@ int svndump_init(const char *filename)
void svndump_deinit(void)
{
- log_reset();
fast_export_deinit();
- reset_dump_ctx(~0);
+ reset_dump_ctx(NULL);
reset_rev_ctx(0);
reset_node_ctx(NULL);
+ strbuf_release(&rev_ctx.log);
if (buffer_deinit(&input))
fprintf(stderr, "Input error\n");
if (ferror(stdout))
@@ -484,10 +481,10 @@ void svndump_deinit(void)
void svndump_reset(void)
{
- log_reset();
fast_export_reset();
buffer_reset(&input);
- reset_dump_ctx(~0);
- reset_rev_ctx(0);
- reset_node_ctx(NULL);
+ strbuf_release(&dump_ctx.uuid);
+ strbuf_release(&dump_ctx.url);
+ strbuf_release(&rev_ctx.log);
+ strbuf_release(&rev_ctx.author);
}