Show More
@@ -2,7 +2,6 b'' | |||||
2 | # encoding: utf-8 |
|
2 | # encoding: utf-8 | |
3 | # middleware to handle mercurial api calls |
|
3 | # middleware to handle mercurial api calls | |
4 | # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
|
4 | # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> | |
5 | from mercurial.error import RepoError |
|
|||
6 |
|
5 | |||
7 | # This program is free software; you can redistribute it and/or |
|
6 | # This program is free software; you can redistribute it and/or | |
8 | # modify it under the terms of the GNU General Public License |
|
7 | # modify it under the terms of the GNU General Public License | |
@@ -30,6 +29,7 b' from datetime import datetime' | |||||
30 | from itertools import chain |
|
29 | from itertools import chain | |
31 | from mercurial.hgweb import hgweb |
|
30 | from mercurial.hgweb import hgweb | |
32 | from mercurial.hgweb.request import wsgiapplication |
|
31 | from mercurial.hgweb.request import wsgiapplication | |
|
32 | from mercurial.error import RepoError | |||
33 | from paste.auth.basic import AuthBasicAuthenticator |
|
33 | from paste.auth.basic import AuthBasicAuthenticator | |
34 | from paste.httpheaders import REMOTE_USER, AUTH_TYPE |
|
34 | from paste.httpheaders import REMOTE_USER, AUTH_TYPE | |
35 | from pylons_app.lib.auth import authfunc, HasPermissionAnyMiddleware |
|
35 | from pylons_app.lib.auth import authfunc, HasPermissionAnyMiddleware | |
@@ -37,6 +37,7 b' from pylons_app.lib.utils import is_merc' | |||||
37 | check_repo_fast |
|
37 | check_repo_fast | |
38 | from pylons_app.model import meta |
|
38 | from pylons_app.model import meta | |
39 | from pylons_app.model.db import UserLog, User |
|
39 | from pylons_app.model.db import UserLog, User | |
|
40 | import pylons_app.lib.helpers as h | |||
40 | from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError |
|
41 | from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError | |
41 | import logging |
|
42 | import logging | |
42 | import os |
|
43 | import os | |
@@ -127,16 +128,18 b' class SimpleHg(object):' | |||||
127 | log.error(traceback.format_exc()) |
|
128 | log.error(traceback.format_exc()) | |
128 | return HTTPInternalServerError()(environ, start_response) |
|
129 | return HTTPInternalServerError()(environ, start_response) | |
129 |
|
130 | |||
130 |
|
||||
131 | #invalidate cache on push |
|
131 | #invalidate cache on push | |
132 | if action == 'push': |
|
132 | if action == 'push': | |
133 | self.__invalidate_cache(repo_name) |
|
133 | self.__invalidate_cache(repo_name) | |
134 |
|
134 | messages = [] | ||
135 |
messages |
|
135 | messages.append('thank you for using hg-app') | |
136 | return self.msg_wrapper(app, environ, start_response, messages) |
|
136 | ||
|
137 | return self.msg_wrapper(app, environ, start_response, messages) | |||
|
138 | else: | |||
|
139 | return app(environ, start_response) | |||
137 |
|
140 | |||
138 |
|
141 | |||
139 | def msg_wrapper(self, app, environ, start_response, messages): |
|
142 | def msg_wrapper(self, app, environ, start_response, messages=[]): | |
140 | """ |
|
143 | """ | |
141 | Wrapper for custom messages that come out of mercurial respond messages |
|
144 | Wrapper for custom messages that come out of mercurial respond messages | |
142 | is a list of messages that the user will see at the end of response |
|
145 | is a list of messages that the user will see at the end of response | |
@@ -157,6 +160,15 b' class SimpleHg(object):' | |||||
157 |
|
160 | |||
158 | def __get_environ_user(self, environ): |
|
161 | def __get_environ_user(self, environ): | |
159 | return environ.get('REMOTE_USER') |
|
162 | return environ.get('REMOTE_USER') | |
|
163 | ||||
|
164 | def __get_size(self, repo_path, content_size): | |||
|
165 | size = int(content_size) | |||
|
166 | for path, dirs, files in os.walk(repo_path): | |||
|
167 | if path.find('.hg') == -1: | |||
|
168 | for f in files: | |||
|
169 | size += os.path.getsize(os.path.join(path, f)) | |||
|
170 | return size | |||
|
171 | return h.format_byte_size(size) | |||
160 |
|
172 | |||
161 | def __get_action(self, environ): |
|
173 | def __get_action(self, environ): | |
162 | """ |
|
174 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now