view tests/test-convert-svn-move @ 12252:4481f8a93c7a stable

convert/darcs: handle non-ASCII metadata in darcs changelog (issue2354) Given a commit author or message with non-ASCII characters in a darcs repo, convert would raise a UnicodeEncodeError when adding changesets to the hg changelog. This happened because etree returns back unicode objects for any text it can't encode into ASCII. convert was passing these objects to changelog.add(), which would then attempt encoding.fromlocal() on them. This patch ensures converter_source.recode() is called on each piece of commit data returned by etree. (Also note that darcs is currently encoding agnostic and will print out whatever is in a patch's metadata byte-for-byte, even in the XML changelog.)
author Brodie Rao <brodie@bitheap.org>
date Fri, 10 Sep 2010 09:30:50 -0500
parents 73a4ed3bfef8
children
line wrap: on
line source

#!/bin/sh

"$TESTDIR/hghave" svn svn-bindings || exit 80

fix_path()
{
    tr '\\' /
}

echo "[extensions]" >> $HGRCPATH
echo "convert = " >> $HGRCPATH
echo "hgext.graphlog =" >> $HGRCPATH

svnadmin create svn-repo
cat "$TESTDIR/svn/move.svndump" | svnadmin load svn-repo > /dev/null

svnpath=`pwd | fix_path`
# SVN wants all paths to start with a slash. Unfortunately,
# Windows ones don't. Handle that.
expr "$svnpath" : "\/" > /dev/null
if [ $? -ne 0 ]; then
    svnpath="/$svnpath"
fi
svnurl="file://$svnpath/svn-repo"

echo % convert trunk and branches
hg convert --datesort "$svnurl"/subproject A-hg

cd A-hg
hg glog --template '{rev} {desc|firstline} files: {files}\n'
echo '% check move copy records'
hg st --rev 12:13 --copies
echo '% check branches'
hg branches | sed 's/:.*/:/'
cd ..

mkdir test-replace
cd test-replace
svnadmin create svn-repo
cat "$TESTDIR/svn/replace.svndump" | svnadmin load svn-repo > /dev/null

echo '% convert files being replaced by directories'
hg convert svn-repo hg-repo
cd hg-repo
echo '% manifest before'
hg -v manifest -r 1
echo '% manifest after clobber1'
hg -v manifest -r 2
echo '% manifest after clobber2'
hg -v manifest -r 3
echo '% try updating'
hg up -qC default
cd ..

echo '% test convert progress bar'

echo "progress=" >> $HGRCPATH
echo "[progress]" >> $HGRCPATH
echo "assume-tty=1" >> $HGRCPATH
echo "delay=0" >> $HGRCPATH
echo "refresh=0" >> $HGRCPATH

cat > filtercr.py <<EOF
import sys, re
for line in sys.stdin:
    line = re.sub(r'\r+[^\n]', lambda m: '\n' + m.group()[-1:], line)
    sys.stdout.write(line)
EOF

hg convert svn-repo hg-progress 2>&1 | python filtercr.py