Mercurial > public > mercurial-scm > hg
diff tests/test-win32text @ 5967:f8ad3b76e923
Provide better context for custom Python encode/decode filters.
While some can function with just some text and an optional command name,
others may want a repository object, a ui object, and a file path.
Use the enhanced information to good effect in win32text.dumbdecode's warning.
author | Jesse Glick <jesse.glick@sun.com> |
---|---|
date | Fri, 21 Dec 2007 23:21:17 -0500 |
parents | 963c516bb38c |
children | 942287cb1f57 |
line wrap: on
line diff
--- a/tests/test-win32text Mon Jan 28 21:39:47 2008 +0100 +++ b/tests/test-win32text Fri Dec 21 23:21:17 2007 -0500 @@ -9,6 +9,11 @@ file(path, 'wb').write(data) EOF +cat > print.py <<EOF +import sys +print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>')) +EOF + hg init echo '[hooks]' >> .hg/hgrc echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc @@ -62,4 +67,35 @@ hg log -v echo -# XXX missing tests for encode/decode hooks +rm .hg/hgrc +(echo some; echo text) > f3 +python -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")' +hg add f3 f4.bat +hg ci -m 6 -d'0 0' + +python print.py < bin +python print.py < f3 +python print.py < f4.bat +echo + +echo '[extensions]' >> .hg/hgrc +echo 'win32text = ' >> .hg/hgrc +echo '[decode]' >> .hg/hgrc +echo '** = cleverdecode:' >> .hg/hgrc +echo '[encode]' >> .hg/hgrc +echo '** = cleverencode:' >> .hg/hgrc +cat .hg/hgrc +echo + +rm f3 f4.bat bin +hg co 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))' +python print.py < bin +python print.py < f3 +python print.py < f4.bat +echo + +python -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")' +hg add f5.sh +hg ci -m 7 -d'0 0' +python print.py < f5.sh +hg cat f5.sh | python print.py