pysvn是否允许您以相反的顺序限制日志消息?

时间:2013-09-10 14:11:12

标签: python svn pysvn

基本上我想要和正在运行的行为相同:

log = client.log(url)
oldestEntry = log[-1]

除了不必下载整个日志。我知道设置

limit=1

可让您找到最新的条目。有没有办法限制相反的顺序?

1 个答案:

答案 0 :(得分:1)

撤消revision_startrevision_end的顺序,并将limit设为1:

import pysvn

url='http://svn.apache.org/repos/asf/httpd/httpd/trunk/README'

epoch = pysvn.Revision(pysvn.opt_revision_kind.number, 0)
head = pysvn.Revision(pysvn.opt_revision_kind.head)

client = pysvn.Client()

# Get all entries
l = client.log(url)
print len(l), l[0].revision, l[-1].revision

# Get most recent entry:
l = client.log(url, limit=1)
print len(l), l[0].revision

# Get most recent entry, again:
l = client.log(url, revision_start=head, revision_end=epoch, limit=1)
print len(l), l[0].revision

# Get least recent entry
l = client.log(url, revision_start=epoch, revision_end=head, limit=1)
print len(l), l[0].revision

结果是:

22 <Revision kind=number 1209505> <Revision kind=number 87470>
1 <Revision kind=number 1209505>
1 <Revision kind=number 1209505>
1 <Revision kind=number 87470>