view tests/test-fastimport-cvs2git-fixup @ 44:61ff7b929cea

Handle fixup commits and branch creation as produced by cvs2git. Update test script to test real cvs2git output, not my idealized version of it.
author Greg Ward <greg-hg@gerg.ca>
date Mon, 11 May 2009 17:46:19 -0400
parents 71f1e5ed6213
children 783890f8a6fb
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

echo "% import cvs2git with branch/tag"
set -e
hg init realcvs
hg -R realcvs fastimport git-blob.dat git-dump-1.dat \
  | sed "s|$HGTMP|HGTMP|g"

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

echo "% hg branches"
# 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"
hg heads --template="$template"

echo "% hg tags -v"
hg tags | grep -v "^tip"