Edgewall Software

Ticket #2845 (closed task: duplicate)

Opened 2 years ago

Last modified 2 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:

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

trac-post-commit-hook (7.9 kB) - added by anonymous 2 years ago.
post-commit.bat (1.4 kB) - added by anonymous 2 years ago.
post-commit.2.bat (1.4 kB) - added by ante.blaskovic@… 2 years ago.
Unicode log file create
post.commit.bat (1.2 kB) - added by anonymous 2 years ago.
Last copy that works
svnfileR-47 (76 bytes) - added by anonymous 2 years ago.
example of unicode-log message
svnfileTMP-47 (38 bytes) - added by anonymous 2 years ago.
example of log message

Change History

Changed 2 years ago by anonymous

Changed 2 years ago by anonymous

Changed 2 years ago by ante.blaskovic@…

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

Changed 2 years ago by anonymous

  • priority changed from normal to highest
  • component changed from general to ticket system

Changed 2 years ago by anonymous

  • type changed from defect to task

Changed 2 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.

Changed 2 years ago by ante.blaskovic@…

Unicode log file create

Changed 2 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 :(

Changed 2 years ago by ante.blaskovic@…

I will try to change codpage tomorrow to see if that helps.

Changed 2 years ago by anonymous

Last copy that works

Changed 2 years ago by anonymous

example of unicode-log message

Changed 2 years ago by anonymous

example of log message

Changed 2 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.

Changed 2 years ago by anonymous

Solution that works for me is:

  1. Use standard redirect to file (no unicode) which will save file in windows current code page.

  2. 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)

'

Changed 2 years ago by cboos

  • status changed from new to closed
  • resolution set to duplicate

Hm, I think this is a duplicate of #1310.

Add/Change #2845 (post-commit hook & unicode)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.