diff --git a/rhodecode/apps/repository/views/strip.py b/rhodecode/apps/repository/views/strip.py --- a/rhodecode/apps/repository/views/strip.py +++ b/rhodecode/apps/repository/views/strip.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2011-2017 RhodeCode GmbH +# Copyright (C) 2017-2017 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License, version 3 @@ -24,7 +24,7 @@ from pyramid.view import view_config from rhodecode.apps._base import RepoAppView from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous) - +from rhodecode.lib.ext_json import json log = logging.getLogger(__name__) @@ -57,21 +57,21 @@ class StripView(RepoAppView): @HasRepoPermissionAnyDecorator('repository.admin') @view_config( route_name='strip_check', request_method='POST', - renderer='json', xhr=True - ) + renderer='json', xhr=True) def strip_check(self): from rhodecode.lib.vcs.backends.base import EmptyCommit data = {} rp = self.request.POST for i in range(1, 11): - chset = 'changeset_id-%d'%(i,) + chset = 'changeset_id-%d' % (i,) check = rp.get(chset) if check: data[i] = self.db_repo.get_changeset(rp[chset]) if isinstance(data[i], EmptyCommit): data[i] = {'rev': None, 'commit': rp[chset]} else: - data[i] = {'rev': data[i].raw_id, 'branch': data[i].branch, 'author': data[i].author, + data[i] = {'rev': data[i].raw_id, 'branch': data[i].branch, + 'author': data[i].author, 'comment': data[i].message} else: break @@ -82,12 +82,9 @@ class StripView(RepoAppView): @HasRepoPermissionAnyDecorator('repository.admin') @view_config( route_name='strip_execute', request_method='POST', - renderer='json', xhr=True - ) + renderer='json', xhr=True) def strip_execute(self): - from rhodecode.model.scm import ScmModel - from rhodecode.lib.ext_json import json c = self.load_default_context() user = self._rhodecode_user @@ -95,16 +92,18 @@ class StripView(RepoAppView): data = {} for idx in rp: commit = json.loads(rp[idx]) - #If someone put two times the same branch + # If someone put two times the same branch if commit['branch'] in data.keys(): continue try: - ScmModel().strip(repo=c.repo_info, - commit_id=commit['rev'], branch=commit['branch']) - log.info('Stripped commit %s from repo `%s` by %s' % (commit['rev'], c.repo_info.repo_name, user)) + ScmModel().strip( + repo=c.repo_info, + commit_id=commit['rev'], branch=commit['branch']) + log.info('Stripped commit %s from repo `%s` by %s' % ( + commit['rev'], c.repo_info.repo_name, user)) data[commit['rev']] = True - except Exception, e: + except Exception as e: data[commit['rev']] = False - log.debug('Stripped commit %s from repo `%s` failed by %s, exeption %s' % (commit['rev'], - c.repo_info.repo_name, user, e.message)) + log.debug('Stripped commit %s from repo `%s` failed by %s, exeption %s' % ( + commit['rev'], self.db_repo_name, user, e.message)) return data