Should be almost exactly equivalent now, and both should function properly.
authorChris Lee <clee@c133.org>
Sun, 14 Jan 2007 15:05:30 +0000 (07:05 -0800)
committerChris Lee <clee@clee-desktop.(none)>
Sun, 14 Jan 2007 15:05:30 +0000 (07:05 -0800)
svn-fast-export.c
svn-fast-export.py

index e115a73..df9b079 100644 (file)
@@ -44,20 +44,18 @@ time_t get_epoch(char *svn_date)
 int dump_blob(svn_fs_root_t *root, char *full_path, apr_pool_t *pool)
 {
     svn_filesize_t stream_length;
-    svn_stream_t *stream;
+    svn_stream_t *stream, *outstream;
     apr_size_t len;
     char buf[8];
 
     SVN_ERR(svn_fs_file_length(&stream_length, root, full_path, pool));
     SVN_ERR(svn_fs_file_contents(&stream, root, full_path, pool));
 
-    fprintf(stdout, "data %li\n", stream_length);
+    fprintf(stdout, "data %lu\n", stream_length);
+    fflush(stdout);
 
-    do {
-        len = sizeof(buf);
-        SVN_ERR(svn_stream_read(stream, buf, &len));
-        fprintf (stdout, "%s\0", buf);
-    } while (len);
+    SVN_ERR(svn_stream_for_stdout(&outstream, pool));
+    SVN_ERR(svn_stream_copy(stream, outstream, pool));
 
     fprintf(stdout, "\n");
 
@@ -81,7 +79,7 @@ int export_revision(svn_revnum_t rev, svn_repos_t *repo, svn_fs_t *fs, apr_pool_
     const void *key;
     void *val;
  
-    fprintf(stderr, "Exporting revision %li... ", rev);
+    fprintf(stderr, "Exporting revision %ld... ", rev);
 
     SVN_ERR(svn_fs_revision_root(&root_obj, fs, rev, pool));
     SVN_ERR(svn_fs_paths_changed(&changes, root_obj, pool));
@@ -108,7 +106,7 @@ int export_revision(svn_revnum_t rev, svn_repos_t *repo, svn_fs_t *fs, apr_pool_
         } else {
             *(char **)apr_array_push(file_changes) = (char *)svn_string_createf(pool, "M 644 :%u %s", mark, path + strlen(TRUNK))->data;
             fprintf(stdout, "blob\nmark :%u\n", mark++);
-            // dump_blob(root_obj, (char *)path, revpool);
+            dump_blob(root_obj, (char *)path, revpool);
         }
     }
 
index 1c2eb7a..a2304c7 100755 (executable)
@@ -19,29 +19,19 @@ import gc, sys, os.path
 from optparse import OptionParser
 from time import sleep, mktime, localtime, strftime, strptime
 from svn.fs import svn_fs_dir_entries, svn_fs_file_length, svn_fs_file_contents, svn_fs_is_dir, svn_fs_revision_root, svn_fs_youngest_rev, svn_fs_revision_proplist, svn_fs_revision_prop, svn_fs_paths_changed
-from svn.core import svn_pool_create, svn_pool_clear, svn_pool_destroy, svn_stream_read, svn_stream_close, run_app
+from svn.core import svn_pool_create, svn_pool_clear, svn_pool_destroy, svn_stream_read, svn_stream_for_stdout, svn_stream_copy, svn_stream_close, run_app
 from svn.repos import svn_repos_open, svn_repos_fs
 
 ct_short = ['M', 'A', 'D', 'R', 'X']
 
 def dump_file_blob(root, full_path, pool):
-    # Use an iteration subpool.
-    subpool = svn_pool_create(pool)
-
-    # Clear the iteration subpool.
-    svn_pool_clear(subpool)
-
-    # print full_path
-    stream_length = svn_fs_file_length(root, full_path, subpool)
-    stream = svn_fs_file_contents(root, full_path, subpool)
-    contents = svn_stream_read(stream, int(stream_length))
+    stream_length = svn_fs_file_length(root, full_path, pool)
+    stream = svn_fs_file_contents(root, full_path, pool)
     sys.stdout.write("data %s\n" % stream_length)
-    sys.stdout.write(contents)
+    ostream = svn_stream_for_stdout(pool)
+    svn_stream_copy(stream, ostream, pool)
     sys.stdout.write("\n")
 
-    # Destroy the iteration subpool.
-    svn_pool_destroy(subpool)
-
 
 def export_revision(rev, repo, fs, pool):
     sys.stderr.write("Exporting revision %s... " % rev)
@@ -71,10 +61,10 @@ def export_revision(rev, repo, fs, pool):
             if c_t == 'D':
                 file_changes.append("D %s" % path.replace(trunk_path, ''))
             else:
-                sys.stdout.write("blob\nmark :%s\n" % i)
                 marks[i] = path.replace(trunk_path, '')
-                # dump_file_blob(root_obj, path, revpool)
                 file_changes.append("M 644 :%s %s" % (i, marks[i]))
+                sys.stdout.write("blob\nmark :%s\n" % i)
+                dump_file_blob(root, path, revpool)
                 i += 1
 
     # Get the commit author and message
@@ -94,14 +84,15 @@ def export_revision(rev, repo, fs, pool):
     svndate = props['svn:date'][0:-8]
     commit_time = mktime(strptime(svndate, '%Y-%m-%dT%H:%M:%S'))
     sys.stdout.write("commit refs/heads/master\n")
-    #sys.stdout.write("committer %s %s -0000\n" % (author, int(commit_time)))
-    #sys.stdout.write("data %s\n" % len(props['svn:log']))
-    #sys.stdout.write(props['svn:log'])
-    #sys.stdout.write("\n")
+    sys.stdout.write("committer %s %s -0000\n" % (author, int(commit_time)))
+    sys.stdout.write("data %s\n" % len(props['svn:log']))
+    sys.stdout.write(props['svn:log'])
+    sys.stdout.write("\n")
     sys.stdout.write('\n'.join(file_changes))
     sys.stdout.write("\n\n")
 
     svn_pool_destroy(revpool)
+
     sys.stderr.write("done!\n")
 
     #if rev % 1000 == 0: