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))
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:
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:
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
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
EOF
src $TESTOPTS list testfile1 >testfile3
-diff testfile2 testfile3
+diff -u testfile2 testfile3
check "list test"
cat >testfile2 <<EOF
EOF
src $TESTOPTS log testfile1 >testfile3
-diff testfile2 testfile3
+diff -u testfile2 testfile3
check "2-commit log test"
cat >testfile1 <<EOF
EOF
src $TESTOPTS log testfile1 >testfile5
-diff testfile4 testfile5
+diff -u testfile4 testfile5
check "3-commit log test"
cat >testfile6 <<EOF
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
check "second tag list check"
src $TESTOPTS tag delete sampletag
-check "tag deletion"
+check "tag deletion: sampletag"
cat >testfile12 <<EOF
= testfile1 =================================================================
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