forked from tobami/codespeed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
140 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os, datetime | ||
from subprocess import Popen, PIPE | ||
|
||
path = os.getcwd() + '/repos/' | ||
repodir = path + 'pypy/' | ||
|
||
def updaterepo(repo): | ||
if os.path.exists(repodir): | ||
cmd = "hg up" | ||
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, cwd=repodir) | ||
stdout, stderr = p.communicate() | ||
if stderr: | ||
return [{'error': True, 'message': stderr}] | ||
else: | ||
return [{'error': False}] | ||
else: | ||
#os.mkdir(path) | ||
cmd = "hg clone %s" % repo | ||
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, cwd=path) | ||
stdout, stderr = p.communicate() | ||
if stderr: | ||
return [{'error': True, 'message': stderr}] | ||
else: | ||
return [{'error': False}] | ||
|
||
def getlogs(endrev, startrev): | ||
if not os.path.exists(repodir): | ||
updaterepo(endrev.project.repo_path) | ||
|
||
cmd = "hg log -r %s:%s --template '{rev}:{node|short}\n{author|person} / {author|user}\n{date}\n{desc}\n=newlog=\n'" % (endrev.commitid, startrev.commitid) | ||
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, cwd=repodir) | ||
stdout, stderr = p.communicate() | ||
if stderr: | ||
return [{'error': True, 'message': stderr}] | ||
else: | ||
logs = [] | ||
for log in stdout.split("=newlog=\n"): | ||
commitid, author, date, message = ("","","","") | ||
elements = [] | ||
elements = log.split('\n')[:-1] | ||
if not len(elements) or len(elements) < 4: | ||
continue | ||
else: | ||
commitid = elements.pop(0) | ||
author = elements.pop(0) | ||
date = elements.pop(0) | ||
message = '\n'.join(elements) | ||
|
||
# Parse date | ||
date = date.split('-')[0] | ||
date = datetime.datetime.fromtimestamp(float(date)).strftime("%Y-%m-%d %H:%M:%S") | ||
|
||
# Add changeset info | ||
logs.append({'date': date, 'author': author, 'message': message, | ||
'commitid': commitid}) | ||
return logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# -*- coding: utf-8 -*- | ||
'''Subversion commit logs support''' | ||
from datetime import datetime | ||
|
||
def getlogs(newrev, startrev): | ||
import pysvn | ||
|
||
logs = [] | ||
log_messages = [] | ||
loglimit = 200 | ||
|
||
def get_login(realm, username, may_save): | ||
return True, newrev.project.repo_user, newrev.project.repo_pass, False | ||
|
||
client = pysvn.Client() | ||
if newrev.project.repo_user != "": | ||
client.callback_get_login = get_login | ||
|
||
try: | ||
log_messages = \ | ||
client.log( | ||
newrev.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: | ||
return [ | ||
{'error': True, | ||
'message': "Could not resolve '" + newrev.project.repo_path + "'"}] | ||
except ValueError: | ||
return [{ | ||
'error': True, | ||
'message': "'%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 | ||
# Add log unless it is the last commit log, which has already been tested | ||
if not (startrev != newrev and log.revision.number == int(startrev.commitid)): | ||
logs.append( | ||
{'date': date, 'author': author, 'message': message, | ||
'commitid': log.revision.number}) | ||
return logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters