Skip to content

Commit 862e5b7

Browse files
committed
Merge branch 'master' into speed.python.org
Updates from upstream
2 parents 7d8a820 + f6e9c37 commit 862e5b7

29 files changed

Lines changed: 555 additions & 414 deletions

.travis.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
language: python
22
python:
3-
- 2.6
43
- 2.7
54
- 3.4
65
env:
76
- DJANGO_VERSION=1.8.5
87
- DJANGO_VERSION=1.6.11
9-
- DJANGO_VERSION=1.4.22
10-
matrix:
11-
exclude:
12-
- python: 2.6
13-
env: DJANGO_VERSION=1.8.5
14-
- python: 3.4
15-
env: DJANGO_VERSION=1.4.22
168
install:
179
- pip install -q Django==$DJANGO_VERSION
1810
- python setup.py install

codespeed/commits/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .logs import get_logs

codespeed/commits/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import, unicode_literals
3+
4+
class CommitLogError(Exception):
5+
"""An error when trying to display commit log messages"""
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from django.conf import settings
77

8+
from .exceptions import CommitLogError
89

910
logger = logging.getLogger(__name__)
1011

@@ -19,8 +20,8 @@ def updaterepo(project, update=True):
1920

2021
stdout, stderr = p.communicate()
2122
if p.returncode != 0:
22-
raise RuntimeError("git pull returned %s: %s" % (p.returncode,
23-
stderr))
23+
raise CommitLogError("git pull returned %s: %s" % (p.returncode,
24+
stderr))
2425
else:
2526
return [{'error': False}]
2627
else:
@@ -32,7 +33,7 @@ def updaterepo(project, update=True):
3233
stdout, stderr = p.communicate()
3334

3435
if p.returncode != 0:
35-
raise RuntimeError("%s returned %s: %s" % (
36+
raise CommitLogError("%s returned %s: %s" % (
3637
" ".join(cmd), p.returncode, stderr))
3738
else:
3839
return [{'error': False}]
@@ -58,8 +59,8 @@ def getlogs(endrev, startrev):
5859
stdout, stderr = p.communicate()
5960

6061
if p.returncode != 0:
61-
raise RuntimeError("%s returned %s: %s" % (
62-
" ".join(cmd), p.returncode, stderr))
62+
raise CommitLogError("%s returned %s: %s" % (
63+
" ".join(cmd), p.returncode, stderr))
6364
logs = []
6465
for log in filter(None, stdout.split("\x1e")):
6566
(short_commit_id, commit_id, date_t, author_name, author_email,
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
Among other things, this means that the codespeed server doesn't need to have
66
git installed, the ability to write files, etc.
77
"""
8+
from __future__ import absolute_import
9+
810
import logging
911
import urllib
1012
import re
@@ -13,6 +15,8 @@
1315
import isodate
1416
from django.core.cache import cache
1517

18+
from .exceptions import CommitLogError
19+
1620
logger = logging.getLogger(__name__)
1721

1822
GITHUB_URL_RE = re.compile(
@@ -52,7 +56,7 @@ def retrieve_revision(commit_id, username, project, revision=None):
5256
cache.set(commit_url, commit_json, 86400 * 30)
5357

5458
if commit_json["message"] in ("Not Found", "Server Error",):
55-
raise RuntimeError("Unable to load %s: %s" % (commit_url, commit_json["message"]))
59+
raise CommitLogError("Unable to load %s: %s" % (commit_url, commit_json["message"]))
5660

5761
date = isodate.parse_datetime(commit_json['committer']['date'])
5862

codespeed/commits/logs.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import, unicode_literals
3+
4+
import logging
5+
6+
logger = logging.getLogger(__name__)
7+
8+
9+
def get_logs(rev, startrev, update=False):
10+
logs = []
11+
project = rev.branch.project
12+
if project.repo_type == project.SUBVERSION:
13+
from .subversion import getlogs, updaterepo
14+
elif project.repo_type == project.MERCURIAL:
15+
from .mercurial import getlogs, updaterepo
16+
elif project.repo_type == project.GIT:
17+
from .git import getlogs, updaterepo
18+
elif project.repo_type == project.GITHUB:
19+
from .github import getlogs, updaterepo
20+
else:
21+
if project.repo_type not in (project.NO_LOGS, ""):
22+
logger.warning("Don't know how to retrieve logs from %s project",
23+
project.get_repo_type_display())
24+
return logs
25+
26+
if update:
27+
updaterepo(rev.branch.project)
28+
29+
logs = getlogs(rev, startrev)
30+
31+
# Remove last log because the startrev log shouldn't be shown
32+
if len(logs) > 1 and logs[-1].get('commitid') == startrev.commitid:
33+
logs.pop()
34+
35+
return logs
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
14
import os
25
import datetime
36
from subprocess import Popen, PIPE
47
import logging
58

69
from django.conf import settings
710

11+
from .exceptions import CommitLogError
812

913
logger = logging.getLogger(__name__)
1014

@@ -19,8 +23,8 @@ def updaterepo(project, update=True):
1923
stdout, stderr = p.communicate()
2024

2125
if p.returncode != 0 or stderr:
22-
raise RuntimeError("hg pull returned %s: %s" % (p.returncode,
23-
stderr))
26+
raise CommitLogError("hg pull returned %s: %s" % (p.returncode,
27+
stderr))
2428
else:
2529
return [{'error': False}]
2630
else:
@@ -34,9 +38,9 @@ def updaterepo(project, update=True):
3438
stdout, stderr = p.communicate()
3539

3640
if p.returncode != 0:
37-
raise RuntimeError("%s returned %s: %s" % (" ".join(cmd),
38-
p.returncode,
39-
stderr))
41+
raise CommitLogError("%s returned %s: %s" % (" ".join(cmd),
42+
p.returncode,
43+
stderr))
4044
else:
4145
return [{'error': False}]
4246

@@ -53,7 +57,7 @@ def getlogs(endrev, startrev):
5357
stdout, stderr = p.communicate()
5458

5559
if p.returncode != 0:
56-
raise RuntimeError(str(stderr))
60+
raise CommitLogError(str(stderr))
5761
else:
5862
stdout = stdout.rstrip('\n') # Remove last newline
5963
logs = []
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# -*- coding: utf-8 -*-
2-
'''Subversion commit logs support'''
2+
"""Subversion commit logs support"""
3+
# -*- coding: utf-8 -*-
4+
from __future__ import absolute_import
5+
36
from datetime import datetime
47

8+
from .exceptions import CommitLogError
9+
510

611
def updaterepo(project):
712
"""Not needed for a remote subversion repo"""
@@ -34,9 +39,9 @@ def get_login(realm, username, may_save):
3439
)
3540
)
3641
except pysvn.ClientError as e:
37-
raise RuntimeError(e.args)
42+
raise CommitLogError(e.args)
3843
except ValueError:
39-
raise RuntimeError(
44+
raise CommitLogError(
4045
"'%s' is an invalid subversion revision number" % newrev.commitid)
4146
log_messages.reverse()
4247
s = len(log_messages)

0 commit comments

Comments
 (0)