我需要找到一个分支的第一个提交者,而不必检查所有整个分支。 从命令行很容易做到:
svn log -v --stop-on-copy http://subversion.repository.com/svn/repositoryname
我需要通过 python 脚本执行此操作,知道我该怎么做吗?我检查了 python 颠覆绑定(bind),但我无法理解如何去做,即使它看起来可以完成。
我们将不胜感激。
最佳答案
您可以只使用 Python 的 subprocess
模块:
from subprocess import Popen, PIPE
p = Popen('svn log -v --stop-on-copy http://subversion.repository.com/svn/repositoryname',
stdout=PIPE)
stdout, stderr = p.communicate()
这样您就可以运行任何您想要的 SVN 命令:只需检查 stdout
(也许还有 stderr
)以获得命令的结果。然后您可以使用例如正则表达式来解析检索到的数据:
>>> s = Popen('svn log', shell=True, stdout=PIPE).communicate()[0]
>>> m = re.search('\r\nr(?P<rev>\d+)\s+\|\s+(?P<author>\w+)\s+\|\s+(?P<timestamp>.*?)\s|', s)
{'timestamp': '2011-10-10 10:45:01 +0000 (wed, okt 10 2011)',
'rev': '1234',
'author': 'someuser'
}
关于python - 如何从 python 远程轮询颠覆历史/日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7876680/