view tests/test-fastimport-cvs2git-fixup @ 45:783890f8a6fb

Test that my idealized version of cvs2git's output produces identical output.
author Greg Ward <greg-hg@gerg.ca>
date Mon, 11 May 2009 17:55:57 -0400
parents 61ff7b929cea
children
line wrap: on
line source

#!/bin/sh

# Test a dump created by cvs2git from a CVS repository with branches and
# tags.  Specifically, we're looking at the creation of a new branch
# REL-2-2-3 where the branch point is tagged REL-2-2-3-P1.

# Rather than create an artificial example, this is derived from
# a real-life CVS repository.

. $TESTDIR/fastimport-common

cat > git-blob.dat <<EOF
blob
mark :2308
data 5
boo!

blob
mark :14693
data 18
# Doxyfile 1.2.14

blob
mark :11363
data 6
hello

EOF

# This is the dump that cvs2git actually produces.  There are some
# oddities to it:
#  - commit 1619 has no first parent, but the "merge" directive
#    (second parent) points to the commit that should be its first parent
#  - commit 1620 should have 1619 as its first parent, but 1619 is
#    set to the second parent... and there is no first parent
#
# but git-fast-import accepts it, and the spec allows it.  Therefore,
# hg-fastimport must accept it and handle it correctly.

#cat > /dev/null <<EOF
cat > git-dump-1.dat <<EOF
commit refs/heads/master
mark :1000000373
committer Example <example> 991793180 +0000
data 15
added Makefile

M 100644 :2308 Makefile

commit refs/heads/REL-2-2-3
mark :1000001619
committer cvs2git <cvs2git> 1022533494 +0000
data 47
create branch 'REL-2-2-3' (manufactured commit)
merge :1000000373
M 100644 :2308 Makefile

commit refs/heads/TAG.FIXUP
mark :1000001620
committer cvs2git <cvs2git> 1022533495 +0000
data 47
create tag 'REL-2-2-3-P1' (manufactured commit)
merge :1000001619
M 100644 :14693 Tools/Debug/C++/DebugCpp.doxygen

reset refs/tags/REL-2-2-3-P1
from :1000001620
reset refs/heads/TAG.FIXUP

commit refs/heads/master
mark :1000001621
committer Other <other@example.com> 1022536868 +0000
data 18
added iostream.h

M 100644 :11363 main.cpp
EOF

# This is another way of expressing the same thing.  git-fast-import
# treats them the same, therefore hg-fastimport should too.
cat > git-dump-2.dat <<EOF
commit refs/heads/master
mark :1000000373
committer Example <example> 991793180 +0000
data 15
added Makefile

M 100644 :2308 Makefile

commit refs/heads/REL-2-2-3
mark :1000001619
committer cvs2git <cvs2git> 1022533494 +0000
data 47
create branch 'REL-2-2-3' (manufactured commit)
from :1000000373
M 100644 :2308 Makefile

commit refs/heads/TAG.FIXUP
mark :1000001620
committer cvs2git <cvs2git> 1022533495 +0000
data 47
create tag 'REL-2-2-3-P1' (manufactured commit)
from :1000001619
M 100644 :14693 Tools/Debug/C++/DebugCpp.doxygen

reset refs/tags/REL-2-2-3-P1
from :1000001620
reset refs/heads/TAG.FIXUP

commit refs/heads/master
mark :1000001621
committer Other <other@example.com> 1022536868 +0000
data 18
added iostream.h

M 100644 :11363 main.cpp
EOF

# Test that both dumps work (they should produce identical output).
#for dump in git-dump-1.dat git-dump-2.dat; do
for i in 1 2 ; do
    dump=git-dump-$i.dat
    echo "----------------------------------------"
    echo "% import $dump"
    set -e
    repo=realcvs.$i
    hg init $repo
    hg -R $repo fastimport git-blob.dat $dump \
      | sed "s|$HGTMP|HGTMP|g"

    echo "% hg glog ($dump)"
    cd $repo
    template="rev:    {rev}\nauthor: {author}\nbranch: '{branches}'  tags:   {tags}\nfiles:  {files}\ndesc:   {desc}\n\n"
    hg glog -v --template="$template"

    echo "% hg branches ($dump)"
    # Exclude default since its changeset ID is different with every run.
    # (Same thing with tags and tip below.)
    hg branches | grep -v "^default"

    echo "% hg heads -v ($dump)"
    hg heads --template="$template"

    echo "% hg tags -v ($dump)"
    hg tags | grep -v "^tip"
    cd ..
done