diff options
author | David Barr <david.barr@cordelta.com> | 2011-03-22 17:52:17 -0500 |
---|---|---|
committer | Jonathan Nieder <jrnieder@gmail.com> | 2011-03-22 18:01:48 -0500 |
commit | 7c5817d3ba111bb71a5d7e3c8526e0925f96c92d (patch) | |
tree | 27d8e622674ca0e7530cf3cf8dc17b75bb6c9c79 /vcs-svn | |
parent | dce33c9c18e2987da1fe8ade67d27057bcb80a67 (diff) | |
download | git-7c5817d3ba111bb71a5d7e3c8526e0925f96c92d.tar.gz git-7c5817d3ba111bb71a5d7e3c8526e0925f96c92d.tar.xz |
vcs-svn: use strbuf for author, UUID, and URL
Use strbufs and strings instead of interned strings for values of rev,
dump, and node fields that happen to be strings. After this change,
the only remaining string_pool use is for paths in the repo_tree API
and internals.
Functional change: treat an empty author, UUID, or URL as none at all.
So for example, in repos where the first revision has an empty
svn:author property, the first rev will be treated as by "nobody"
rather than by a person with empty name and email address created by
prepending an @ sign to the repository UUID.
Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Diffstat (limited to 'vcs-svn')
-rw-r--r-- | vcs-svn/fast_export.c | 14 | ||||
-rw-r--r-- | vcs-svn/fast_export.h | 5 | ||||
-rw-r--r-- | vcs-svn/repo_tree.c | 4 | ||||
-rw-r--r-- | vcs-svn/repo_tree.h | 5 | ||||
-rw-r--r-- | vcs-svn/svndump.c | 45 |
5 files changed, 43 insertions, 30 deletions
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c index 07a8353c8..a4d4d9993 100644 --- a/vcs-svn/fast_export.c +++ b/vcs-svn/fast_export.c @@ -31,24 +31,24 @@ void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode, } static char gitsvnline[MAX_GITSVN_LINE_LEN]; -void fast_export_commit(uint32_t revision, uint32_t author, char *log, - uint32_t uuid, uint32_t url, +void fast_export_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("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 054e7d5eb..05cf97f3a 100644 --- a/vcs-svn/fast_export.h +++ b/vcs-svn/fast_export.h @@ -6,8 +6,9 @@ void fast_export_delete(uint32_t depth, uint32_t *path); void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode, uint32_t mark); -void fast_export_commit(uint32_t revision, uint32_t author, char *log, - uint32_t uuid, uint32_t url, unsigned long timestamp); +void fast_export_commit(uint32_t revision, const char *author, char *log, + const char *uuid, const char *url, + unsigned long timestamp); void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len, struct line_buffer *input); diff --git a/vcs-svn/repo_tree.c b/vcs-svn/repo_tree.c index 14bcc192b..d722e3212 100644 --- a/vcs-svn/repo_tree.c +++ b/vcs-svn/repo_tree.c @@ -278,8 +278,8 @@ void repo_diff(uint32_t r1, uint32_t r2) repo_commit_root_dir(commit_pointer(r2))); } -void repo_commit(uint32_t revision, uint32_t author, char *log, uint32_t uuid, - uint32_t url, unsigned long timestamp) +void repo_commit(uint32_t revision, const char *author, char *log, + const char *uuid, const char *url, unsigned long timestamp) { fast_export_commit(revision, author, log, uuid, url, timestamp); dent_commit(); diff --git a/vcs-svn/repo_tree.h b/vcs-svn/repo_tree.h index 11d48c244..a1b0e8765 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); uint32_t 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 559a8084a..7ac74877f 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -36,13 +36,14 @@ static struct { } node_ctx; static struct { - uint32_t revision, author; + uint32_t revision; unsigned long timestamp; - struct strbuf log; + struct strbuf log, author; } rev_ctx; static struct { - uint32_t version, uuid, url; + uint32_t version; + struct strbuf uuid, url; } dump_ctx; static struct { @@ -72,14 +73,16 @@ static void reset_rev_ctx(uint32_t revision) rev_ctx.revision = revision; rev_ctx.timestamp = 0; strbuf_reset(&rev_ctx.log); - rev_ctx.author = ~0; + 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 init_keys(void) @@ -114,7 +117,9 @@ static void handle_property(uint32_t key, const char *val, uint32_t len, strbuf_reset(&rev_ctx.log); strbuf_add(&rev_ctx.log, val, len); } else if (key == keys.svn_author) { - rev_ctx.author = pool_intern(val); + strbuf_reset(&rev_ctx.author); + if (val) + strbuf_add(&rev_ctx.author, val, len); } else if (key == keys.svn_date) { if (!val) die("invalid dump: unsets svn:date"); @@ -274,8 +279,9 @@ static void handle_node(void) static void handle_revision(void) { if (rev_ctx.revision) - repo_commit(rev_ctx.revision, rev_ctx.author, rev_ctx.log.buf, - dump_ctx.uuid, dump_ctx.url, rev_ctx.timestamp); + repo_commit(rev_ctx.revision, rev_ctx.author.buf, + rev_ctx.log.buf, dump_ctx.uuid.buf, dump_ctx.url.buf, + rev_ctx.timestamp); } void svndump_read(const char *url) @@ -286,7 +292,7 @@ void svndump_read(const char *url) uint32_t len; uint32_t key; - reset_dump_ctx(pool_intern(url)); + reset_dump_ctx(url); while ((t = buffer_read_line(&input))) { val = strstr(t, ": "); if (!val) @@ -301,7 +307,8 @@ void svndump_read(const char *url) die("expected svn dump format version <= 3, found %"PRIu32, dump_ctx.version); } else if (key == keys.uuid) { - dump_ctx.uuid = pool_intern(val); + strbuf_reset(&dump_ctx.uuid); + strbuf_addstr(&dump_ctx.uuid, val); } else if (key == keys.revision_number) { if (active_ctx == NODE_CTX) handle_node(); @@ -378,8 +385,11 @@ int svndump_init(const char *filename) if (buffer_init(&input, filename)) return error("cannot open %s: %s", filename, strerror(errno)); repo_init(); + strbuf_init(&dump_ctx.uuid, 4096); + strbuf_init(&dump_ctx.url, 4096); strbuf_init(&rev_ctx.log, 4096); - reset_dump_ctx(~0); + strbuf_init(&rev_ctx.author, 4096); + reset_dump_ctx(NULL); reset_rev_ctx(0); reset_node_ctx(NULL); init_keys(); @@ -389,7 +399,7 @@ int svndump_init(const char *filename) void svndump_deinit(void) { repo_reset(); - reset_dump_ctx(~0); + reset_dump_ctx(NULL); reset_rev_ctx(0); reset_node_ctx(NULL); strbuf_release(&rev_ctx.log); @@ -403,7 +413,8 @@ void svndump_reset(void) { buffer_reset(&input); repo_reset(); - 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); } |