Below is the file 'tests/t_cvsimport_branch.at' from this revision. You can also download the file.

#  -*- Autoconf -*-

AT_SETUP([importing CVS branches with correct ancestory])

MONOTONE_SETUP

AT_XFAIL_IF(true)

AT_DATA(file1.0, [version 0 of test file1
])

AT_DATA(file1.1, [version 1 of test file1
])

AT_DATA(file1.2, [version 2 of test file1
])

AT_DATA(file2.0, [version 0 of test file2
])

AT_DATA(file2.1, [version 1 of test file2
])

AT_DATA(changelog.0, [first changelog entry
])

AT_DATA(changelog.1, [second changelog

first changelog entry
])

AT_DATA(changelog.2, [third changelog -not on branch-

second changelog

first changelog entry
])

AT_DATA(changelog.3, [third changelog -on branch-

second changelog

first changelog entry
])

AT_DATA(branchlist, [test
test.branched
])

F1SHA0=`SHA1(file1.0)`
F1SHA1=`SHA1(file1.1)`
F1SHA2=`SHA1(file1.2)`
F2SHA0=`SHA1(file2.0)`
T2SHA1=`SHA1(file2.1)`
CSHA0=`SHA1(changelog.0)`
CSHA1=`SHA1(changelog.1)`
CSHA2=`SHA1(changelog.2)`
CSHA3=`SHA1(changelog.3)`

# build the cvs repository

CVSROOT=`pwd`/cvs-repository
AT_CHECK(cvs -q -d $CVSROOT init, [0], [ignore], [ignore])
AT_CHECK(test -e $CVSROOT)
AT_CHECK(test -e $CVSROOT/CVSROOT)
AT_CHECK(test -e $CVSROOT/CVSROOT/modules)

# checkout the empty repository and commit some files

AT_CHECK(cvs -d $CVSROOT co ., [], [ignore], [ignore])
AT_CHECK(mkdir testdir)
AT_CHECK(cp file1.0 testdir/file1)
AT_CHECK(cp file2.0 testdir/file2)
AT_CHECK(cp changelog.0 testdir/changelog)
AT_CHECK(cvs -d $CVSROOT add testdir, [], [ignore], [ignore])
AT_CHECK(cvs -d $CVSROOT add testdir/file1, [], [ignore], [ignore])
AT_CHECK(cvs -d $CVSROOT add testdir/file2, [], [ignore], [ignore])
AT_CHECK(cvs -d $CVSROOT add testdir/changelog, [], [ignore], [ignore])
AT_CHECK(cvs -d $CVSROOT commit -m 'initial import' testdir/file1 testdir/file2 testdir/changelog, [], [ignore], [ignore])

# commit first changes
AT_CHECK(cp file1.1 testdir/file1)
AT_CHECK(cp changelog.1 testdir/changelog)
AT_CHECK(cvs -d $CVSROOT commit -m 'first commit' testdir/file1 testdir/changelog, [], [ignore], [ignore])

# now we create a branch
AT_CHECK(cd testdir; cvs -d $CVSROOT tag -b branched, [], [ignore], [ignore])
AT_CHECK(cd testdir; cvs -d $CVSROOT up -r branched, [], [ignore], [ignore])

# alter the files on the branch
AT_CHECK(cp file2.1 testdir/file2)
AT_CHECK(cp changelog.3 testdir/changelog)
AT_CHECK(cvs -d $CVSROOT commit -m 'commit on branch' testdir/file2 testdir/changelog, [], [ignore], [ignore])

# and create some mainline changes after the branch
AT_CHECK(cvs -d $CVSROOT up -A, [], [ignore], [ignore])
AT_CHECK(cp file1.2 testdir/file1)
AT_CHECK(cp changelog.2 testdir/changelog)
AT_CHECK(cvs -d $CVSROOT commit -m 'commit on mainline after branch' testdir/file1 testdir/changelog, [], [ignore], [ignore])

# import into monotone and check presence of files
AT_CHECK(MONOTONE --branch=test cvs_import $CVSROOT/testdir, [], [ignore], [ignore])

# check if all branches were imported
AT_CHECK(MONOTONE list branches, [], [stdout], [ignore])
AT_CHECK(cmp stdout branchlist)

# checkout the imported repository into maindir and branchdir
AT_CHECK(MONOTONE checkout --branch=test maindir, [], [ignore], [ignore])
AT_CHECK(MONOTONE checkout --branch=test.branched branchdir, [], [ignore], [ignore])

# check for correctness of the files in the main tree
AT_CHECK(cmp file1.2 maindir/file1)
AT_CHECK(cmp file2.0 maindir/file2)
AT_CHECK(cmp changelog.2 maindir/changelog)

# check for correctness of the files in the branch
AT_CHECK(cmp file1.1 branchdir/file1)
AT_CHECK(cmp file2.1 branchdir/file2)
AT_CHECK(cmp changelog.3 branchdir/changelog)

# get the log of the branch to check for correct branchpoint
AT_CHECK(cd branchdir; MONOTONE log, [], [stdout], [ignore])
AT_CHECK(grep "commit on branch" stdout, [], [ignore], [ignore])
AT_CHECK(grep "initial import" stdout, [], [ignore], [ignore])

AT_CLEANUP