Ticket #2845 (closed task: duplicate)
Opened 6 years ago
Last modified 6 years ago
post-commit hook & unicode
| Reported by: | ante.blaskovic@… | Owned by: | jonas |
|---|---|---|---|
| Priority: | highest | Milestone: | |
| Component: | ticket system | Version: | 0.9.4 |
| Severity: | normal | Keywords: | |
| Cc: | |||
| Release Notes: | |||
| API 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
Change History
Changed 6 years ago by anonymous
- Attachment trac-post-commit-hook added
Changed 6 years ago by anonymous
- Attachment post-commit.bat added
comment:1 Changed 6 years ago by ante.blaskovic@…
comment:2 Changed 6 years ago by anonymous
- Component changed from general to ticket system
- Priority changed from normal to highest
comment:3 Changed 6 years ago by anonymous
- Type changed from defect to task
comment:4 Changed 6 years ago by core@…
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 Changed 6 years ago by ante.blaskovic@…
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:6 Changed 6 years ago by ante.blaskovic@…
I will try to change codpage tomorrow to see if that helps.
comment:7 Changed 6 years ago by ante.blaskovic@…
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 Changed 6 years ago by anonymous
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 Changed 6 years ago by cboos
- Resolution set to duplicate
- Status changed from new to closed
Hm, I think this is a duplicate of #1310.



Modified trac-post-commit-hook reads log message from a file.