获取 SVN 中的最后一个修订号? [英] Getting the last revision number in SVN?
问题描述
使用 PHP、Perl 或 Python(最好是 PHP),我需要一种方法来查询 SVN 数据库并找出发送给 SVN 的最后一个修订号.除此之外我不需要任何东西.它需要是非密集型的(所以我每 5 分钟做一次作为 cron 作业;SVN 的性能不应该受到影响).
Using PHP, Perl, or Python (preferably PHP), I need a way to query an SVN database and find out the last revision number sent to SVN. I don't need anything other than that. It needs to be non-intensive (so I do it every 5 minutes as a cron job; SVN's performance should not be affected).
SVN 位于我的 Intranet 上,但不在我的特定计算机上.
SVN is located on my Intranet, but not my specific computer.
我安装了 SVN,但没有为 PHP/Perl/Python 安装绑定.我正在运行 Windows XP,但我更喜欢一个也可以在 Linux 中运行的独立于平台的解决方案.如果您有仅适用于 Linux(或仅适用于 XP)的解决方案,那也会有所帮助.
I have SVN installed, but no bindings installed for PHP/Perl/Python. I'm running Windows XP, but I would prefer a platform-independent solution that can also work in Linux. If you have a Linux-only (or XP-only) solution, that would also be helpful.
推荐答案
<?php
$url = 'your repository here';
$output = `svn info $url`;
echo "<pre>$output</pre>";
?>
您可以像这样获得 XML 格式的输出:
You can get the output in XML like so:
$output = `svn info $url --xml`;
如果出现错误,则输出将定向到 stderr.要在输出中捕获标准错误,请使用:
If there is an error then the output will be directed to stderr. To capture stderr in your output use thusly:
$output = `svn info $url 2>&1`;
这篇关于获取 SVN 中的最后一个修订号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!