Changeset - d5527cebf76a
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 14 years ago 2012-03-11 16:51:23
marcin@python-works.com
Resolve error occurring during recursive group creation in API create-repo function
3 files changed with 17 insertions and 22 deletions:
0 comments (0 inline, 0 general)
docs/changelog.rst
Show inline comments
 
@@ -27,6 +27,8 @@ fixes
 
- fixed #385 clone by ID url was loosing proxy prefix in URL
 
- fixed some unicode problems with waitress
 
- fixed issue with escaping < and > in changeset commits
 
- fixed error occurring during recursive group creation in API 
 
  create_repo function
 

	
 
1.3.3 (**2012-03-02**)
 
----------------------
rhodecode/controllers/api/api.py
Show inline comments
 
@@ -39,6 +39,7 @@ from rhodecode.model.repo import RepoMod
 
from rhodecode.model.user import UserModel
 
from rhodecode.model.users_group import UsersGroupModel
 
from rhodecode.model.repos_group import ReposGroupModel
 
from rhodecode.lib.utils import map_groups
 

	
 

	
 
log = logging.getLogger(__name__)
 
@@ -464,15 +465,10 @@ class ApiController(JSONRPCController):
 
            if Repository.get_by_repo_name(repo_name):
 
                raise JSONRPCError("repo %s already exist" % repo_name)
 

	
 
            groups = repo_name.split('/')
 
            groups = repo_name.split(Repository.url_sep())
 
            real_name = groups[-1]
 
            groups = groups[:-1]
 
            parent_id = None
 
            for g in groups:
 
                group = RepoGroup.get_by_group_name(g)
 
                if not group:
 
                    group = ReposGroupModel().create(g, '', parent_id)
 
                parent_id = group.group_id
 
            # create structure of groups
 
            group = map_groups(repo_name)
 

	
 
            repo = RepoModel().create(
 
                dict(
 
@@ -481,7 +477,7 @@ class ApiController(JSONRPCController):
 
                    description=description,
 
                    private=private,
 
                    repo_type=repo_type,
 
                    repo_group=parent_id,
 
                    repo_group=group.group_id if group else None,
 
                    clone_uri=clone_uri
 
                ),
 
                owner
rhodecode/lib/utils.py
Show inline comments
 
@@ -380,15 +380,16 @@ class EmptyChangeset(BaseChangeset):
 
        return 0
 

	
 

	
 
def map_groups(groups):
 
def map_groups(path):
 
    """
 
    Checks for groups existence, and creates groups structures.
 
    It returns last group in structure
 
    Given a full path to a repository, create all nested groups that this
 
    repo is inside. This function creates parent-child relationships between
 
    groups and creates default perms for all new groups.
 

	
 
    :param groups: list of groups structure
 
    :param paths: full path to repository
 
    """
 
    sa = meta.Session
 

	
 
    groups = path.split(Repository.url_sep())
 
    parent = None
 
    group = None
 

	
 
@@ -400,22 +401,18 @@ def map_groups(groups):
 
        group = RepoGroup.get_by_group_name(group_name)
 
        desc = '%s group' % group_name
 

	
 
#        # WTF that doesn't work !?
 
#        if group is None:
 
#            group = rgm.create(group_name, desc, parent, just_db=True)
 
#            sa.commit()
 

	
 
        # skip folders that are now removed repos
 
        if REMOVED_REPO_PAT.match(group_name):
 
            break
 

	
 
        if group is None:
 
            log.debug('creating group level: %s group_name: %s' % (lvl, group_name))
 
            log.debug('creating group level: %s group_name: %s' % (lvl,
 
                                                                   group_name))
 
            group = RepoGroup(group_name, parent)
 
            group.group_description = desc
 
            sa.add(group)
 
            rgm._create_default_perms(group)
 
            sa.commit()
 
            sa.flush()
 
        parent = group
 
    return group
 

	
 
@@ -438,7 +435,7 @@ def repo2db_mapper(initial_repo_list, re
 
    added = []
 

	
 
    for name, repo in initial_repo_list.items():
 
        group = map_groups(name.split(Repository.url_sep()))
 
        group = map_groups(name)
 
        if not rm.get_by_repo_name(name, cache=False):
 
            log.info('repository %s not found creating default' % name)
 
            added.append(name)
0 comments (0 inline, 0 general)