[PATCH] i18n: safety writing into non-ASCII named files on any shell implementation
FUJIWARA Katsunori
fujiwara at ascade.co.jp
Wed Jul 21 08:45:58 CDT 2010
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1279718904 -32400
# Branch stable
# Node ID c83103eb88b4f795a7c7068303ab1c147823e42b
# Parent 9e874ee0fe97ffd00fe13300f4cdf6b44921e71d
i18n: safety writing into non-ASCII named files on any shell implementation
some shell implementation (e.g.: dash) can not handle redirection into
non-ASCII UTF-8 named file correctly.
this patch uses instant python script to write data into such files.
diff -r 9e874ee0fe97 -r c83103eb88b4 tests/test-encoding-align
--- a/tests/test-encoding-align Tue Jul 13 03:04:14 2010 +0200
+++ b/tests/test-encoding-align Wed Jul 21 22:28:24 2010 +0900
@@ -8,17 +8,21 @@
hg init t
cd t
-python << EOF
+cat << EOF > names.py
# (byte, width) = (6, 4)
s = "\xe7\x9f\xad\xe5\x90\x8d"
# (byte, width) = (7, 7): odd width is good for alignment test
m = "MIDDLE_"
# (byte, width) = (18, 12)
l = "\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d"
+EOF
-f = file('s', 'w'); f.write(s); f.close()
-f = file('m', 'w'); f.write(m); f.close()
-f = file('l', 'w'); f.write(l); f.close()
+python <<EOF
+import names
+
+f = file('s', 'w'); f.write(names.s); f.close()
+f = file('m', 'w'); f.write(names.m); f.close()
+f = file('l', 'w'); f.write(names.l); f.close()
# instant extension to show list of options
f = file('showoptlist.py', 'w'); f.write("""# encoding: utf-8
@@ -29,9 +33,9 @@
cmdtable = {
'showoptlist':
(showoptlist,
- [('s', 'opt1', '', 'short width', '""" + s + """'),
- ('m', 'opt2', '', 'middle width', '""" + m + """'),
- ('l', 'opt3', '', 'long width', '""" + l + """')
+ [('s', 'opt1', '', 'short width', '""" + names.s + """'),
+ ('m', 'opt2', '', 'middle width', '""" + names.m + """'),
+ ('l', 'opt3', '', 'long width', '""" + names.l + """')
],
""
)
@@ -69,25 +73,33 @@
touch $L
hg add $L
+# for safety append to non-ASCII UTF-8 named files
+# on any shell implementatoins
+cat <<EOF > append.py
+import sys
+import names
+
+namelist = [ names.s, names.m, names.l ]
+
+for i in xrange(len(namelist)):
+ f = file(namelist[i], 'a');
+ f.write('%s(%d)\n' % (sys.argv[1], (i + 1)));
+ f.close()
+EOF
+
#### commit(1)
-echo 'first line(1)' >> $S
-echo 'first line(2)' >> $M
-echo 'first line(3)' >> $L
+python append.py 'first line'
hg commit -m 'first commit' -u $S -d "1000000 0"
#### commit(2)
-echo 'second line(1)' >> $S
-echo 'second line(2)' >> $M
-echo 'second line(3)' >> $L
+python append.py 'second line'
hg commit -m 'second commit' -u $M -d "1000000 0"
#### commit(3)
-echo 'third line(1)' >> $S
-echo 'third line(2)' >> $M
-echo 'third line(3)' >> $L
+python append.py 'third line'
hg commit -m 'third commit' -u $L -d "1000000 0"
#### check
More information about the Mercurial-devel
mailing list