##// END OF EJS Templates
Added support for repository located in subdirectories.
marcink -
r248:fb7f0661 default
parent child Browse files
Show More
@@ -22,8 +22,32 b' def make_map(config):'
22 map.connect('hg_home', '/', controller='hg', action='index')
22 map.connect('hg_home', '/', controller='hg', action='index')
23
23
24
24
25 #REST controllers
25 #REST routes
26 map.resource('repo', 'repos', path_prefix='/_admin')
26 with map.submapper(path_prefix='/_admin', controller='repos') as m:
27 m.connect("repos", "/repos",
28 action="create", conditions=dict(method=["POST"]))
29 m.connect("repos", "/repos",
30 action="index", conditions=dict(method=["GET"]))
31 m.connect("formatted_repos", "/repos.{format}",
32 action="index",
33 conditions=dict(method=["GET"]))
34 m.connect("new_repo", "/repos/new",
35 action="new", conditions=dict(method=["GET"]))
36 m.connect("formatted_new_repo", "/repos/new.{format}",
37 action="new", conditions=dict(method=["GET"]))
38 m.connect("/repos/{id:.*}",
39 action="update", conditions=dict(method=["PUT"]))
40 m.connect("/repos/{id:.*}",
41 action="delete", conditions=dict(method=["DELETE"]))
42 m.connect("edit_repo", "/repos/{id:.*}/edit",
43 action="edit", conditions=dict(method=["GET"]))
44 m.connect("formatted_edit_repo", "/repos/{id:.*}.{format}/edit",
45 action="edit", conditions=dict(method=["GET"]))
46 m.connect("repo", "/repos/{id:.*}",
47 action="show", conditions=dict(method=["GET"]))
48 m.connect("formatted_repo", "/repos/{id:.*}.{format}",
49 action="show", conditions=dict(method=["GET"]))
50
27 map.resource('user', 'users', path_prefix='/_admin')
51 map.resource('user', 'users', path_prefix='/_admin')
28 map.resource('permission', 'permissions', path_prefix='/_admin')
52 map.resource('permission', 'permissions', path_prefix='/_admin')
29
53
@@ -34,34 +58,34 b' def make_map(config):'
34 action='add_repo')
58 action='add_repo')
35
59
36 #FEEDS
60 #FEEDS
37 map.connect('rss_feed_home', '/{repo_name}/feed/rss',
61 map.connect('rss_feed_home', '/{repo_name:.*}/feed/rss',
38 controller='feed', action='rss')
62 controller='feed', action='rss')
39 map.connect('atom_feed_home', '/{repo_name}/feed/atom',
63 map.connect('atom_feed_home', '/{repo_name:.*}/feed/atom',
40 controller='feed', action='atom')
64 controller='feed', action='atom')
41
65
42 map.connect('login_home', '/login', controller='login')
66 map.connect('login_home', '/login', controller='login')
43 map.connect('logout_home', '/logout', controller='login', action='logout')
67 map.connect('logout_home', '/logout', controller='login', action='logout')
44
68
45 map.connect('changeset_home', '/{repo_name}/changeset/{revision}',
69 map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}',
46 controller='changeset', revision='tip')
70 controller='changeset', revision='tip')
47 map.connect('summary_home', '/{repo_name}/summary',
71 map.connect('summary_home', '/{repo_name:.*}/summary',
48 controller='summary')
72 controller='summary')
49 map.connect('shortlog_home', '/{repo_name}/shortlog',
73 map.connect('shortlog_home', '/{repo_name:.*}/shortlog',
50 controller='shortlog')
74 controller='shortlog')
51 map.connect('branches_home', '/{repo_name}/branches',
75 map.connect('branches_home', '/{repo_name:.*}/branches',
52 controller='branches')
76 controller='branches')
53 map.connect('tags_home', '/{repo_name}/tags',
77 map.connect('tags_home', '/{repo_name:.*}/tags',
54 controller='tags')
78 controller='tags')
55 map.connect('changelog_home', '/{repo_name}/changelog',
79 map.connect('changelog_home', '/{repo_name:.*}/changelog',
56 controller='changelog')
80 controller='changelog')
57 map.connect('files_home', '/{repo_name}/files/{revision}/{f_path:.*}',
81 map.connect('files_home', '/{repo_name:.*}/files/{revision}/{f_path:.*}',
58 controller='files', revision='tip', f_path='')
82 controller='files', revision='tip', f_path='')
59 map.connect('files_diff_home', '/{repo_name}/diff/{f_path:.*}',
83 map.connect('files_diff_home', '/{repo_name:.*}/diff/{f_path:.*}',
60 controller='files', action='diff', revision='tip', f_path='')
84 controller='files', action='diff', revision='tip', f_path='')
61 map.connect('files_raw_home', '/{repo_name}/rawfile/{revision}/{f_path:.*}',
85 map.connect('files_raw_home', '/{repo_name:.*}/rawfile/{revision}/{f_path:.*}',
62 controller='files', action='rawfile', revision='tip', f_path='')
86 controller='files', action='rawfile', revision='tip', f_path='')
63 map.connect('files_annotate_home', '/{repo_name}/annotate/{revision}/{f_path:.*}',
87 map.connect('files_annotate_home', '/{repo_name:.*}/annotate/{revision}/{f_path:.*}',
64 controller='files', action='annotate', revision='tip', f_path='')
88 controller='files', action='annotate', revision='tip', f_path='')
65 map.connect('files_archive_home', '/{repo_name}/archive/{revision}/{fileformat}',
89 map.connect('files_archive_home', '/{repo_name:.*}/archive/{revision}/{fileformat}',
66 controller='files', action='archivefile', revision='tip')
90 controller='files', action='archivefile', revision='tip')
67 return map
91 return map
@@ -2,6 +2,8 b' from pylons import request, response, se'
2 app_globals as g
2 app_globals as g
3 from pylons.controllers.util import abort, redirect
3 from pylons.controllers.util import abort, redirect
4 from pylons_app.lib.auth import LoginRequired
4 from pylons_app.lib.auth import LoginRequired
5 from pylons.i18n.translation import _
6 from pylons_app.lib import helpers as h
5 from pylons_app.lib.base import BaseController, render
7 from pylons_app.lib.base import BaseController, render
6 from pylons_app.lib.filters import clean_repo
8 from pylons_app.lib.filters import clean_repo
7 from pylons_app.lib.utils import check_repo, invalidate_cache
9 from pylons_app.lib.utils import check_repo, invalidate_cache
@@ -39,6 +41,7 b' class ReposController(BaseController):'
39 self._create_repo(name)
41 self._create_repo(name)
40 #clear our cached list for refresh with new repo
42 #clear our cached list for refresh with new repo
41 invalidate_cache('cached_repo_list')
43 invalidate_cache('cached_repo_list')
44 h.flash(_('created repository %s') % name, category='success')
42 except Exception as e:
45 except Exception as e:
43 log.error(e)
46 log.error(e)
44
47
@@ -85,7 +88,7 b' class ReposController(BaseController):'
85
88
86 #clear our cached list for refresh with new repo
89 #clear our cached list for refresh with new repo
87 invalidate_cache('cached_repo_list')
90 invalidate_cache('cached_repo_list')
88
91 h.flash(_('deleted repository %s') % rm_path, category='success')
89 return redirect(url('repos'))
92 return redirect(url('repos'))
90
93
91
94
@@ -50,8 +50,9 b' class SimpleHg(object):'
50 return result.wsgi_application(environ, start_response)
50 return result.wsgi_application(environ, start_response)
51
51
52 try:
52 try:
53 repo_name = environ['PATH_INFO'].split('/')[1]
53 repo_name = '/'.join(environ['PATH_INFO'].split('/')[1:])
54 except:
54 except Exception as e:
55 log.error(e)
55 return HTTPNotFound()(environ, start_response)
56 return HTTPNotFound()(environ, start_response)
56
57
57 #since we wrap into hgweb, just reset the path
58 #since we wrap into hgweb, just reset the path
@@ -63,6 +64,7 b' class SimpleHg(object):'
63 try:
64 try:
64 app = wsgiapplication(self.__make_app)
65 app = wsgiapplication(self.__make_app)
65 except Exception as e:
66 except Exception as e:
67 log.error(e)
66 return HTTPNotFound()(environ, start_response)
68 return HTTPNotFound()(environ, start_response)
67 action = self.__get_action(environ)
69 action = self.__get_action(environ)
68 #invalidate cache on push
70 #invalidate cache on push
@@ -6,10 +6,7 b' log = logging.getLogger(__name__)'
6
6
7
7
8 def get_repo_slug(request):
8 def get_repo_slug(request):
9 path_info = request.environ.get('PATH_INFO')
9 return request.environ['pylons.routes_dict'].get('repo_name')
10 uri_lst = path_info.split('/')
11 repo_name = uri_lst[1]
12 return repo_name
13
10
14 def is_mercurial(environ):
11 def is_mercurial(environ):
15 """
12 """
@@ -131,14 +128,7 b' class EmptyChangeset(BaseChangeset):'
131
128
132 def repo2db_mapper():
129 def repo2db_mapper():
133 """
130 """
134 put !
131 scann all dirs for .hgdbid
132 if some dir doesn't have one generate one.
135 """
133 """
136 pass
134 pass No newline at end of file
137 #scann all dirs for .hgdbid
138 #if some dir doesn't have one generate one.
139 #
140
141
142
143
144
@@ -82,7 +82,13 b' class HgModel(object):'
82 repos_list = {}
82 repos_list = {}
83 for name, path in repos:
83 for name, path in repos:
84 try:
84 try:
85 repos_list[name] = MercurialRepository(path, baseui=baseui)
85 #name = name.split('/')[-1]
86 if repos_list.has_key(name):
87 raise RepositoryError('Duplicate repository name %s found in'
88 ' %s' % (name, path))
89 else:
90 repos_list[name] = MercurialRepository(path, baseui=baseui)
91 repos_list[name].name = name
86 except OSError:
92 except OSError:
87 continue
93 continue
88 return repos_list
94 return repos_list
General Comments 0
You need to be logged in to leave comments. Login now