1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#!/bin/sh
cat > $HGRCPATH <<EOF
[diff]
git = 1
EOF
seteol () {
if [ $1 = "LF" ]; then
EOL='\n'
else
EOL='\r\n'
fi
}
makerepo () {
seteol $1
echo
echo "# ==== setup $1 repository ===="
echo '% hg init'
hg init repo
cd repo
cat > .hgeol <<EOF
[repository]
native = $1
[patterns]
unix.txt = LF
win.txt = CRLF
**.txt = native
EOF
printf "first\r\nsecond\r\nthird\r\n" > win.txt
printf "first\nsecond\nthird\n" > unix.txt
printf "first${EOL}second${EOL}third${EOL}" > native.txt
hg commit --addremove -m 'checkin'
cd ..
}
dotest () {
seteol $1
echo
echo "% hg clone repo repo-$1"
hg clone --noupdate repo repo-$1
cd repo-$1
cat > .hg/hgrc <<EOF
[extensions]
eol =
[eol]
native = $1
EOF
hg update
echo '% printrepr.py native.txt'
python $TESTDIR/printrepr.py < native.txt
echo '% printrepr.py unix.txt'
python $TESTDIR/printrepr.py < unix.txt
echo '% printrepr.py win.txt'
python $TESTDIR/printrepr.py < win.txt
printf "first${EOL}third${EOL}" > native.txt
printf "first\r\nthird\r\n" > win.txt
printf "first\nthird\n" > unix.txt
echo '% hg diff'
hg diff > p
python $TESTDIR/printrepr.py < p
echo '% hg revert'
hg revert --all
echo '% hg import'
hg import -m 'patch' p
echo '% printrepr.py native.txt'
python $TESTDIR/printrepr.py < native.txt
echo '% printrepr.py unix.txt'
python $TESTDIR/printrepr.py < unix.txt
echo '% printrepr.py win.txt'
python $TESTDIR/printrepr.py < win.txt
echo '% hg diff -c tip'
hg diff -c tip | python $TESTDIR/printrepr.py
cd ..
rm -r repo-$1
}
makerepo LF
dotest LF
dotest CRLF
rm -r repo
makerepo CRLF
dotest LF
dotest CRLF
rm -r repo
|