Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#2845 closed task (duplicate)

post-commit hook & unicode

Reported by: ante.blaskovic@… 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)

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

Download all attachments as: .zip

Change History (15)

by (none), 18 years ago

Attachment: trac-post-commit-hook added

by (none), 18 years ago

Attachment: post-commit.bat added

comment:1 by ante.blaskovic@…, 18 years ago

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

comment:2 by anonymous, 18 years ago

Component: generalticket system
Priority: normalhighest

comment:3 by anonymous, 18 years ago

Type: defecttask

comment:4 by core@…, 18 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.

by ante.blaskovic@…, 18 years ago

Attachment: post-commit.2.bat added

Unicode log file create

comment:5 by ante.blaskovic@…, 18 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:6 by ante.blaskovic@…, 18 years ago

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

by anonymous, 18 years ago

Attachment: post.commit.bat added

Last copy that works

by anonymous, 18 years ago

Attachment: svnfileR-47 added

example of unicode-log message

by anonymous, 18 years ago

Attachment: svnfileTMP-47 added

example of log message

comment:7 by ante.blaskovic@…, 18 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 anonymous, 18 years ago

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)

'

comment:9 by Christian Boos, 18 years ago

Resolution: duplicate
Status: newclosed

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.