【问题标题】:SVN Getting The Count Of Revisions Of A RepositorySVN 获取存储库的修订计数
【发布时间】:2018-06-28 12:56:29
【问题描述】:

我目前正在开发一个 Qt c++ 项目,该项目基本上打印特定 SVN 存储库的 2 个特定修订版(用户输入存储库和修订版)之间的所有提交日志消息。

我需要获取 repo URL 中的修订计数。

我想在 Windows 10 上执行此操作,所以我猜批处理命令可能非常有用。

我正在使用 Visual SVN 服务器和 Tortoise SVN。

(如果需要,我的 Qt 版本是 5.11.1)

我有一个批处理脚本,可以打印 .txt 文件的 2 个特定修订版本之间的所有日志。

是这样的:

@ECHO OFF

REM This Script Takes all the logs between a given repository's 2 specific revision.

REM Below, we store the first parameter which is the URL of the Repository that is wanted.
SET urlOfRepository=%1

REM Below, we store the second parameter which is the first revision that is wanted.
SET firstRevision=%2

REM Below, we store the third parameter which is the second revision that is wanted.
SET secondRevision=%3

REM Below is the command for getting all the log messages between the first and the second revision that is wanted in the wanted repository and printing to a .txt file.
svn log -r %firstRevision%:%secondRevision% --limit %secondRevision% %urlOfRepository% > svnLog.txt

EXIT /B 0

如果有人可以帮助我,我会很高兴。

如果需要,我可以进一步澄清问题,因此请随时通过 cmets 与我联系。

提前致谢。

感谢 Kostix,答案是:

svn info -r HEAD --show-item revision %URL%

我已经编写了一个脚本来解决我的问题。这里是:

@ECHO OFF

REM This Script writes the revision count of a specific SVN repository

REM Below, we store the first parameter which is the URL of the Repository that is wanted.
SET urlOfRepository=%1

REM Below, is the command that returns the count of revisions in the specifically given SVN repository and writes to a .txt file
svn info -r HEAD --show-item revision %urlOfRepository% > svnCountOfRepoRevisions.txt

EXIT /B 0

【问题讨论】:

  • 将定义添加到 makefile DEFINES += "SVN_REV=\"\\\"$(shell svnversion -n)\\\"\"" 它会给你当前的 svn 版本。

标签: qt batch-file svn tortoisesvn visualsvn-server


【解决方案1】:

没必要搞那么复杂——就一个

svn log -r HEAD:1 %URL%

应该可以。

特殊的HEAD 修订版自动成为存储库中的最后一个,修订版 1 是第一个(显然)。

Subversion 足够聪明,可以跳过 URL 没有的修订 存在,因此,如果它是在修订版 42 中添加的,svn log 不会抱怨修订版范围 [41…1] 中没有 URL。


您可以通过运行获取更多信息

svn help log

在您的控制台窗口中。

【讨论】:

  • 哦,您也可以使用 BASE 修订版——以防万一该 URL 不再存在于 HEAD(可能已超过 BASE)。
  • @kostix 我的脚本确实会打印您编写的命令的输出(svn log -r HEAD:1 %URL%)。谢谢你的回答。我只需要 HEAD 的值,这样我就可以在 QListWidget 中列出修订。
  • 你可以做svn info -r HEAD --show-item revision %URL%tnen。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-12
  • 1970-01-01
  • 2010-09-19
  • 2011-07-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多