comparison rhodecode/model/repo.py @ 1550:6f468ba37650 beta

fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 12 Oct 2011 14:43:46 +0200
parents bd604cf75c5a
children 752b0a7b7679 9dae92a65e40
comparison
equal deleted inserted replaced
1549:d6cb805c92fd 1550:6f468ba37650
303 :param repo_name: 303 :param repo_name:
304 :param alias: 304 :param alias:
305 :param parent_id: 305 :param parent_id:
306 :param clone_uri: 306 :param clone_uri:
307 """ 307 """
308 from rhodecode.lib.utils import is_valid_repo 308 from rhodecode.lib.utils import is_valid_repo,is_valid_repos_group
309 309
310 if new_parent_id: 310 if new_parent_id:
311 paths = Group.get(new_parent_id).full_path.split(Group.url_sep()) 311 paths = Group.get(new_parent_id).full_path.split(Group.url_sep())
312 new_parent_path = os.sep.join(paths) 312 new_parent_path = os.sep.join(paths)
313 else: 313 else:
314 new_parent_path = '' 314 new_parent_path = ''
315 315
316 repo_path = os.path.join(*map(lambda x:safe_str(x), 316 repo_path = os.path.join(*map(lambda x:safe_str(x),
317 [self.repos_path, new_parent_path, repo_name])) 317 [self.repos_path, new_parent_path, repo_name]))
318 318
319 if is_valid_repo(repo_path, self.repos_path) is False: 319
320 log.info('creating repo %s in %s @ %s', repo_name, repo_path, 320 # check if this path is not a repository
321 clone_uri) 321 if is_valid_repo(repo_path, self.repos_path):
322 backend = get_backend(alias) 322 raise Exception('This path %s is a valid repository' % repo_path)
323 323
324 backend(repo_path, create=True, src_url=clone_uri) 324 # check if this path is a group
325 if is_valid_repos_group(repo_path, self.repos_path):
326 raise Exception('This path %s is a valid group' % repo_path)
327
328 log.info('creating repo %s in %s @ %s', repo_name, repo_path,
329 clone_uri)
330 backend = get_backend(alias)
331
332 backend(repo_path, create=True, src_url=clone_uri)
325 333
326 334
327 def __rename_repo(self, old, new): 335 def __rename_repo(self, old, new):
328 """ 336 """
329 renames repository on filesystem 337 renames repository on filesystem