#! /bin/bash

# This script will create a darcs repo with only two commits, a file
# addition and a file removal (in a subdirectory), and will convert it
# to a bzr repo with tailor. Conversion will fail in the second commit
# because the subdirectory gets `bzr rm`'ed before than the file. The
# solution is to reverse-sort the file list in bzr._removePathnames().

D=/tmp/tailor-bug
[ -d $D ] || mkdir $D || exit 1
cd $D || exit 1
rm -rf darcs

set -x

pwd
mkdir -p darcs/subdir && cd darcs
darcs init
touch subdir/file.txt
darcs add -r subdir
darcs record -a -m 'add subdir'
darcs remove subdir/* subdir
darcs record -a -m 'remove subdir'
cd ..

rm -rf convert
cat >config <<EOF
[DEFAULT]
verbose = Yes

[bug]
source = darcs:bug
target = bzr:bug
root-directory = $D/convert

[darcs:bug]
repository = $D/darcs

[bzr:bug]
EOF

tailor config
