From 2eeba42a36f26fe6044df6e34e362a2e132a9b21 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 8 Nov 2014 09:11:27 -0500 Subject: [PATCH] fast-export is working. --- TODO | 2 -- src | 14 ++++++++++---- srctest | 31 ++++++++++++++++--------------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/TODO b/TODO index 69726fb..2f2c1bb 100644 --- a/TODO +++ b/TODO @@ -8,8 +8,6 @@ * src fast-import -* src fast-import - * vc.el * .srcignore diff --git a/src b/src index 1738ac3..399939d 100755 --- 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 ecba8a4..2514af3 100755 --- 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 </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 <testfile2 <testfile3 -diff testfile2 testfile3 +diff -u testfile2 testfile3 check "list test" cat >testfile2 <testfile3 -diff testfile2 testfile3 +diff -u testfile2 testfile3 check "2-commit log test" cat >testfile1 <testfile5 -diff testfile4 testfile5 +diff -u testfile4 testfile5 check "3-commit log test" cat >testfile6 <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 <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 -- 2.43.0