Index: trac-post-commit-hook
===================================================================
--- trac-post-commit-hook	(Revision 1029)
+++ trac-post-commit-hook	(Arbeitskopie)
@@ -29,6 +29,8 @@
 # 
 # It should be called from the 'post-commit' script in Subversion, such as
 # via:
+# 
+# LINUX:
 #
 # REPOS="$1"
 # REV="$2"
@@ -42,6 +44,31 @@
 #  -u "$AUTHOR"    \
 #  -m "$LOG"
 #
+# WINDOWS: sample of post-commit.bat (must use temporary files for the log message)
+#
+##SET REPOS=%1
+##SET REV=%2
+##
+##::-----------------------------
+##::Call the TRAC post-commit hook
+##::
+##SET TRAC_ENV=C:\somewhere\trac\project
+##SET LOG_FILE=%TEMP%.\svnfileR-%REV%
+##SET AUT_FILE=%TEMP%.\svnfileA-%REV%
+##
+##svnlook log -r %REV% %REPOS%>%LOG_FILE%
+##svnlook author -r %REV% %REPOS%>%AUT_FILE%
+##
+##:: SET THE AUTHOR FROM THE FILE. The file is expected to contain only one line with this value
+##FOR /F %%A IN (%AUT_FILE%) DO SET AUTHOR=%%A
+##
+##python [trac-path]\contrib\trac-post-commit-hook.py -p "%TRAC_ENV%" -r "%REV%" -u "%AUTHOR%" -m "file:%LOG_FILE%"
+##DEL %LOG_FILE%
+##DEL %AUT_FILE%
+##::
+##::-----------------------------
+##
+#
 # It searches commit messages for text in the form of:
 #   command #1
 #   command #1, #2
@@ -114,6 +141,7 @@
     def __init__(self, project=options.project, author=options.user, rev=options.rev, msg=options.msg):
         self.author = author
         self.rev = rev
+        msg = self._readFromFile( msg )
         self.msg = "(In [%s]) %s" % (rev, msg)
         self.now = int(time.time()) 
         self.con = sqlite.connect(os.path.join(project, 'db', 'trac.db'), autocommit=0) 
@@ -150,6 +178,20 @@
             cur.execute("INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)",
                         int(tkt), self.now, self.author, 'comment', '', self.msg)
 
+    def _readFromFile(self, message):
+        """ Ivan Melnychuk: SOLUTION FOR WINDOWS SYSTEMS:
+        Windows does not support returning values from script.
+        Therefore temporary files may be used to keep some information like commit message
+        If the 'message' starts with 'file:', and the file with indicated name exists, then read the text message from the file rather then using the text directly
+        Even though actual message also may start with such prefix, it is very unlikely that the file exists with such a name by accident
+        """
+        if message[:5] == 'file:' and os.path.exists( message[5:] ):
+            f = open( message[5:], 'r' )
+            message = f.read()
+            f.close()
+            return message
+        return message;
+
     def verifyDatabaseVersion(self):
         """Make sure the database uses a known schema version"""
         cursor = self.con.cursor()
@@ -157,10 +199,10 @@
                        'name=%s AND value=%s', 'database_version', '7')
         if not cursor.fetchone():
             raise Exception('Expected Trac database version 7')
-                        
+
 if __name__ == "__main__":
     if len(sys.argv) < 5:
         print "For usage: %s --help" % (sys.argv[0])
     else:
         CommitHook()
-    
+

