Mercurial > public > src > rhodecode
comparison pylons_app/lib/utils.py @ 125:2811259dc12d
Moved check_repo function to utils, error controller check for first name in url, for this repo and only prints 404 make repo template if repo does not exists, moded check repo from admin
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 29 Apr 2010 01:26:20 +0200 |
parents | cc5cf1a93902 |
children | 36102488d634 |
comparison
equal
deleted
inserted
replaced
124:f8ae5c1dfae2 | 125:2811259dc12d |
---|---|
1 from mercurial import ui, config | |
2 import os | 1 import os |
3 import logging | 2 import logging |
4 | 3 from mercurial import ui, config, hg |
4 from mercurial.error import RepoError | |
5 log = logging.getLogger(__name__) | |
6 | |
7 | |
5 def get_repo_slug(request): | 8 def get_repo_slug(request): |
6 path_info = request.environ.get('PATH_INFO') | 9 path_info = request.environ.get('PATH_INFO') |
7 uri_lst = path_info.split('/') | 10 uri_lst = path_info.split('/') |
8 repo_name = uri_lst[1] | 11 repo_name = uri_lst[1] |
9 return repo_name | 12 return repo_name |
24 repos_path = repos_path[:-1] | 27 repos_path = repos_path[:-1] |
25 if repos_path[0] != '/': | 28 if repos_path[0] != '/': |
26 repos_path[0] = '/' | 29 repos_path[0] = '/' |
27 if not os.path.isdir(os.path.join(*repos_path)): | 30 if not os.path.isdir(os.path.join(*repos_path)): |
28 raise Exception('Not a valid repository in %s' % paths[0][1]) | 31 raise Exception('Not a valid repository in %s' % paths[0][1]) |
29 | 32 |
33 def check_repo(repo_name, base_path): | |
34 | |
35 repo_path = os.path.join(base_path, repo_name) | |
36 | |
37 try: | |
38 r = hg.repository(ui.ui(), repo_path) | |
39 hg.verify(r) | |
40 #here we hnow that repo exists it was verified | |
41 log.info('%s repo is already created', repo_name) | |
42 return False | |
43 #raise Exception('Repo exists') | |
44 except RepoError: | |
45 log.info('%s repo is free for creation', repo_name) | |
46 #it means that there is no valid repo there... | |
47 return True | |
48 | |
30 def make_ui(path='hgwebdir.config', checkpaths=True): | 49 def make_ui(path='hgwebdir.config', checkpaths=True): |
31 """ | 50 """ |
32 A funcion that will read python rc files and make an ui from read options | 51 A funcion that will read python rc files and make an ui from read options |
33 | 52 |
34 @param path: path to mercurial config file | 53 @param path: path to mercurial config file |
35 """ | 54 """ |
36 if not os.path.isfile(path): | 55 if not os.path.isfile(path): |
37 logging.error('Unable to read config file %s' % path) | 56 log.error('Unable to read config file %s' % path) |
38 return False | 57 return False |
39 #propagated from mercurial documentation | 58 #propagated from mercurial documentation |
40 sections = [ | 59 sections = [ |
41 'alias', | 60 'alias', |
42 'auth', | 61 'auth', |