I'm making an application in python that needs to be able to get information (date, author, files changed) about the latest commits to an svn repository.
I've been trying with the svn library and my application can get the information it needs by manually filtering through something like this:
import svn.local
repo = svn.local.LocalClient('/my/svn/repo')
for rel_path, entry in repo.list_recursive():
revision = entry['commit_revision']
date = entry['date']
The problem with this is that it iterates through every file in the repo, getting commit info on the file, and the load time is nearly a minute long on a fairly powerful machine.
If it's possible, I'm looking for some way to iterate through a list of commits starting with the latest revision going back N revisions where N will be provided by the user.
According to the documentation there is a log_default
method which would allow you to do this easier and even has an option limit
which could be used to get the n
items. For example:
import svn.local
def print_commits(repo, limit=5):
client = svn.local.LocalClient(repo)
for commit in client.log_default(limit=limit):
revision = commit.revision
date = commit.date
print("{}:{}".format(date, revision))
print_commits("repo")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.