Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pypy
Browse files Browse the repository at this point in the history
Conflicts:
	example/templates/base.html
  • Loading branch information
tobami committed Sep 4, 2011
2 parents 6016259 + 47d8505 commit 55030e2
Show file tree
Hide file tree
Showing 15 changed files with 163 additions and 77 deletions.
2 changes: 1 addition & 1 deletion codespeed/fixtures/testdata.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions codespeed/mercurial.py
@@ -1,5 +1,7 @@
import os, datetime
from subprocess import Popen, PIPE
import logging

from django.conf import settings


Expand Down Expand Up @@ -52,8 +54,8 @@ def getlogs(endrev, startrev):
p = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=working_copy)
stdout, stderr = p.communicate()

if stderr:
return [{'error': True, 'message': stderr}]
if p.returncode != 0:
raise RuntimeError(str(stderr))
else:
stdout = stdout.rstrip('\n')#Remove last newline
logs = []
Expand Down
16 changes: 6 additions & 10 deletions codespeed/models.py
Expand Up @@ -73,10 +73,6 @@ def clean(self):
long(self.commitid)
except ValueError:
raise ValidationError("Invalid SVN commit id %s" % self.commitid)
elif self.branch.project.repo_type in ("M", "G", "H") and len(self.commitid) != 40:
raise ValidationError("Invalid %s commit hash %s" % (
self.branch.project.get_repo_type_display(),
self.commitid))


class Executable(models.Model):
Expand Down Expand Up @@ -280,15 +276,15 @@ def get_changes_table(self, trend_depth=10, force_save=False):
return self._get_tablecache()
# Otherwise generate a new changes table
# Get latest revisions for this branch (which also sets the project)
lastrevisions = Revision.objects.filter(
branch=self.revision.branch
).filter(
date__lte=self.revision.date
).order_by('-date')[:trend_depth+1]
try:
lastrevisions = Revision.objects.filter(
branch=self.revision.branch
).filter(
date__lte=self.revision.date
).order_by('-date')[:trend_depth+1]
# Same as self.revision unless in a different branch
lastrevision = lastrevisions[0]
except IndexError:
except:
return []
change_list = []
pastrevisions = []
Expand Down
3 changes: 3 additions & 0 deletions codespeed/settings.py
Expand Up @@ -6,6 +6,9 @@

DEF_ENVIRONMENT = None #Name of the environment which should be selected as default

DEF_BRANCH = "default" # Defines the default branch to be used.
# In git projects, this branch is usually be calles
# "master"

DEF_BASELINE = None # Which executable + revision should be default as a baseline
# Given as the name of the executable and commitid of the revision
Expand Down
5 changes: 2 additions & 3 deletions codespeed/static/js/codespeed.js
Expand Up @@ -155,9 +155,8 @@ function renderComparisonPlot(plotid, benchmarks, exes, enviros, baseline, chart
var benchlabel = $("label[for='benchmark_" + benchmarks[b] + "']").text();
var baselinelabel = $("label[for='exe_" + baseline + "']").text();
var msg = "<strong>"+ title + "</strong>" + "<br><br>";
msg += "Could not render plot because baseline "+baselinelabel+" has empty results for benchmark " + benchlabel;
msg += "Could not render plot because the chosen baseline has empty results for benchmark " + benchlabel;
return abortRender(plotid, msg);
val = 0.0001;
} else {
baseline_is_empty = false;
val = val / baseval;
Expand All @@ -181,7 +180,7 @@ function renderComparisonPlot(plotid, benchmarks, exes, enviros, baseline, chart
if (baseline_is_empty) {
var baselinelabel = $("label[for='exe_" + baseline + "']").text();
var msg = "<strong>"+ title + "</strong>" + "<br><br>";
msg += "Could not render plot because baseline "+baselinelabel+" is empty";
msg += "Could not render plot because the chosen baseline is empty";
return abortRender(plotid, msg);
return -1;
}
Expand Down
11 changes: 4 additions & 7 deletions codespeed/subversion.py
Expand Up @@ -34,14 +34,11 @@ def get_login(realm, username, may_save):
)
)
except pysvn.ClientError:
return [
{'error': True,
'message': "Could not resolve '" + newrev.branch.project.repo_path + "'"}]
raise RuntimeError(
"Could not resolve '" + newrev.branch.project.repo_path + "'")
except ValueError:
return [{
'error': True,
'message': "'%s' is an invalid subversion revision number" % newrev.commitid
}]
raise RuntimeError(
"'%s' is an invalid subversion revision number" % newrev.commitid)
log_messages.reverse()
s = len(log_messages)
while s > loglimit:
Expand Down
15 changes: 8 additions & 7 deletions codespeed/templates/codespeed/changes.html
Expand Up @@ -141,14 +141,15 @@
<div id="executable" class="sidebox">
<div class="boxhead"><h2>Executable</h2></div>
<div class="boxbody">
<ul>
{% for exec in executables|dictsort:"id" %}
<li title="{{ exec.description }}">
<input id="executable{{ exec.id }}" type="radio" name="executable" value="{{ exec.id }}" />
<label for="executable{{ exec.id }}">{{ exec }}</label>
</li>
{% if executables|length > 1 %}<ul>{% endif %}{% for proj, execs in executables.items %}
<ul>{% if executables|length > 1 %}{{ proj }}{% endif %}{% for exec in execs|dictsort:"name" %}
<li title="{{ exec.description }}"><!-- the input id != value. It is used for exeutable color order -->
<input id="executable{{ exec.id }}" type="radio" name="executable" value="{{ exec.id }}" />
<label for="executable{{ exec.id }}">{{ exec }}</label><div class="seriescolor"></div>
</li>{% endfor %}
</ul>
{% endfor %}
</ul>
{% if executables|length > 1 %}</ul>{% endif %}
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions codespeed/templates/codespeed/comparison.html
Expand Up @@ -164,7 +164,7 @@
<div class="boxhead"><h2>Executables</h2></div>
<div class="boxbody">
{% for proj, executable in executables.items %}
<ul>{{ proj }} (<a href="#" class="checkall">All</a>, <a href="#" class="uncheckall">None</a>)
<ul>{{ proj }} <a href="#" class="checkall">(All</a>, <a href="#" class="uncheckall">None)</a>
{% for exe in executable %}
<li title="{{ exe.executable }} - {{ exe.revision }}">
<input id="exe_{{ exe.key }}" type="checkbox" name="executables" value="{{ exe.key }}" />
Expand All @@ -177,7 +177,7 @@
<div class="boxhead"><h2>Benchmarks</h2></div>
<div class="boxbody">
{% for key,benchlist in benchmarks.items %}
<ul>{{ key }} (<a href="#" class="checkall">All</a>, <a href="#" class="uncheckall">None</a>)
<ul>{{ key }} <a href="#" class="checkall">(All</a>, <a href="#" class="uncheckall">None)</a>
{% for bench in benchlist|dictsort:"name" %}
<li title="{{ bench.description }}">
<input id="benchmark_{{ bench.id }}" type="checkbox" name="benchmarks" value="{{ bench.id }}" />
Expand Down
34 changes: 27 additions & 7 deletions codespeed/templates/codespeed/timeline.html
Expand Up @@ -305,7 +305,7 @@
.attr('checked', true);

