diff --git a/kallithea/controllers/admin/repo_groups.py b/kallithea/controllers/admin/repo_groups.py --- a/kallithea/controllers/admin/repo_groups.py +++ b/kallithea/controllers/admin/repo_groups.py @@ -148,6 +148,7 @@ class RepoGroupsController(BaseControlle # permissions for can create group based on parent_id are checked # here in the Form repo_group_form = RepoGroupForm(repo_groups=c.repo_groups) + form_result = None try: form_result = repo_group_form.to_python(dict(request.POST)) gr = RepoGroupModel().create( @@ -171,6 +172,8 @@ class RepoGroupsController(BaseControlle log.error(traceback.format_exc()) h.flash(_('Error occurred during creation of repository group %s') % request.POST.get('group_name'), category='error') + if form_result is None: + raise parent_group_id = form_result['parent_group_id'] # TODO: maybe we should get back to the main view, not the admin one raise HTTPFound(location=url('repos_groups', parent_group=parent_group_id)) diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -470,14 +470,15 @@ class PullrequestsController(BaseRepoCon c.a_rev) = c.pull_request.other_ref.split(':') # a_rev is ancestor org_scm_instance = c.cs_repo.scm_instance # property with expensive cache invalidation check!!! - try: - c.cs_ranges = [] - for x in c.pull_request.revisions: + c.cs_ranges = [] + for x in c.pull_request.revisions: + try: c.cs_ranges.append(org_scm_instance.get_changeset(x)) - except ChangesetDoesNotExistError: - c.cs_ranges = [] - h.flash(_('Revision %s not found in %s') % (x, c.cs_repo.repo_name), - 'error') + except ChangesetDoesNotExistError: + c.cs_ranges = [] + h.flash(_('Revision %s not found in %s') % (x, c.cs_repo.repo_name), + 'error') + break c.cs_ranges_org = None # not stored and not important and moving target - could be calculated ... revs = [ctx.revision for ctx in reversed(c.cs_ranges)] c.jsdata = graph_data(org_scm_instance, revs) diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -557,8 +557,8 @@ def _parse_lines(diff_lines): added = deleted = 0 old_line = old_end = new_line = new_end = None + chunks = [] try: - chunks = [] line = diff_lines.next() while True: diff --git a/kallithea/lib/utils2.py b/kallithea/lib/utils2.py --- a/kallithea/lib/utils2.py +++ b/kallithea/lib/utils2.py @@ -374,7 +374,7 @@ def uri_filter(uri): :returns: filtered list of strings """ if not uri: - return '' + return [] proto = '' @@ -541,11 +541,11 @@ def get_hook_environment(): raise HookEnvironmentError("Environment variable KALLITHEA_EXTRAS not found") extras = json.loads(kallithea_extras) - try: - for k in ['username', 'repository', 'scm', 'action', 'ip', 'config']: + for k in ['username', 'repository', 'scm', 'action', 'ip', 'config']: + try: extras[k] - except KeyError: - raise HookEnvironmentError('Missing key %s in KALLITHEA_EXTRAS %s' % (k, extras)) + except KeyError: + raise HookEnvironmentError('Missing key %s in KALLITHEA_EXTRAS %s' % (k, extras)) return AttributeDict(extras) diff --git a/kallithea/lib/vcs/nodes.py b/kallithea/lib/vcs/nodes.py --- a/kallithea/lib/vcs/nodes.py +++ b/kallithea/lib/vcs/nodes.py @@ -329,8 +329,8 @@ class FileNode(Node): encoding = None # try with pygments + from pygments import lexers try: - from pygments import lexers mt = lexers.get_lexer_for_filename(self.name).mimetypes except lexers.ClassNotFound: mt = None