##// END OF EJS Templates
small fixes for hg middleware, messages are now propagated only on push
marcink -
r340:71f25781 default
parent child Browse files
Show More
@@ -2,7 +2,6 b''
2 2 # encoding: utf-8
3 3 # middleware to handle mercurial api calls
4 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5 from mercurial.error import RepoError
6 5
7 6 # This program is free software; you can redistribute it and/or
8 7 # modify it under the terms of the GNU General Public License
@@ -30,6 +29,7 b' from datetime import datetime'
30 29 from itertools import chain
31 30 from mercurial.hgweb import hgweb
32 31 from mercurial.hgweb.request import wsgiapplication
32 from mercurial.error import RepoError
33 33 from paste.auth.basic import AuthBasicAuthenticator
34 34 from paste.httpheaders import REMOTE_USER, AUTH_TYPE
35 35 from pylons_app.lib.auth import authfunc, HasPermissionAnyMiddleware
@@ -37,6 +37,7 b' from pylons_app.lib.utils import is_merc'
37 37 check_repo_fast
38 38 from pylons_app.model import meta
39 39 from pylons_app.model.db import UserLog, User
40 import pylons_app.lib.helpers as h
40 41 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
41 42 import logging
42 43 import os
@@ -127,16 +128,18 b' class SimpleHg(object):'
127 128 log.error(traceback.format_exc())
128 129 return HTTPInternalServerError()(environ, start_response)
129 130
130
131 131 #invalidate cache on push
132 132 if action == 'push':
133 133 self.__invalidate_cache(repo_name)
134
135 messages = ['thanks for using hg app !']
136 return self.msg_wrapper(app, environ, start_response, messages)
134 messages = []
135 messages.append('thank you for using hg-app')
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 144 Wrapper for custom messages that come out of mercurial respond messages
142 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 161 def __get_environ_user(self, environ):
159 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 173 def __get_action(self, environ):
162 174 """
General Comments 0
You need to be logged in to leave comments. Login now