Changeset - 6f468ba37650
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 14 years ago 2011-10-12 14:43:46
marcin@python-works.com
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
2 files changed with 27 insertions and 12 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/forms.py
Show inline comments
 
@@ -250,7 +250,7 @@ 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 This is an actuall just the name to store in the
 
                # db key This is an actual just the name to store in the
 
                # database
 
                repo_name_full = group_path + Group.url_sep() + repo_name
 
            else:
 
@@ -259,25 +259,32 @@ def ValidRepoName(edit, old_data):
 

	
 

	
 
            value['repo_name_full'] = repo_name_full
 
            if old_data.get('repo_name') != repo_name_full or not edit:
 
            rename = old_data.get('repo_name') != repo_name_full
 
            create = not edit
 
            if  rename or create:
 

	
 
                if group_path != '':
 
                    if RepoModel().get_by_repo_name(repo_name_full,):
 
                        e_dict = {'repo_name':_('This repository already '
 
                                                'exists in group "%s"') %
 
                                                'exists in a group "%s"') %
 
                                  gr.group_name}
 
                        raise formencode.Invalid('', value, state,
 
                                                 error_dict=e_dict)
 
                elif Group.get_by_group_name(repo_name_full):
 
                        e_dict = {'repo_name':_('There is a group with this'
 
                                                ' name already "%s"') %
 
                                  repo_name_full}
 
                        raise formencode.Invalid('', value, state,
 
                                                 error_dict=e_dict)
 

	
 
                else:
 
                    if RepoModel().get_by_repo_name(repo_name_full):
 
                elif RepoModel().get_by_repo_name(repo_name_full):
 
                        e_dict = {'repo_name':_('This repository '
 
                                                'already exists')}
 
                        raise formencode.Invalid('', value, state,
 
                                                 error_dict=e_dict)
 

	
 
            return value
 

	
 

	
 
    return _ValidRepoName
 

	
 
def ValidForkName():
rhodecode/model/repo.py
Show inline comments
 
@@ -305,7 +305,7 @@ class RepoModel(BaseModel):
 
        :param parent_id:
 
        :param clone_uri:
 
        """
 
        from rhodecode.lib.utils import is_valid_repo
 
        from rhodecode.lib.utils import is_valid_repo,is_valid_repos_group
 

	
 
        if new_parent_id:
 
            paths = Group.get(new_parent_id).full_path.split(Group.url_sep())
 
@@ -316,12 +316,20 @@ class RepoModel(BaseModel):
 
        repo_path = os.path.join(*map(lambda x:safe_str(x),
 
                                [self.repos_path, new_parent_path, repo_name]))
 

	
 
        if is_valid_repo(repo_path, self.repos_path) is False:
 
            log.info('creating repo %s in %s @ %s', repo_name, repo_path,
 
                     clone_uri)
 
            backend = get_backend(alias)
 
        
 
        # check if this path is not a repository
 
        if is_valid_repo(repo_path, self.repos_path):
 
            raise Exception('This path %s is a valid repository' % repo_path)
 

	
 
            backend(repo_path, create=True, src_url=clone_uri)
 
        # check if this path is a group
 
        if is_valid_repos_group(repo_path, self.repos_path):
 
            raise Exception('This path %s is a valid group' % repo_path)
 
                
 
        log.info('creating repo %s in %s @ %s', repo_name, repo_path,
 
                 clone_uri)
 
        backend = get_backend(alias)
 

	
 
        backend(repo_path, create=True, src_url=clone_uri)
 

	
 

	
 
    def __rename_repo(self, old, new):
0 comments (0 inline, 0 general)