]> thyrsus.com Git - src.git/commitdiff
fast-export is working.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 14:11:27 +0000 (09:11 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 14:11:27 +0000 (09:11 -0500)
TODO
src
srctest

diff --git a/TODO b/TODO
index 69726fbb13f6cb6eead1d42edd66cbf057360aff..2f2c1bb0d37f055440e0ce12a1e903ddf4dac376 100644 (file)
--- a/TODO
+++ b/TODO
@@ -8,8 +8,6 @@
 
 * src fast-import
 
-* src fast-import
-
 * vc.el
 
 * .srcignore
diff --git a/src b/src
index 1738ac34953989232de59bd29c8ecb4538a8514b..399939d00007b26dc7556f18169b9869675ef110 100755 (executable)
--- a/src
+++ b/src
@@ -616,17 +616,16 @@ def fast_export_method(*args):
         revspec = metadata.resolve(revspec)
         if revspec is None:
             revspec = 1
-        revrange = range(revspec, len(metadata))
+        revrange = range(revspec, len(metadata)+1)
         with lifted(arg):
             markmap = {}
             last_commit_mark = 0
             if len(args) == 1:
                 branch = "master"
             else:
-                # FIXME: Sanitize branch names
+                # FIXME: Sanitize branch names.
+                # FIXME: Make this canonical even with tags
                 branch = arg + "master"
-            if revspec > 1:
-                sys.stdout.write("from refs/heads/%s^0" % branch)
             for revno in revrange:
                 scratchfile = "/tmp/src%dtmp" % os.getpid()
                 do_or_die("co -q -p -r{1} {0} >{2}".format(arg, metadata.revno_to_rcs(revno), scratchfile))
@@ -636,8 +635,14 @@ def fast_export_method(*args):
                 item = metadata.by_revno(revno)
                 sys.stdout.write("blob\nmark :%d\ndata %d\n" % (mark, size))
                 sys.stdout.write(open(scratchfile).read() + "\n")
+                if revno == revspec:
+                    if revspec == 1:
+                        sys.stdout.write("reset refs/heads/%s\n" % branch)
+                    else:
+                        sys.stdout.write("from refs/heads/%s^0\n" % branch)
                 sys.stdout.write("commit refs/heads/%s\n" % branch)
                 sys.stdout.write("mark :%d\n" % (mark + 1))
+                sys.stdout.write("author %s %d +0000\n" % (attribution, item.unixtime()))
                 sys.stdout.write("committer %s %d +0000\n" % (attribution, item.unixtime()))
                 sys.stdout.write("data %s\n%s" % (len(item.log), item.log))
                 if last_commit_mark:
@@ -646,6 +651,7 @@ def fast_export_method(*args):
                 mark += 1
                 last_commit_mark = mark
                 markmap[revno] = mark
+            sys.stdout.write("reset refs/heads/%s\nfrom :%d\n\n" % (branch, mark))
             for (key, val) in metadata.symbols.items():
                 val = metadata.rcs_to_revno(val)
                 if val in revrange:
diff --git a/srctest b/srctest
index ecba8a415e1118e83cb600af542b4744086c6c58..2514af3b5cc85fea47aa6f58d998d5b6cbd4c30f 100755 (executable)
--- a/srctest
+++ b/srctest
@@ -37,7 +37,7 @@ check "add"
 src $TESTOPTS commit -m "First comment" testfile1 >/dev/null
 check "commit with -m option"
 
-src $TESTOPTS cat testfile1 | diff testfile1 - >/dev/null
+src $TESTOPTS cat testfile1 | diff -u testfile1 - >/dev/null
 check "content check after first commit"
 
 cat >testfile1 <<EOF
@@ -49,7 +49,7 @@ cp testfile1 testrev2
 echo "Second comment" | src $TESTOPTS commit - testfile1 >/dev/null
 check "commit with -"
 
-src $TESTOPTS cat testfile1 | diff testfile1 -
+src $TESTOPTS cat testfile1 | diff -u testfile1 -
 check "content check after second commit"
 
 cat >testfile2 <<EOF
@@ -59,7 +59,7 @@ cat >testfile2 <<EOF
 EOF
 
 src $TESTOPTS list testfile1 >testfile3
-diff testfile2 testfile3
+diff -u testfile2 testfile3
 check "list test"
 
 cat >testfile2 <<EOF
@@ -73,7 +73,7 @@ First comment
 EOF
 
 src $TESTOPTS log testfile1 >testfile3
-diff testfile2 testfile3
+diff -u testfile2 testfile3
 check "2-commit log test"
 
 cat >testfile1 <<EOF
@@ -101,7 +101,7 @@ First comment
 EOF
 
 src $TESTOPTS log testfile1 >testfile5
-diff testfile4 testfile5
+diff -u testfile4 testfile5
 check "3-commit log test"
 
 cat >testfile6 <<EOF
@@ -110,7 +110,7 @@ src: testfile1 has no 5 revision
 EOF
 
 src $TESTOPTS list 5 testfile1 >testfile7 2>&1
-diff testfile6 testfile7
+diff -u testfile6 testfile7
 check "oob revision spec check"
 
 for rev in 1 2 3
@@ -145,7 +145,7 @@ diff testfile10 testfile11
 check "second tag list check"
 
 src $TESTOPTS tag delete sampletag
-check "tag deletion"
+check "tag deletion: sampletag"
 
 cat >testfile12 <<EOF
 = testfile1 =================================================================
@@ -155,15 +155,16 @@ src $TESTOPTS tag >testfile13
 diff testfile12 testfile13
 check "tag list check after deletion"
 
-exit 0
+# Alas, we have to do this or the fast-export regression will fail.
+# We don't know how to be perfectly canonical about tags let.
+src $TESTOPTS tag delete basetag
+check "tag deletion: basetag"
+
 mkdir $SANDBOX/foo
 src $TESTOPTS fast-export testfile1 >testfile14
-cat testfile14
-cat testfile14 | (cd $SANDBOX/foo >/dev/null; git init; git fast-import --quiet)
-(cd $SANDBOX/foo; git log)
-
-#(cd $SANDBOX/foo; git fast-export --all) >testfile15
-#diff testfile14 testfile15
-
+cat testfile14 | (cd $SANDBOX/foo >/dev/null; git init --quiet; git fast-import --quiet)
+(cd $SANDBOX/foo; git fast-export --all) >testfile15
+diff -u testfile14 testfile15
+check "fast-export" 
 
 # end