##// END OF EJS Templates
patch: drop eol normalization fast-path for 'lf' and 'crlf'...
patch: drop eol normalization fast-path for 'lf' and 'crlf' With eolmode set to 'lf' or 'crlf' we avoided the hunk duplication and normalization by reading the input patch in text mode. Dropping this optimization simplifies code expectations for a small overhead. The change in test-mq-eol comes from a tolerance to CRLF instead of LF for last lines without newlines being broken by this revision. This tolerance was only partially supported and will be added again in a better way.

File last commit:

r10128:ea7c392f default
r10128:ea7c392f default
Show More
test-mq-eol
64 lines | 1.2 KiB | text/plain | TextLexer
#!/bin/sh
# Test interactions between mq and patch.eol
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
cat > makepatch.py <<EOF
f = file('eol.diff', 'wb')
w = f.write
w('test message\n')
w('diff --git a/a b/a\n')
w('--- a/a\n')
w('+++ b/a\n')
w('@@ -1,5 +1,5 @@\n')
w(' a\n')
w('-b\r\n')
w('+y\r\n')
w(' c\r\n')
w(' d\n')
w('-e\n')
w('\ No newline at end of file\n')
w('+z\n')
w('\ No newline at end of file\r\n')
EOF
cat > cateol.py <<EOF
import sys
for line in file(sys.argv[1], 'rb'):
line = line.replace('\r', '<CR>')
line = line.replace('\n', '<LF>')
print line
EOF
hg init repo
cd repo
echo '\.diff' > .hgignore
echo '\.rej' >> .hgignore
# Test different --eol values
python -c 'file("a", "wb").write("a\nb\nc\nd\ne")'
hg ci -Am adda
python ../makepatch.py
hg qimport eol.diff
echo % should fail in strict mode
hg qpush
hg qpop
echo % invalid eol
hg --config patch.eol='LFCR' qpush
hg qpop
echo % force LF
hg --config patch.eol='CRLF' qpush
hg qrefresh
python ../cateol.py .hg/patches/eol.diff
python ../cateol.py a
hg qpop
echo % push again forcing LF and compare revisions
hg --config patch.eol='CRLF' qpush
python ../cateol.py a
hg qpop
echo % push again without LF and compare revisions
hg qpush
python ../cateol.py a
hg qpop