目录
显示
SVN 命令行获取提交日志
一、命令帮助
svn help log
帮助内容:
>svn help log log: Show the log messages for a set of revision(s) and/or path(s). usage: 1. log [PATH][@REV] 2. log URL[@REV] [PATH...] 1. Print the log messages for the URL corresponding to PATH (default: '.'). If specified, REV is the revision in which the URL is first looked up, and the default revision range is REV:1. If REV is not specified, the default revision range is BASE:1, since the URL might not exist in the HEAD revision. 2. Print the log messages for the PATHs (default: '.') under URL. If specified, REV is the revision in which the URL is first looked up, and the default revision range is REV:1; otherwise, the URL is looked up in HEAD, and the default revision range is HEAD:1. Multiple '-c' or '-r' options may be specified (but not a combination of '-c' and '-r' options), and mixing of forward and reverse ranges is allowed. With -v, also print all affected paths with each log message. Each changed path is preceded with a symbol describing the change: A: The path was added or copied. D: The path was deleted. R: The path was replaced (deleted and re-added in the same revision). M: The path's file and/or property content was modified. If an added or replaced path was copied from somewhere else, the copy source path and revision are shown in parentheses. If a file or directory was moved from one path to another with 'svn move' the old path will be listed as deleted and the new path will be listed as copied from the old path at a prior revision. With -q, don't print the log message body itself (note that this is compatible with -v). Each log message is printed just once, even if more than one of the affected paths for that revision were explicitly requested. Logs follow copy history by default. Use --stop-on-copy to disable this behavior, which can be useful for determining branchpoints. The --depth option is only valid in combination with the --diff option and limits the scope of the displayed diff to the specified depth. If the --search option is used, log messages are displayed only if the provided search pattern matches any of the author, date, log message text (unless --quiet is used), or, if the --verbose option is also provided, a changed path. The search pattern may include "glob syntax" wildcards: ? matches any single character * matches a sequence of arbitrary characters [abc] matches any of the characters listed inside the brackets If multiple --search options are provided, a log message is shown if it matches any of the provided search patterns. If the --search-and option is used, that option's argument is combined with the pattern from the previous --search or --search-and option, and a log message is shown only if it matches the combined search pattern. If --limit is used in combination with --search, --limit restricts the number of log messages searched, rather than restricting the output to a particular number of matching log messages. Examples: Show the latest 5 log messages for the current working copy directory and display paths changed in each commit: svn log -l 5 -v Show the log for bar.c as of revision 42: svn log bar.c@42 Show log messages and diffs for each commit to foo.c: svn log --diff http://www.example.com/repo/project/foo.c (Because the above command uses a full URL it does not require a working copy.) Show log messages for the children foo.c and bar.c of the directory '/trunk' as it appeared in revision 50, using the ^/ URL shortcut: svn log ^/trunk@50 foo.c bar.c Show the log messages for any incoming changes to foo.c during the next 'svn update': svn log -r BASE:HEAD foo.c Show the log message for the revision in which /branches/foo was created: svn log --stop-on-copy --limit 1 -r0:HEAD ^/branches/foo Show all log messages for commits between the tags ^/tags/2.0 and ^/tags/3.0; assuming that tag 2.0 was created in revision 100: svn log -rHEAD:100 ^/tags/3.0 If ^/trunk/foo.c was moved to ^/trunk/bar.c' in revision 22, 'svn log -v' shows a deletion and a copy in its changed paths list, such as: D /trunk/foo.c A /trunk/bar.c (from /trunk/foo.c:21) Valid options: -r [--revision] ARG : ARG (some commands also take ARG1:ARG2 range) A revision argument can be one of: NUMBER revision number '{' DATE '}' revision at start of the date 'HEAD' latest in repository 'BASE' base rev of item's working copy 'COMMITTED' last commit at or before BASE 'PREV' revision just before COMMITTED -c [--change] ARG : the change made in revision ARG -q [--quiet] : do not print the log message -v [--verbose] : also print all affected paths -g [--use-merge-history] : use/display additional information from merge history --targets ARG : pass contents of file ARG as additional args --stop-on-copy : do not cross copies while traversing history --incremental : give output suitable for concatenation --xml : output in XML -l [--limit] ARG : maximum number of log entries --with-all-revprops : retrieve all revision properties --with-no-revprops : retrieve no revision properties --with-revprop ARG : retrieve revision property ARG --depth ARG : limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity') --diff : produce diff output --diff-cmd ARG : use ARG as diff command --internal-diff : override diff-cmd specified in config file -x [--extensions] ARG : Specify differencing options for external diff or internal diff or blame. Default: '-u'. Options are separated by spaces. Internal diff and blame take: -u, --unified: Show 3 lines of unified context -b, --ignore-space-change: Ignore changes in amount of white space -w, --ignore-all-space: Ignore all white space --ignore-eol-style: Ignore changes in EOL style -U ARG, --context ARG: Show ARG lines of context -p, --show-c-function: Show C function name --search ARG : use ARG as search pattern (glob syntax, case- and accent-insensitive, may require quotation marks to prevent shell expansion) --search-and ARG : combine ARG with the previous search pattern (Use '-v' to show global and experimental options.)
二、显示某个日期或日期范围的日志
2.1 某个日期的日志
svn log -r '{20220719}'
这个命令参数解释是:revision at start of the date。
实际情况如下:
可以看到,每次基本只能显示一条记录,大致是给定的日期开始时的最新版本的提交日志,所以获取的是给定日期前(前一天或更早之前)。但是有一个参数为当天(20220720)的,获取结果为空,不知何故。
2.2 某个日期范围的日志
这个需求,帮助文档中没有体现,经过摸索,命令格式如下:
svn log -r '{20220719}:{20220720}'
效果:
当天(20220720)更新到新的提交后,使用范围命令感觉就正常了(但是和前面的效果感觉是两套逻辑呀):
以上为在 PowerShell 中的情况,在命令提示符中需要将参数的引号去掉:
2.3 获取当天的提交日志
说明:基于 “2.2 某个日期范围的日志”,动态获取当天和第二天的日期并拼接为参数。
GetCommitLog.bat:
:@echo off set Today=%date:~0,4%-%date:~5,2%-%date:~8,2% echo 当前日期是:%Today% echo Wscript.echo dateadd("d",1,date)>vbs.vbs for /f %%a in ('cscript /nologo vbs.vbs') do del vbs.vbs&&set yyyymmdd=%%a for /f "tokens=1,2,3* delims=// " %%i in ('echo %yyyymmdd%') do set yyyy=%%i&set mm=%%j&set dd=%%k if %mm% LSS 9 set mm=0%mm% if %dd% LSS 9 set dd=0%dd% set tomorrow=%yyyy%-%mm%-%dd% echo tomorrow is : %tomorrow% set para={%Today%}:{%tomorrow%} SETLOCAL ENABLEDELAYEDEXPANSION for /f "delims=" %%i in ('svn log -r %para%') do ( set str=!str! %%i ) echo "%str%" pause
效果(乱入了前一天的日志,这是之前说过的问题):
注:获取当天和第二天日期的脚本参考以下两篇文章,《[bat 文件 cmd 命令获取系统日期格式](https://blog.51cto.com/lexsaints/2806267)》和《[bat 获取明天日期](https://blog.csdn.net/weixin_41710606/article/details/115673362)》
全文完。
原创文章,转载请注明: 转载自 独立观察员(dlgcy.com)
本文链接地址: [SVN 命令行获取提交日志](https://dlgcy.com/svn-command-get-commit-log/)
关注微信公众号 独立观察员博客(DLGCY_BLOG) 第一时间获取最新文章
发表评论