Skip to content
Browse files

Merge branch 'release-1.5.x'

  • Loading branch information...
2 parents ca21254 + 0aaec8c commit a723e709a3b815cf187cdeb36e5fc3d81fefbc32 @davidt davidt committed Mar 22, 2011
View
5 reviewboard/admin/siteconfig.py
@@ -256,4 +256,7 @@ def apply_setting(settings_key, db_key, default=None):
settings.AWS_ACCESS_KEY_ID = str(siteconfig.get('aws_access_key_id'))
settings.AWS_SECRET_ACCESS_KEY = str(siteconfig.get('aws_secret_access_key'))
settings.AWS_STORAGE_BUCKET_NAME = str(siteconfig.get('aws_s3_bucket_name'))
- settings.AWS_CALLING_FORMAT = int(siteconfig.get('aws_calling_format'))
+ try:
+ settings.AWS_CALLING_FORMAT = int(siteconfig.get('aws_calling_format'))
+ except ValueError:
+ settings.AWS_CALLING_FORMAT = 0
View
48 reviewboard/diffviewer/diffutils.py
@@ -3,8 +3,16 @@
import re
import subprocess
import tempfile
+import logging
+import signal
from difflib import SequenceMatcher
+class TimeoutException(Exception):
+ pass
+
+def our_timeout_handler(signum, frame):
+ raise TimeoutException()
+
try:
import pygments
from pygments.lexers import get_lexer_for_filename
@@ -349,8 +357,8 @@ def fetch_file(file, revision):
file = filediff.source_file
revision = filediff.source_revision
- key = "%s:%s:%s" % (filediff.diffset.repository.path, urlquote(file),
- revision)
+ key = "%s:%s:%s" % (urlquote(filediff.diffset.repository.path),
+ urlquote(file), urlquote(revision))
# We wrap the result of get_file in a list and then return the first
# element after getting the result from the cache. This prevents the
@@ -467,14 +475,17 @@ def get_interesting_headers(differ, lines, start, end, is_modified_file):
if not possible_functions:
raise StopIteration
- if is_modified_file:
- last_index = last_header_index[1]
- i1 = lines[start][4]
- i2 = lines[end - 1][4]
- else:
- last_index = last_header_index[0]
- i1 = lines[start][1]
- i2 = lines[end - 1][1]
+ try:
+ if is_modified_file:
+ last_index = last_header_index[1]
+ i1 = lines[start][4]
+ i2 = lines[end - 1][4]
+ else:
+ last_index = last_header_index[0]
+ i1 = lines[start][1]
+ i2 = lines[end - 1][1]
+ except IndexError:
+ raise StopIteration
for i in xrange(last_index, len(possible_functions)):
linenum, line = possible_functions[i]
@@ -506,8 +517,21 @@ def apply_pygments(data, filename):
except AttributeError:
pass
- return pygments.highlight(data, lexer, NoWrapperHtmlFormatter()).splitlines()
+ # Sometimes pygments spins forever trying to highlight something, give it 10 seconds then give up.
+ old_alarm_handler = signal.signal(signal.SIGALRM, our_timeout_handler)
+ signal.alarm(10)
+ try:
+ log_timer = log_timed("Syntax highlighting file '%s' with lexer %s" % (filename, lexer.name))
+ result = pygments.highlight(data, lexer, NoWrapperHtmlFormatter()).splitlines()
+ except TimeoutException:
+ logging.warn("Timed out trying to highlight data for file '%s' with lexer %s" % (filename, lexer.name))
+ return
+ finally:
+ signal.signal(signal.SIGALRM, old_alarm_handler)
+ log_timer.done()
+ signal.alarm(0)
+ return result
# There are three ways this function is called:
#
@@ -598,7 +622,7 @@ def apply_pygments(data, filename):
# once instead of twice.
markup_a = apply_pygments(old or '', source_file)
markup_b = apply_pygments(new or '', dest_file)
- except ValueError:
+ except:
pass
if not markup_a:
View
3 reviewboard/htdocs/media/rb/css/common.css
@@ -55,6 +55,9 @@ ul.errorlist li {
vertical-align: text-bottom;
}
+textarea {
+ resize: none;
+}
/****************************************************************************
* Banners
View
63 reviewboard/htdocs/media/rb/js/common.js
@@ -192,43 +192,48 @@ $.fn.formDlg = function(options) {
/*
* Toggles whether an object is starred. Right now, we support
- * "reviewrequests" and "groups" types.
+ * "reviewrequests" and "groups" types. Loads parameters from
+ * data attributes on the element. Attaches via 'live' so it applies
+ * to future stars matching the current jQuery selector.
*
- * @param {string} type The type used for constructing the path.
- * @param {string} objid The object ID to star/unstar.
- * @param {bool} default_ The default value.
+ * @param {string} object-type The type used for constructing the path.
+ * @param {string} object-id The object ID to star/unstar.
+ * @param {bool} starred The default value.
*/
-$.fn.toggleStar = function(type, objid, default_) {
- return this.each(function() {
- var self = $(this);
+$.fn.toggleStar = function() {
+ // Constants
+ var STAR_ON_IMG = MEDIA_URL + "rb/images/star_on.png?" + MEDIA_SERIAL;
+ var STAR_OFF_IMG = MEDIA_URL + "rb/images/star_off.png?" + MEDIA_SERIAL;
- // Constants
- var STAR_ON_IMG = MEDIA_URL + "rb/images/star_on.png?" + MEDIA_SERIAL;
- var STAR_OFF_IMG = MEDIA_URL + "rb/images/star_off.png?" + MEDIA_SERIAL;
+ return this.live('click', function() {
+ var self = $(this);
- var obj;
- var on = default_;
+ var obj = self.data("rb.obj");
- self.click(function() {
- on = !on;
+ if (!obj) {
+ var type = self.attr("data-object-type");
+ var objid = self.attr("data-object-id");
- if (!obj) {
- if (type == "reviewrequests") {
- obj = new RB.ReviewRequest(objid);
- } else if (type == "groups") {
- obj = new RB.ReviewGroup(objid);
- } else {
- self.remove();
- return;
- }
+ if (type == "reviewrequests") {
+ obj = new RB.ReviewRequest(objid);
+ } else if (type == "groups") {
+ obj = new RB.ReviewGroup(objid);
+ } else {
+ self.remove();
+ return;
}
+ }
- obj.setStarred(on);
- self.attr("src", (on ? STAR_ON_IMG : STAR_OFF_IMG));
+ var on = (parseInt(self.attr("data-starred")) == 1) ? 0 : 1;
+ obj.setStarred(on);
+ self.data("rb.obj", obj);
- var alt_title = on ? "Starred" : "Click to star";
- self.attr("alt", alt_title);
- self.attr("title", alt_title);
+ var alt_title = on ? "Starred" : "Click to star";
+ self.attr({
+ src: (on ? STAR_ON_IMG : STAR_OFF_IMG),
+ 'data-starred': on,
+ alt: alt_title,
+ title: alt_title
});
});
};
@@ -258,6 +263,8 @@ $(document).ready(function() {
$(this).find(".user-infobox").hide();
}
);
+
+ $('.star').toggleStar();
});
// vim: set et:sw=4:
View
5 reviewboard/manage.py
@@ -63,7 +63,10 @@ def check_dependencies():
try:
imp.find_module('PIL')
except ImportError:
- dependency_error('The Python Imaging Library (PIL) is required.')
+ try:
+ imp.find_module('Image')
+ except ImportError:
+ dependency_error('The Python Imaging Library (PIL) is required.')
# ReCaptcha
View
3 reviewboard/reviews/forms.py
@@ -198,7 +198,8 @@ def create(self, user, diff_file, parent_diff_file, local_site=None):
except ChangeNumberInUseError:
# The user is updating an existing review request, rather than
# creating a new one.
- review_request = ReviewRequest.objects.get(changenum=changenum)
+ review_request = ReviewRequest.objects.get(changenum=changenum,
+ repository=repository)
review_request.update_from_changenum(changenum)
if review_request.status == 'D':
View
8 reviewboard/templates/reviews/star.html
@@ -1,9 +1,3 @@
{% if user.is_authenticated %}
-<img class="star" id="star-{{object.type}}-{{object.id}}" src="{{MEDIA_URL}}rb/images/star_{% if starred %}on{% else %}off{% endif %}.png?{{MEDIA_SERIAL}}" width="16" height="15" border="0" alt="{{alt}}" title="{{alt}}" />
-<script type="text/javascript">
- $(document).ready(function() {
- $("#star-{{object.type}}-{{object.id}}").toggleStar(
- '{{object.type}}', '{{object.id}}', {{starred}});
- });
-</script>
+<img class="star" src="{{MEDIA_URL}}rb/images/star_{% if starred %}on{% else %}off{% endif %}.png?{{MEDIA_SERIAL}}" width="16" height="15" border="0" alt="{{alt}}" title="{{alt}}" data-starred="{{starred}}" data-object-type="{{object.type}}" data-object-id="{{object.id}}"/>
{% endif %}
View
6 reviewboard/test.py
@@ -38,7 +38,11 @@
from PIL import Image
Image.init()
except ImportError:
- pass
+ try:
+ from Image import Image
+ Image.init()
+ except ImportError:
+ pass
from django.conf import settings
from django.core import management
View
1 reviewboard/webapi/resources.py
@@ -4844,6 +4844,7 @@ def get(self, request, *args, **kwargs):
'url': url,
'administrators': [{'name': name, 'email': email}
for name, email in settings.ADMINS],
+ 'time_zone': settings.TIME_ZONE,
},
},
}

0 comments on commit a723e70

Please sign in to comment.
Something went wrong with that request. Please try again.