Issue1183

Title wrong encoding when using web.encoding setting
Priority bug Status chatting
Superseder Nosy List azraiyl, djc, mpm
Assigned To Topics hgweb

Created on 2008-06-17.19:55:15 by azraiyl, last changed 2008-06-20.13:31:38 by azraiyl.

Files
File name Uploaded Type Edit Remove
server.diff azraiyl, 2008-06-19.21:04:37 application/octet-stream
Messages
msg6367 (view) Author: azraiyl Date: 2008-06-20.13:31:38
Because dispatch.py cares about --encoding the web:encoding encoding has to be
set before. Either dispatch.py is (heavily) modified so the --encoding is set
later or dispatch.py does somehow know that "hg serve" has not default behavior.

if cmd == "serve":
  if foo.config("web", "encoding"):
    util._encoding = foo.config("web", "encoding")
if options["encoding"]:
  util._encoding = options["encoding"]

But hey guys i think you know 100 times better than me where a fix would be
appropriate. Or do you play snakes and ladders with me - ding ding - wrong path,
go back to start and try once more :)
msg6358 (view) Author: djc Date: 2008-06-19.21:26:03
Hmm, it probably isn't.
msg6357 (view) Author: azraiyl Date: 2008-06-19.21:04:37
I've tried to implement djc idea. But the downside of this fix is that the
"--encoding" parameter is overriden by web:encoding. Don't know if this is a
good thing.
msg6328 (view) Author: djc Date: 2008-06-18.13:52:04
Maybe hgweb() should just set util._encoding to whatever it wants?
msg6312 (view) Author: azraiyl Date: 2008-06-17.20:51:01
I have 4 ideas (3 fancy ones)

- tolocal has an encoding parameter. Usability=0 as it has to be passed from web
down to util.
- tolocal does something like a stack inspection. Called from web it switches to
web:encoding.
- tolocal internally uses util._encoding. util needs to know somehow if used for
web or not. While util is initialized it can try to modify the encoding.

(probably the best idea)

If anyone uses the "--encoding=xyz" parameter the util._encoding is changed
inside dispatch.py

util._encoding = options["encoding"]

if "hg serve" is the only command that is related to the web category then
dispatch should modify util._encoding (maybe before the line before).
msg6310 (view) Author: mpm Date: 2008-06-17.20:14:43
What -should- happen is that setting web:encoding should change util's idea of
what the encoding is in the same way that --encoding does.
msg6308 (view) Author: azraiyl Date: 2008-06-17.19:55:15
Situation: Windows default installation. Default encoding is cp1252. I modify
the web section in Mercurial.ini and add encoding=utf-8. "hg serve" without any
parameter. hg sends to client the encoding is utf-8 as intendet - but - the
content is still encoded in cp1252 and therefore does not make sense.

example

hgweb_mod.py calls changectx from a context
context.py calls from read from changelog
changelog.py calls tolocal from util
util.py does not care about the web encoding

The cp1252 encoded string therfore goes back up to hgweb_mod.py and is never
modified again.

A simple bugfix would be to remove the web encoding at all. An "--encoding
utf-8" in the defaults section for "hg serve" does work well.
History
Date User Action Args
2008-06-20 13:31:38azraiylsetmessages: + msg6367
2008-06-19 21:26:03djcsetmessages: + msg6358
2008-06-19 21:04:39azraiylsetfiles: + server.diff
messages: + msg6357
2008-06-18 13:52:04djcsetnosy: + djc
messages: + msg6328
2008-06-17 20:51:05azraiylsetmessages: + msg6312
2008-06-17 20:14:43mpmsetstatus: unread -> chatting
nosy: + mpm
messages: + msg6310
2008-06-17 19:55:15azraiylcreate