Added an init phase to most modules.
[svn-fe.git] / fast_export.c
blobdc17c549be617e6cdf1829096b39f3fd4695cf60
1 #include <string.h>
3 #include "fast_export.h"
4 #include "line_buffer.h"
5 #include "repo_tree.h"
6 #include "string_pool.h"
8 #define MAX_GITSVN_LINE_LEN 4096
10 void fast_export_delete(uint32_t depth, uint32_t *path)
12 putchar('D');
13 putchar(' ');
14 pool_print_seq(depth, path, '/', stdout);
15 putchar('\n');
18 void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode,
19 uint32_t mark)
21 printf("M %06o :%d ", mode, mark);
22 pool_print_seq(depth, path, '/', stdout);
23 putchar('\n');
26 static char gitsvnline[MAX_GITSVN_LINE_LEN];
27 void fast_export_commit(uint32_t revision, uint32_t author, char *log,
28 uint32_t uuid, uint32_t url, time_t timestamp)
30 if (!log)
31 log = "";
32 if (~uuid && ~url) {
33 snprintf(gitsvnline, MAX_GITSVN_LINE_LEN, "\n\ngit-svn-id: %s@%d %s\n",
34 pool_fetch(url), revision, pool_fetch(uuid));
35 } else {
36 *gitsvnline = '\0';
38 printf("commit refs/heads/master\n");
39 printf("committer %s <%s@%s> %ld +0000\n",
40 ~author ? pool_fetch(author) : "nobody",
41 ~author ? pool_fetch(author) : "nobody",
42 ~uuid ? pool_fetch(uuid) : "local", timestamp);
43 printf("data %zd\n%s%s\n",
44 strlen(log) + strlen(gitsvnline), log, gitsvnline);
45 repo_diff(revision - 1, revision);
46 fputc('\n', stdout);
48 printf("progress Imported commit %d.\n\n", revision);
51 void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len)
53 if (mode == REPO_MODE_LNK) {
54 /* svn symlink blobs start with "link " */
55 buffer_skip_bytes(5);
56 len -= 5;
58 printf("blob\nmark :%d\ndata %d\n", mark, len);
59 buffer_copy_bytes(len);
60 fputc('\n', stdout);