SVN预提交钩子编码
我正在使用Python脚本来实现SVN预提交挂钩:
svnlookPath = 'path-to-svnlook'
f = subprocess.Popen([svnlookPath, 'log', sys.argv[1], '--transaction', sys.argv[2]], stdout=subprocess.PIPE).stdout
commitMessage = f.read()
f.close()
commitMessage = commitMessage.rstrip('\n\r')
print >> sys.stderr, 'Commit message: "' + commitMessage + '"'
sys.exit(1)
我的pre-commit.bat(服务器托管在Windows Server 2008上) :
@python.exe path-to-py-file %1 %2
在客户端我使用TortoiseSVN。
一切顺利,除了提交消息编码。例如,如果提交消息包含俄语字母,它们将显示为“?” (问号)在 Tortoise 窗口中。
I'm using Python script to implement SVN pre-commit hook:
svnlookPath = 'path-to-svnlook'
f = subprocess.Popen([svnlookPath, 'log', sys.argv[1], '--transaction', sys.argv[2]], stdout=subprocess.PIPE).stdout
commitMessage = f.read()
f.close()
commitMessage = commitMessage.rstrip('\n\r')
print >> sys.stderr, 'Commit message: "' + commitMessage + '"'
sys.exit(1)
My pre-commit.bat (server is hosted on Windows Server 2008):
@python.exe path-to-py-file %1 %2
On a client side I use TortoiseSVN.
Everything goes ok, except commit message encoding. If the commit message contains, for example, Russian letters they are shown as '?' (question marks) in Tortoise window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想说这更多是
.bat
的错误,而不是 python 脚本的错误,因为 python 具有出色的 unicode 支持。或许这个问题的答案可以帮到你。
批处理文件编码
I would say this is more the fault of the
.bat
then of the python script, because python has excellent unicode support.Perhaps the answer of this question can help you.
Batch file encoding
问题可能出在乌龟本身。尝试以下
svn log http://rev_url
并查看 svn 所说的日志注释是什么。如果正确的话,那么 Tortoise 可能没有显示俄语编码。如果您在没有预提交挂钩的情况下提交会发生什么?这显示正确吗?
The problem could be Tortoise itself. Try the following
svn log http://rev_url
and see what svn says the log comment is. If it gets it right, then its probably Tortoise not showing the Russian encoding. What happens if you commit without your pre-commit hook? Does that show correctly?