Opened 19 years ago
Closed 19 years ago
#2845 closed task (duplicate)
post-commit hook & unicode
Reported by: | Owned by: | Jonas Borgström | |
---|---|---|---|
Priority: | highest | Milestone: | |
Component: | ticket system | Version: | 0.9.4 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I've setup post-commit hook on Windows (svn log message is read from file). Everything works fine except when I use Croatian characters. Trac ticket breakes with error: Unexpected error while processing ticket ID 3: 'utf8' codec can't decode bytes i n position 10-12: invalid data.
I made unicode log file which doesn't break the trac ticket. Characters in ticket are displayed OK but post commit hook can not parse the log message.
Can unicode be supported in parsing ticket or how can I setup Trac to use international characters (Croatian for example).
Attachments (6)
Change History (15)
by , 19 years ago
Attachment: | trac-post-commit-hook added |
---|
by , 19 years ago
Attachment: | post-commit.bat added |
---|
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Component: | general → ticket system |
---|---|
Priority: | normal → highest |
comment:3 by , 19 years ago
Type: | defect → task |
---|
comment:4 by , 19 years ago
Try to check what svnlook gives out as log and if it's correct. (see post-commit lines 18, 26) On Linux with several Locale settings (e.g. non UTF-8), svnlook itself produces incorrect output. Maybe changing the codepage helps.
comment:5 by , 19 years ago
When I call svnlook from command prompt output message is OK. When I call svnlook from command prompt output and redirect it to text file message is scrambled.
I need to redirect message to a text file because of windows batch file limitiations so I tried doing this (see re-attached batch file because of mismatch in line 29)
SET TMP_LOG=%TEMP%.\svnfileTMP-%REV% SET LOG_FILE=%TEMP%.\svnfileR-%REV% svnlook log -r %REV% %REPOS%>%TMP_LOG% ::napravi unicode cmd /c /u "type %TMP_LOG%>%LOG_FILE%" ::type "%TMP_LOG%"
cmd parameter /u - Causes the output of internal commands to a pipe or file to be Unicode
But trac cannot parse it if in unicode :(
comment:7 by , 19 years ago
I can not figure out how to change encoding for SVN, I'm using TortoiseSVN as client and I'm sure that log messages are stored correctly.
I fond switch for SVN:
—encoding but that's svn and not svnlook switch
See attachments added 03/022/2006. If I send to trac message from svnfileTMP-47 trac complains about utf encoding. If I send to trac message from svnfile-47 trac works fine but cannot parse log message (for example:
fixes #3
is interpreted as
f i x e s # 3
)
Have no idesa how to solve it, is there any command in python that chan convert message from svnfile-47 correctly or read it correctly from file.
comment:8 by , 19 years ago
Solution that works for me is:
- Use standard redirect to file (no unicode) which will save file in windows current code page.
- find the code in trac-post-commit-hook in lines 136,137:
msg = self._readFromFile( msg ) self.msg = "(In [%s]) %s" % (rev, msg)
and replace it with
## ## International character support ## # decode message from user locale encodeing, # to get codepagefor windows from command prompt run command chcp dec_msg = msg.decode('cp852') # encode it to unicode, because trac must use unicode to represent # international characters uni_msg = dec_msg.encode('utf-8') self.msg = "(In [%s]) %s" % (rev, uni_msg)
'
comment:9 by , 19 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Hm, I think this is a duplicate of #1310.
Modified trac-post-commit-hook reads log message from a file.