annotate pylons_app/lib/simplehg.py @ 203:be6d8aaddbd1

dirty fix for https working.
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 22 May 2010 22:40:12 +0200
parents da59b7e07e3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
178
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
1 #!/usr/bin/env python
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
2 # encoding: utf-8
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
3 #
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
4 # Copyright (c) 2010 marcink. All rights reserved.
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
5 #
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
6 """
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
7 Created on 2010-04-28
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
8
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
9 @author: marcink
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
10 SimpleHG middleware for handling mercurial protocol request (push/clone etc.)
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
11 It's implemented with basic auth function
24dbf4bc57aa simplehg update
Marcin Kuzminski <marcin@python-works.com>
parents: 177
diff changeset
12 """
197
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
13 from datetime import datetime
111
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 from mercurial.hgweb import hgweb
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 from mercurial.hgweb.request import wsgiapplication
177
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
16 from paste.auth.basic import AuthBasicAuthenticator
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
17 from paste.httpheaders import REMOTE_USER, AUTH_TYPE
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
18 from pylons_app.lib.auth import authfunc
197
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
19 from pylons_app.lib.utils import is_mercurial, make_ui, invalidate_cache
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
20 from pylons_app.model import meta
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
21 from pylons_app.model.db import UserLogs, Users
124
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
22 from webob.exc import HTTPNotFound
197
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
23 import logging
177
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
24 import os
197
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
25 log = logging.getLogger(__name__)
177
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
26
111
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 class SimpleHg(object):
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 def __init__(self, application, config):
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 self.application = application
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 self.config = config
177
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
32 #authenticate this mercurial request using
185
3380ca40cdba added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
Marcin Kuzminski <marcin@python-works.com>
parents: 178
diff changeset
33 realm = '%s %s' % (config['hg_app_name'], 'mercurial repository')
177
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
34 self.authenticate = AuthBasicAuthenticator(realm, authfunc)
111
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 def __call__(self, environ, start_response):
203
be6d8aaddbd1 dirty fix for https working.
Marcin Kuzminski <marcin@python-works.com>
parents: 197
diff changeset
37 #dirty fix for https
be6d8aaddbd1 dirty fix for https working.
Marcin Kuzminski <marcin@python-works.com>
parents: 197
diff changeset
38 environ['wsgi.url_scheme'] = 'https'
111
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 if not is_mercurial(environ):
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 return self.application(environ, start_response)
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 else:
177
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
42 #===================================================================
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
43 # AUTHENTICATE THIS MERCURIAL REQUEST
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
44 #===================================================================
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
45 username = REMOTE_USER(environ)
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
46 if not username:
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
47 result = self.authenticate(environ)
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
48 if isinstance(result, str):
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
49 AUTH_TYPE.update(environ, 'basic')
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
50 REMOTE_USER.update(environ, result)
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
51 else:
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
52 return result.wsgi_application(environ, start_response)
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
53
124
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
54 try:
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
55 repo_name = environ['PATH_INFO'].split('/')[1]
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
56 except:
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
57 return HTTPNotFound()(environ, start_response)
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
58
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
59 #since we wrap into hgweb, just reset the path
114
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
60 environ['PATH_INFO'] = '/'
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
61 self.baseui = make_ui()
171
52bbeb1e813f Added universal cache invalidator for two cached functions.
Marcin Kuzminski <marcin@python-works.com>
parents: 124
diff changeset
62 self.basepath = self.baseui.configitems('paths')[0][1]\
52bbeb1e813f Added universal cache invalidator for two cached functions.
Marcin Kuzminski <marcin@python-works.com>
parents: 124
diff changeset
63 .replace('*', '')
114
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
64 self.repo_path = os.path.join(self.basepath, repo_name)
124
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
65 try:
197
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
66 app = wsgiapplication(self.__make_app)
124
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
67 except Exception as e:
f8ae5c1dfae2 Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
Marcin Kuzminski <marcin@python-works.com>
parents: 116
diff changeset
68 return HTTPNotFound()(environ, start_response)
171
52bbeb1e813f Added universal cache invalidator for two cached functions.
Marcin Kuzminski <marcin@python-works.com>
parents: 124
diff changeset
69
197
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
70 action = self.__get_action(environ)
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
71 #invalidate cache on push
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
72 if action == 'push':
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
73 self.__invalidate_cache(repo_name)
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
74
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
75 if action:
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
76 username = self.__get_environ_user(environ)
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
77 self.__log_user_action(username, action, repo_name)
114
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
78 return app(environ, start_response)
111
70b1e5d1e20d simplehg, cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79
197
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
80 def __make_app(self):
114
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
81 hgserve = hgweb(self.repo_path)
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
82 return self.load_web_settings(hgserve)
197
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
83
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
84 def __get_environ_user(self, environ):
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
85 return environ.get('REMOTE_USER')
114
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
86
197
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
87 def __get_action(self, environ):
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
88 """
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
89 Maps mercurial request commands into a pull or push command.
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
90 @param environ:
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
91 """
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
92 mapping = {
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
93 'changegroup': 'pull',
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
94 'changegroupsubset': 'pull',
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
95 'unbundle': 'push',
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
96 'stream_out': 'pull',
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
97 }
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
98 for qry in environ['QUERY_STRING'].split('&'):
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
99 if qry.startswith('cmd'):
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
100 cmd = qry.split('=')[-1]
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
101 if mapping.has_key(cmd):
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
102 return mapping[cmd]
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
103
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
104 def __log_user_action(self, username, action, repo):
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
105 sa = meta.Session
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
106 try:
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
107 user = sa.query(Users)\
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
108 .filter(Users.username == username).one()
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
109 user_log = UserLogs()
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
110 user_log.user_id = user.user_id
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
111 user_log.action = action
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
112 user_log.repository = repo.replace('/', '')
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
113 user_log.action_date = datetime.now()
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
114 sa.add(user_log)
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
115 sa.commit()
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
116 log.info('Adding user %s, action %s on %s',
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
117 username, action, repo)
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
118 except Exception as e:
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
119 sa.rollback()
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
120 log.error('could not log user action:%s', str(e))
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
121
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
122 def __invalidate_cache(self, repo_name):
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
123 """we know that some change was made to repositories and we should
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
124 invalidate the cache to see the changes right away but only for
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
125 push requests"""
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
126 invalidate_cache('cached_repo_list')
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
127 invalidate_cache('full_changelog', repo_name)
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
128
da59b7e07e3c Changed import to base. Removed action logging from auth to simplehg.
Marcin Kuzminski <marcin@python-works.com>
parents: 194
diff changeset
129
114
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
130 def load_web_settings(self, hgserve):
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
131 repoui = make_ui(os.path.join(self.repo_path, '.hg', 'hgrc'), False)
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
132 #set the global ui for hgserve
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
133 hgserve.repo.ui = self.baseui
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
134
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
135 if repoui:
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
136 #set the repository based config
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
137 hgserve.repo.ui = repoui
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
138
cc5cf1a93902 Implemented simplehg middleware,moved make_ui functions to lib.utils
Marcin Kuzminski <marcin@python-works.com>
parents: 111
diff changeset
139 return hgserve
177
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
140
93bd77e1f3c1 Changed auth basic handler only for mercurial request.
Marcin Kuzminski <marcin@python-works.com>
parents: 171
diff changeset
141