Skip to content

Commit

Permalink
Handle things nicely when Repository URL cannot be resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
tobami committed Jul 2, 2010
1 parent 4b78156 commit 2bcb1af
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 36 deletions.
36 changes: 25 additions & 11 deletions speedcenter/codespeed/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,24 @@ def displaylogs(request):
rev = Revision.objects.get(id=request.GET['revisionid'])
logs = []
logs.append(rev)
error = False
remotelogs = getcommitlogs(rev)
if len(remotelogs): logs = remotelogs
return render_to_response('codespeed/changes_logs.html', { 'logs': logs })
if len(remotelogs):
print remotelogs
try:
if remotelogs[0]['error']:
error = remotelogs[0]['message']
except KeyError:
pass#no errors
logs = remotelogs
else: error = 'no logs found'
print error
return render_to_response('codespeed/changes_logs.html', { 'error': error, 'logs': logs })

def getlogsfromsvn(newrev, startrev):
import pysvn
logs = []
log_messages = []
loglimit = 200
if startrev == newrev:
start = startrev.commitid
Expand All @@ -618,16 +629,19 @@ def get_login(realm, username, may_save):
client = pysvn.Client()
if newrev.project.repo_user != "":
client.callback_get_login = get_login
log_message = \
client.log(
newrev.project.repo_path,
revision_start=pysvn.Revision(
pysvn.opt_revision_kind.number, start
),
revision_end=pysvn.Revision(
pysvn.opt_revision_kind.number, newrev.commitid
try:
log_messages = \
client.log(
newrev.project.repo_path,
revision_start=pysvn.Revision(
pysvn.opt_revision_kind.number, start
),
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 + "'"}]
log_message.reverse()
s = len(log_message)
while s > loglimit:
Expand Down
50 changes: 25 additions & 25 deletions speedcenter/media/js/codespeed.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@

function permalink() {
window.location="?" + $.param(getConfiguration());
window.location="?" + $.param(getConfiguration());
}

function readCheckbox(el) {
config = "";
$(el).each(function() {
config += $(this).val() + ",";
});
config = config.slice(0, -1);
return config;
config = "";
$(el).each(function() {
config += $(this).val() + ",";
});
config = config.slice(0, -1);
return config;
}

function getLoadText(text, h, showloader) {
var loadtext = '<div style="text-align:center;">';
var pstyle = "";
if (h > 0) {
h = h - 32;
if(h < 80) { h = 180; }
else if (h > 400) { h = 400; }
pstyle = ' style="line-height:' + h + 'px;"';
}
loadtext += '<p' + pstyle + '>'+ text;
if (showloader) {
loadtext += ' <img src="/media/images/ajax-loader.gif" align="bottom">';
}
loadtext += '</p></div>';
return loadtext;
var loadtext = '<div style="text-align:center;">';
var pstyle = "";
if (h > 0) {
h = h - 32;
if(h < 80) { h = 180; }
else if (h > 400) { h = 400; }
pstyle = ' style="line-height:' + h + 'px;"';
}
loadtext += '<p' + pstyle + '>'+ text;
if (showloader) {
loadtext += ' <img src="/media/images/ajax-loader.gif" align="bottom">';
}
loadtext += '</p></div>';
return loadtext;
}

//colors number based on a threshold
function getColorcode(change, theigh, tlow) {
var colorcode = "status-yellow";
if(change < tlow) { colorcode = "status-red"; }
else if(change > theigh) { colorcode = "status-green"; }
return colorcode;
var colorcode = "status-yellow";
if(change < tlow) { colorcode = "status-red"; }
else if(change > theigh) { colorcode = "status-green"; }
return colorcode;
}

function renderComparisonPlot(plotid, benchmarks, exes, enviros, baseline, chart, horizontal) {
Expand Down
4 changes: 4 additions & 0 deletions speedcenter/templates/codespeed/changes_logs.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
{% if error %}
<tr><td columnspan="2">Error: {{ error }}</td></tr>
{% else %}
{% for log in logs %}
<tr><td class="date">{{ log.date }}</td><td><div class="author">{{ log.author }} <strong>commited</strong> {{ log.commitid }}</div><div>{{ log.message }}</div></td></tr>{% endfor %}
{% endif %}

0 comments on commit 2bcb1af

Please sign in to comment.