comparison rhodecode/lib/utils.py @ 2825:f7a52d548fd0

merge with beta
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 07 Sep 2012 23:20:33 +0200
parents 9ae95fdeca18 acc05c33cc0c
children 1f7b8c73c94a
comparison
equal deleted inserted replaced
2793:4c13cedbde93 2825:f7a52d548fd0
204 204
205 205
206 def is_valid_repo(repo_name, base_path, scm=None): 206 def is_valid_repo(repo_name, base_path, scm=None):
207 """ 207 """
208 Returns True if given path is a valid repository False otherwise. 208 Returns True if given path is a valid repository False otherwise.
209 If scm param is given also compare if given scm is the same as expected 209 If scm param is given also compare if given scm is the same as expected
210 from scm parameter 210 from scm parameter
211 211
212 :param repo_name: 212 :param repo_name:
213 :param base_path: 213 :param base_path:
214 :param scm: 214 :param scm:
410 rm = RepoModel() 410 rm = RepoModel()
411 user = sa.query(User).filter(User.admin == True).first() 411 user = sa.query(User).filter(User.admin == True).first()
412 if user is None: 412 if user is None:
413 raise Exception('Missing administrative account !') 413 raise Exception('Missing administrative account !')
414 added = [] 414 added = []
415
416 # # clear cache keys
417 # log.debug("Clearing cache keys now...")
418 # CacheInvalidation.clear_cache()
419 # sa.commit()
415 420
416 for name, repo in initial_repo_list.items(): 421 for name, repo in initial_repo_list.items():
417 group = map_groups(name) 422 group = map_groups(name)
418 db_repo = rm.get_by_repo_name(name) 423 db_repo = rm.get_by_repo_name(name)
419 # found repo that is on filesystem not in RhodeCode database 424 # found repo that is on filesystem not in RhodeCode database
436 if new_repo.repo_type == 'git': 441 if new_repo.repo_type == 'git':
437 ScmModel().install_git_hook(new_repo.scm_instance) 442 ScmModel().install_git_hook(new_repo.scm_instance)
438 elif install_git_hook: 443 elif install_git_hook:
439 if db_repo.repo_type == 'git': 444 if db_repo.repo_type == 'git':
440 ScmModel().install_git_hook(db_repo.scm_instance) 445 ScmModel().install_git_hook(db_repo.scm_instance)
446 # during starting install all cache keys for all repositories in the
447 # system, this will register all repos and multiple instances
448 key, _prefix, _org_key = CacheInvalidation._get_key(name)
449 log.debug("Creating cache key for %s instance_id:`%s`" % (name, _prefix))
450 CacheInvalidation._get_or_create_key(key, _prefix, _org_key, commit=False)
441 sa.commit() 451 sa.commit()
442 removed = [] 452 removed = []
443 if remove_obsolete: 453 if remove_obsolete:
444 # remove from database those repositories that are not in the filesystem 454 # remove from database those repositories that are not in the filesystem
445 for repo in sa.query(Repository).all(): 455 for repo in sa.query(Repository).all():
453 except: 463 except:
454 #don't hold further removals on error 464 #don't hold further removals on error
455 log.error(traceback.format_exc()) 465 log.error(traceback.format_exc())
456 sa.rollback() 466 sa.rollback()
457 467
458 # clear cache keys
459 log.debug("Clearing cache keys now...")
460 CacheInvalidation.clear_cache()
461 sa.commit()
462 return added, removed 468 return added, removed
463 469
464 470
465 # set cache regions for beaker so celery can utilise it 471 # set cache regions for beaker so celery can utilise it
466 def add_cache(settings): 472 def add_cache(settings):