我想从SVN文件日志中进行'分页'。例如,修改可以是50、45、40、35、30、25、20、15、10、5,我的页面是第一页,每页3项。所以我可以用svn log -r 50:1 -l 3 repo.url/file.ext
取50,45和40转。但是我怎么能知道从什么修订采取下一个请求,例如第3页(必须是20,15,10)?svn log
中没有skip n
参数,所以不能调用svn log -r 50:1 -l 3 --skip (page*perPage)
。有什么建议吗?
我知道这是一个古老的问题,但这里。虽然我真诚地希望@denn很久以前就找到了答案,但我把这篇文章留在这里,以帮助未来的谷歌搜索者。
我认为最简单的答案是从1到HEAD修订运行一个for/do循环。请注意,由于您没有指定操作系统,所以我在PowerShell中编写这篇文章,并且应该能够根据您的需要进行调整。
####################################################################
####################################################################
### These two variables are the only ones you need to customize
### for your own environment/needs.
###
### Note that it may take some experimentation to determine the best
### value for $LogPerPg; I have set '5' here to follow @denn's example.
####################################################################
# If you want the log for the entire repository, leave off the "/FolderPath"
# (remember to remove that final slash too)
$SvnPath = 'https://SvnPath/RepoName/FolderPath'
# Set the number of log entries to show per page
# and initialize its variable as an integer
[int]$LogPerPg = 5
####################################################################
####################################################################
# The '--show-item revision' parameter will retrieve the revision number of the HEAD
[int]$MaxRev = $(svn info --show-item revision $SvnPath)
# Initialize these variables as integers
[int]$RevCount = 0
[int]$RevUpper = 0
[int]$RevLower = 0
# Loop through from $MaxRev down to 1
for (
# Set the max bound for the entire loop
$RevCount=$MaxRev
# Determine the condition that will cause the loop to stop
$RevCount -gt 0
# Perform an action after each loop is completed
$RevCount = $RevCount - $LogPerPg
) {
# Determine if this will be the final loop or not
if ( $RevCount -ge $LogPerPg ) {
# Note that this same formula inside the FOR condition is only applied
# AFTER the loop, so it is necessary to repeat it inside the loop to
# establish a lower bound
$RevLower = $RevCount - $LogPerPg
} else {
$RevLower = 1
}
# Set the upper revision for this loop
$RevUpper = $RevCount
# Run the log between established bounds
& svn log -r"${RevUpper}:${RevLower}" $SvnPath
# Note that this method **only** accepts the <Enter> key.
Read-Host -Prompt "`n`nPress <Enter> to see the next $LogPerPg revisions"
# Uncomment the next line if you would like the screen to clear between each iteration
# Clear-Host
}
####################################################################
# Final note: I have demonstrated how to display the logs from
# HEAD back to 1. If you want to see from 1 up to HEAD, read on
# A. replace the following lines:
# 33: $RevCount=1
# 35: $RevCount -le $MaxRev
# 37: $RevCount = $RevCount + $LogPerPg
# 41: if ( $RevCount -ge ( $MaxRev - $LogPerPg ) ) {
# 45: $RevLower = $RevCount + $LogPerPg
# 47: $RevLower = $MaxRev
# 51: $RevUpper = $RevCount
#
# B. For reading-logic, you will also want to reverse all instances
# of $RevLower and $RevUpper throughout the entire script
####################################################################
注意:我使用4个空格的制表符展开;如果你使用不同的值,你的缩进可能看起来和我的不一样。