vcs-svn: Allow simple v3 dumps (no deltas yet)
[gitweb.git] / vcs-svn / svndump.c
index 630eeb53b7d75f71bdf91cbdf45f428d0a14eb35..6b64c1b8573c00fd09f6387bbda3714d1336356c 100644 (file)
@@ -42,6 +42,7 @@ static char* log_copy(uint32_t length, char *log)
 static struct {
        uint32_t action, propLength, textLength, srcRev, srcMode, mark, type;
        uint32_t src[REPO_MAX_PATH_DEPTH], dst[REPO_MAX_PATH_DEPTH];
+       uint32_t text_delta, prop_delta;
 } node_ctx;
 
 static struct {
@@ -51,14 +52,16 @@ static struct {
 } rev_ctx;
 
 static struct {
-       uint32_t uuid, url;
+       uint32_t version, uuid, url;
 } dump_ctx;
 
 static struct {
        uint32_t svn_log, svn_author, svn_date, svn_executable, svn_special, uuid,
                revision_number, node_path, node_kind, node_action,
                node_copyfrom_path, node_copyfrom_rev, text_content_length,
-               prop_content_length, content_length;
+               prop_content_length, content_length, svn_fs_dump_format_version,
+               /* version 3 format */
+               text_delta, prop_delta;
 } keys;
 
 static void reset_node_ctx(char *fname)
@@ -72,6 +75,8 @@ static void reset_node_ctx(char *fname)
        node_ctx.srcMode = 0;
        pool_tok_seq(REPO_MAX_PATH_DEPTH, node_ctx.dst, "/", fname);
        node_ctx.mark = 0;
+       node_ctx.text_delta = 0;
+       node_ctx.prop_delta = 0;
 }
 
 static void reset_rev_ctx(uint32_t revision)
@@ -85,6 +90,7 @@ static void reset_rev_ctx(uint32_t revision)
 static void reset_dump_ctx(uint32_t url)
 {
        dump_ctx.url = url;
+       dump_ctx.version = 1;
        dump_ctx.uuid = ~0;
 }
 
@@ -105,6 +111,10 @@ static void init_keys(void)
        keys.text_content_length = pool_intern("Text-content-length");
        keys.prop_content_length = pool_intern("Prop-content-length");
        keys.content_length = pool_intern("Content-length");
+       keys.svn_fs_dump_format_version = pool_intern("SVN-fs-dump-format-version");
+       /* version 3 format (Subversion 1.1.0) */
+       keys.text_delta = pool_intern("Text-delta");
+       keys.prop_delta = pool_intern("Prop-delta");
 }
 
 static void read_props(void)
@@ -142,6 +152,9 @@ static void read_props(void)
 
 static void handle_node(void)
 {
+       if (node_ctx.text_delta || node_ctx.prop_delta)
+               die("text and property deltas not supported");
+
        if (node_ctx.propLength != LENGTH_UNKNOWN && node_ctx.propLength)
                read_props();
 
@@ -206,7 +219,12 @@ void svndump_read(const char *url)
                *val++ = '\0';
                key = pool_intern(t);
 
-               if (key == keys.uuid) {
+               if (key == keys.svn_fs_dump_format_version) {
+                       dump_ctx.version = atoi(val);
+                       if (dump_ctx.version > 3)
+                               die("expected svn dump format version <= 3, found %d",
+                                   dump_ctx.version);
+               } else if (key == keys.uuid) {
                        dump_ctx.uuid = pool_intern(val);
                } else if (key == keys.revision_number) {
                        if (active_ctx == NODE_CTX)
@@ -248,6 +266,10 @@ void svndump_read(const char *url)
                        node_ctx.textLength = atoi(val);
                } else if (key == keys.prop_content_length) {
                        node_ctx.propLength = atoi(val);
+               } else if (key == keys.text_delta) {
+                       node_ctx.text_delta = !strcmp(val, "true");
+               } else if (key == keys.prop_delta) {
+                       node_ctx.prop_delta = !strcmp(val, "true");
                } else if (key == keys.content_length) {
                        len = atoi(val);
                        buffer_read_line();
@@ -257,7 +279,7 @@ void svndump_read(const char *url)
                                handle_node();
                                active_ctx = REV_CTX;
                        } else {
-                               fprintf(stderr, "Unexpected content length header: %d\n", len);
+                               fprintf(stderr, "Unexpected content length header: %"PRIu32"\n", len);
                                buffer_skip_bytes(len);
                        }
                }