//Add color legend to executable list
$("#executable div.boxbody > ul > li > input").each(function() {
$("#executable div.boxbody > ul > ul > li > input").each(function() {
var colorid = $(this).attr("id").slice(10);
$(this).parent().find("div.seriescolor").css("background-color", seriesColors[colorid-1]);
});
Expand Down Expand Up @@ -339,6 +339,23 @@

// Init and change handlers are set to the refreshContent handler
$.address.init(initializeSite).change(refreshSite);

// Check all and none links
$('.checkall').click(function() {
$(this).parent().children("li").children("input").each(function() {
$(this).attr('checked', true);
});
refreshContent();
return false;
});

$('.uncheckall').click(function() {
$(this).parent().children("li").children("input").each(function() {
$(this).attr('checked', false);
});
refreshContent();
return false;
});
});
</script>
{% endblock %}
Expand Down Expand Up @@ -366,12 +383,15 @@
<div id="executable" class="sidebox">
<div class="boxhead"><h2>Executables</h2></div>
<div class="boxbody">
<ul class="clearfix">{% for exec in executables|dictsort:"id" %}
<li title="{{ exec.description }}"><!-- the input id != value. It is used for exeutable color order -->
<input id="executable{{ forloop.counter }}" type="checkbox" name="executable" value="{{ exec.id }}" />
<label for="executable{{ forloop.counter }}">{{ exec }}</label><div class="seriescolor"></div>
</li>{% endfor %}
</ul>
<ul class="clearfix">{% for proj, execs in executables.items %}
<ul>{{ proj }} <a href="#" class="checkall">(All</a>, <a href="#" class="uncheckall">None)</a>
{% for exec in execs|dictsort:"name" %}
<li title="{{ exec.description }}"><!-- the input id != value. It is used for exeutable color order -->
<input id="executable{{ exec.id }}" type="checkbox" name="executable" value="{{ exec.id }}" />
<label for="executable{{ exec.id }}">{{ exec }}</label><div class="seriescolor"></div>
</li>{% endfor %}
</ul>
{% endfor %}
<ul>
<li title="Select baseline">Baseline:<div id="baselinecolor" class="seriescolor"></div><br/>
<select id="baseline">
Expand Down
10 changes: 10 additions & 0 deletions codespeed/tests.py
Expand Up @@ -149,6 +149,16 @@ def test_submit_data_with_none_timestamp(self):
response = self.client.post(self.path, modified_data)
self.assertEquals(response.status_code, 202)

def test_add_result_with_no_project(self):
"""Should add a revision with the project"""
modified_data = copy.deepcopy(self.data)
modified_data['project'] = "My new project"
modified_data['executable'] = "My new executable"
response = self.client.post(self.path, modified_data)
self.assertEquals(response.status_code, 202)
self.assertEquals(response.content, "Result data saved succesfully")


class AddJSONResults(TestCase):
def setUp(self):
self.path = reverse('codespeed.views.add_json_results')
Expand Down

0 comments on commit 55030e2

Please sign in to comment.