view tests/test-convert-darcs @ 12717:89df79b3c011 stable

convert/darcs: support changelogs with bytes 0x7F-0xFF (issue2411) This is a followup to 4481f8a93c7a, which only fixed the conversion of patches with UTF-8 metadata. This patch allows a changelog to have any bytes with values 0x7F-0xFF. It parses the XML changelog as Latin-1 and uses converter_source.recode() to decode the data as UTF-8/Latin-1. Caveats: - Since the convert extension doesn't provide any way to specify the source encoding, users are still limited to UTF-8 and Latin-1. - etree will still complain if the changelog has bytes with values 0x00-0x19. XML only allows printable characters.
author Brodie Rao <brodie@bitheap.org>
date Fri, 01 Oct 2010 10:15:04 -0500
parents 84ceedcfeb6a
children
line wrap: on
line source

#!/bin/sh

"$TESTDIR/hghave" darcs || exit 80

echo "[extensions]" >> $HGRCPATH
echo "convert=" >> $HGRCPATH
echo 'graphlog =' >> $HGRCPATH

DARCS_EMAIL='test@example.org'; export DARCS_EMAIL
HOME=`pwd`/do_not_use_HOME_darcs; export HOME

# skip if we can't import elementtree
mkdir dummy
mkdir dummy/_darcs
if hg convert dummy 2>&1 | grep ElementTree > /dev/null; then
    echo 'skipped: missing feature: elementtree module'
    exit 80
fi

echo '% try converting darcs1 repository'
hg convert -s darcs "$TESTDIR/darcs/darcs1" 2>&1 | grep darcs-1.0

echo % initialize darcs repo
mkdir darcs-repo
cd darcs-repo
darcs init
echo a > a
darcs record -a -l -m p0
cd ..

echo % branch and update
darcs get darcs-repo darcs-clone >/dev/null
cd darcs-clone
echo c >> a
echo c > c
darcs record -a -l -m p1.1
cd ..

echo % update source
cd darcs-repo
echo b >> a
echo b > b
darcs record -a -l -m p1.2

echo % merge branch
darcs pull -a ../darcs-clone
sleep 1
echo e > a
echo f > f
mkdir dir
echo d > dir/d
echo d > dir/d2
darcs record -a -l -m p2

echo % test file and directory move
darcs mv f ff
# Test remove + move
darcs remove dir/d2
rm dir/d2
darcs mv dir dir2
darcs record -a -l -m p3

echo % test utf-8 commit message and author
echo g > g
# darcs is encoding agnostic, so it takes whatever bytes it's given
darcs record -a -l -m 'p4: desc ñ' -A 'author ñ'

echo % test latin-1 commit message
echo h > h
printf "p5: desc " > ../p5
python -c 'print "".join([chr(i) for i in range(128, 256)])' >> ../p5
darcs record -a -l --logfile ../p5

glog()
{
    hg glog --template '{rev} "{desc|firstline}" ({author}) files: {files}\n' "$@"
}

cd ..
hg convert darcs-repo darcs-repo-hg
# The converter does not currently handle patch conflicts very well.
# When they occur, it reverts *all* changes and moves forward,
# letting the conflict resolving patch fix collisions.
# Unfortunately, non-conflicting changes, like the addition of the
# "c" file in p1.1 patch are reverted too.
# Just to say that manifest not listing "c" here is a bug.
HGENCODING=latin-1 glog -R darcs-repo-hg -r 6 | "$TESTDIR"/printrepr.py
HGENCODING=utf-8 glog -R darcs-repo-hg -r 0:5 | "$TESTDIR"/printrepr.py
hg up -q -R darcs-repo-hg
hg -R darcs-repo-hg manifest --debug