Mercurial > kallithea
changeset 2120:d5527cebf76a beta
Resolve error occurring during recursive group creation in API create-repo function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 11 Mar 2012 17:51:23 +0200 |
parents | 4d076981a7b1 |
children | 47d7bcbe5503 462a845c925c |
files | docs/changelog.rst rhodecode/controllers/api/api.py rhodecode/lib/utils.py |
diffstat | 3 files changed, 17 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/changelog.rst Sun Mar 11 04:28:23 2012 +0200 +++ b/docs/changelog.rst Sun Mar 11 17:51:23 2012 +0200 @@ -27,6 +27,8 @@ - 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**) ----------------------
--- a/rhodecode/controllers/api/api.py Sun Mar 11 04:28:23 2012 +0200 +++ b/rhodecode/controllers/api/api.py Sun Mar 11 17:51:23 2012 +0200 @@ -39,6 +39,7 @@ 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 @@ 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 @@ 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
--- a/rhodecode/lib/utils.py Sun Mar 11 04:28:23 2012 +0200 +++ b/rhodecode/lib/utils.py Sun Mar 11 17:51:23 2012 +0200 @@ -380,15 +380,16 @@ 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 @@ 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 @@ 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)