diff rhodecode/lib/celerylib/tasks.py @ 659:758f64f3fbda beta

extended repo creation by repo type. fixed fork creation to maintain repo type.
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 05 Nov 2010 21:55:30 +0100
parents fd63782c4426
children 373ee7031003
line wrap: on
line diff
--- a/rhodecode/lib/celerylib/tasks.py	Fri Nov 05 18:47:00 2010 +0100
+++ b/rhodecode/lib/celerylib/tasks.py	Fri Nov 05 21:55:30 2010 +0100
@@ -289,18 +289,20 @@
 
 @task
 def create_repo_fork(form_data, cur_user):
-    import os
     from rhodecode.model.repo import RepoModel
-
+    from vcs import get_backend
+    log = create_repo_fork.get_logger()
     repo_model = RepoModel(get_session())
     repo_model.create(form_data, cur_user, just_db=True, fork=True)
-
-    repos_path = get_hg_ui_settings()['paths_root_path'].replace('*', '')
-    repo_path = os.path.join(repos_path, form_data['repo_name'])
+    repo_name = form_data['repo_name']
+    repos_path = get_hg_ui_settings()['paths_root_path']
+    repo_path = os.path.join(repos_path, repo_name)
     repo_fork_path = os.path.join(repos_path, form_data['fork_name'])
+    alias = form_data['repo_type']
 
-    MercurialRepository(str(repo_fork_path), True, clone_url=str(repo_path))
-
+    log.info('creating repo fork %s as %s', repo_name, repo_path)
+    backend = get_backend(alias)
+    backend(str(repo_fork_path), create=True, src_url=str(repo_path))
 
 def __get_codes_stats(repo_name):
     LANGUAGES_EXTENSIONS = ['action', 'adp', 'ashx', 'asmx',