diff --git a/rhodecode/controllers/admin/repos.py b/rhodecode/controllers/admin/repos.py --- a/rhodecode/controllers/admin/repos.py +++ b/rhodecode/controllers/admin/repos.py @@ -44,6 +44,7 @@ from rhodecode.model.db import User, Rep from rhodecode.model.forms import RepoForm from rhodecode.model.scm import ScmModel from rhodecode.model.repo import RepoModel +from sqlalchemy.exc import IntegrityError log = logging.getLogger(__name__) @@ -179,11 +180,12 @@ class ReposController(BaseController): category='success') if request.POST.get('user_created'): + #created by regular non admin user action_logger(self.rhodecode_user, 'user_created_repo', - form_result['repo_name'], '', self.sa) + form_result['repo_name_full'], '', self.sa) else: action_logger(self.rhodecode_user, 'admin_created_repo', - form_result['repo_name'], '', self.sa) + form_result['repo_name_full'], '', self.sa) except formencode.Invalid, errors: @@ -287,6 +289,18 @@ class ReposController(BaseController): invalidate_cache('get_repo_cached_%s' % repo_name) h.flash(_('deleted repository %s') % repo_name, category='success') + except IntegrityError, e: + if e.message.find('repositories_fork_id_fkey'): + log.error(traceback.format_exc()) + h.flash(_('Cannot delete %s it still contains attached ' + 'forks') % repo_name, + category='warning') + else: + log.error(traceback.format_exc()) + h.flash(_('An error occurred during ' + 'deletion of %s') % repo_name, + category='error') + except Exception, e: log.error(traceback.format_exc()) h.flash(_('An error occurred during deletion of %s') % repo_name, diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py --- a/rhodecode/lib/utils.py +++ b/rhodecode/lib/utils.py @@ -386,6 +386,7 @@ def repo2db_mapper(initial_repo_list, re added.append(name) form_data = { 'repo_name': name, + 'repo_name_full': name, 'repo_type': repo.alias, 'description': repo.description \ if repo.description != 'unknown' else \ diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -227,8 +227,7 @@ class ValidRepoUser(formencode.validator def to_python(self, value, state): try: - self.user_db = User.query()\ - .filter(User.active == True)\ + User.query().filter(User.active == True)\ .filter(User.username == value).one() except Exception: raise formencode.Invalid(_('This username is not valid'), @@ -251,7 +250,8 @@ def ValidRepoName(edit, old_data): gr = Group.get(value.get('repo_group')) group_path = gr.full_path # value needs to be aware of group name in order to check - # db key + # db key This is an actuall just the name to store in the + # database repo_name_full = group_path + Group.url_sep() + repo_name else: group_path = '' diff --git a/rhodecode/model/repo.py b/rhodecode/model/repo.py --- a/rhodecode/model/repo.py +++ b/rhodecode/model/repo.py @@ -198,14 +198,17 @@ class RepoModel(BaseModel): #force str since hg doesn't go with unicode repo_name = str(form_data['fork_name']) org_name = str(form_data['repo_name']) + org_full_name = str(form_data['repo_name_full']) else: org_name = repo_name = str(form_data['repo_name']) + repo_name_full = form_data['repo_name_full'] + new_repo = Repository() new_repo.enable_statistics = False for k, v in form_data.items(): if k == 'repo_name': - v = repo_name + v = repo_name_full if k == 'repo_group': k = 'group_id' @@ -213,7 +216,7 @@ class RepoModel(BaseModel): if fork: parent_repo = self.sa.query(Repository)\ - .filter(Repository.repo_name == org_name).scalar() + .filter(Repository.repo_name == org_full_name).scalar() new_repo.fork = parent_repo new_repo.user_id = cur_user.user_id @@ -309,7 +312,9 @@ class RepoModel(BaseModel): def __create_repo(self, repo_name, alias, new_parent_id, clone_uri=False): """ - makes repository on filesystem it's group aware + makes repository on filesystem. It's group aware means it'll create + a repository within a group, and alter the paths accordingly of + group location :param repo_name: :param alias: