forked from tobami/codespeed
-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathsubversion.py
More file actions
77 lines (63 loc) · 2.28 KB
/
subversion.py
File metadata and controls
77 lines (63 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# -*- coding: utf-8 -*-
"""Subversion commit logs support"""
from __future__ import absolute_import
from datetime import datetime
from .exceptions import CommitLogError
def updaterepo(project):
"""Not needed for a remote subversion repo"""
return [{'error': False}]
def get_tag(rev_num, repo_path, client):
tags_url = repo_path + '/tags'
tags = client.ls(tags_url)
for tag in tags:
if 'created_rev' in tag and tag['created_rev'].number == rev_num:
if 'name' in tag:
return tag['name'].split('/')[-1]
return ''
def getlogs(newrev, startrev):
import pysvn
logs = []
log_messages = []
loglimit = 200
def get_login(realm, username, may_save):
repo_user = newrev.branch.project.repo_user
repo_pass = newrev.branch.project.repo_pass
return True, repo_user, repo_pass, False
client = pysvn.Client()
if newrev.branch.project.repo_user != "":
client.callback_get_login = get_login
try:
log_messages = \
client.log(
newrev.branch.project.repo_path,
revision_start=pysvn.Revision(
pysvn.opt_revision_kind.number, startrev.commitid
),
revision_end=pysvn.Revision(
pysvn.opt_revision_kind.number, newrev.commitid
)
)
except pysvn.ClientError as e:
raise CommitLogError(e.args)
except ValueError:
raise CommitLogError(
"'%s' is an invalid subversion revision number" % newrev.commitid)
log_messages.reverse()
s = len(log_messages)
while s > loglimit:
log_messages = log_messages[:s]
s = len(log_messages) - 1
for log in log_messages:
try:
author = log.author
except AttributeError:
author = ""
date = datetime.fromtimestamp(log.date).strftime("%Y-%m-%d %H:%M:%S")
message = log.message
tag = get_tag(log.revision.number,
newrev.branch.project.repo_path, client)
# Add log unless it is the last commit log, which has already been tested
logs.append({
'date': date, 'author': author, 'message': message,
'commitid': log.revision.number, 'tag': tag})
return logs