##// END OF EJS Templates
Resolve error occurring during recursive group creation in API create-repo function
marcink -
r2120:d5527ceb beta
parent child Browse files
Show More
@@ -27,6 +27,8 fixes
27 - fixed #385 clone by ID url was loosing proxy prefix in URL
27 - fixed #385 clone by ID url was loosing proxy prefix in URL
28 - fixed some unicode problems with waitress
28 - fixed some unicode problems with waitress
29 - fixed issue with escaping < and > in changeset commits
29 - fixed issue with escaping < and > in changeset commits
30 - fixed error occurring during recursive group creation in API
31 create_repo function
30
32
31 1.3.3 (**2012-03-02**)
33 1.3.3 (**2012-03-02**)
32 ----------------------
34 ----------------------
@@ -39,6 +39,7 from rhodecode.model.repo import RepoMod
39 from rhodecode.model.user import UserModel
39 from rhodecode.model.user import UserModel
40 from rhodecode.model.users_group import UsersGroupModel
40 from rhodecode.model.users_group import UsersGroupModel
41 from rhodecode.model.repos_group import ReposGroupModel
41 from rhodecode.model.repos_group import ReposGroupModel
42 from rhodecode.lib.utils import map_groups
42
43
43
44
44 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
@@ -464,15 +465,10 class ApiController(JSONRPCController):
464 if Repository.get_by_repo_name(repo_name):
465 if Repository.get_by_repo_name(repo_name):
465 raise JSONRPCError("repo %s already exist" % repo_name)
466 raise JSONRPCError("repo %s already exist" % repo_name)
466
467
467 groups = repo_name.split('/')
468 groups = repo_name.split(Repository.url_sep())
468 real_name = groups[-1]
469 real_name = groups[-1]
469 groups = groups[:-1]
470 # create structure of groups
470 parent_id = None
471 group = map_groups(repo_name)
471 for g in groups:
472 group = RepoGroup.get_by_group_name(g)
473 if not group:
474 group = ReposGroupModel().create(g, '', parent_id)
475 parent_id = group.group_id
476
472
477 repo = RepoModel().create(
473 repo = RepoModel().create(
478 dict(
474 dict(
@@ -481,7 +477,7 class ApiController(JSONRPCController):
481 description=description,
477 description=description,
482 private=private,
478 private=private,
483 repo_type=repo_type,
479 repo_type=repo_type,
484 repo_group=parent_id,
480 repo_group=group.group_id if group else None,
485 clone_uri=clone_uri
481 clone_uri=clone_uri
486 ),
482 ),
487 owner
483 owner
@@ -380,15 +380,16 class EmptyChangeset(BaseChangeset):
380 return 0
380 return 0
381
381
382
382
383 def map_groups(groups):
383 def map_groups(path):
384 """
384 """
385 Checks for groups existence, and creates groups structures.
385 Given a full path to a repository, create all nested groups that this
386 It returns last group in structure
386 repo is inside. This function creates parent-child relationships between
387 groups and creates default perms for all new groups.
387
388
388 :param groups: list of groups structure
389 :param paths: full path to repository
389 """
390 """
390 sa = meta.Session
391 sa = meta.Session
391
392 groups = path.split(Repository.url_sep())
392 parent = None
393 parent = None
393 group = None
394 group = None
394
395
@@ -400,22 +401,18 def map_groups(groups):
400 group = RepoGroup.get_by_group_name(group_name)
401 group = RepoGroup.get_by_group_name(group_name)
401 desc = '%s group' % group_name
402 desc = '%s group' % group_name
402
403
403 # # WTF that doesn't work !?
404 # if group is None:
405 # group = rgm.create(group_name, desc, parent, just_db=True)
406 # sa.commit()
407
408 # skip folders that are now removed repos
404 # skip folders that are now removed repos
409 if REMOVED_REPO_PAT.match(group_name):
405 if REMOVED_REPO_PAT.match(group_name):
410 break
406 break
411
407
412 if group is None:
408 if group is None:
413 log.debug('creating group level: %s group_name: %s' % (lvl, group_name))
409 log.debug('creating group level: %s group_name: %s' % (lvl,
410 group_name))
414 group = RepoGroup(group_name, parent)
411 group = RepoGroup(group_name, parent)
415 group.group_description = desc
412 group.group_description = desc
416 sa.add(group)
413 sa.add(group)
417 rgm._create_default_perms(group)
414 rgm._create_default_perms(group)
418 sa.commit()
415 sa.flush()
419 parent = group
416 parent = group
420 return group
417 return group
421
418
@@ -438,7 +435,7 def repo2db_mapper(initial_repo_list, re
438 added = []
435 added = []
439
436
440 for name, repo in initial_repo_list.items():
437 for name, repo in initial_repo_list.items():
441 group = map_groups(name.split(Repository.url_sep()))
438 group = map_groups(name)
442 if not rm.get_by_repo_name(name, cache=False):
439 if not rm.get_by_repo_name(name, cache=False):
443 log.info('repository %s not found creating default' % name)
440 log.info('repository %s not found creating default' % name)
444 added.append(name)
441 added.append(name)
General Comments 0
You need to be logged in to leave comments. Login now