Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/protocol.py @ 6155:ea161d648117
hgweb: no i18n in protocol responses
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 21 Feb 2008 15:56:35 +0100 |
parents | ef1c5a3b653d |
children | f89fd07fc51d |
comparison
equal
deleted
inserted
replaced
6154:ef1c5a3b653d | 6155:ea161d648117 |
---|---|
121 # require ssl by default, auth info cannot be sniffed and | 121 # require ssl by default, auth info cannot be sniffed and |
122 # replayed | 122 # replayed |
123 ssl_req = web.configbool('web', 'push_ssl', True) | 123 ssl_req = web.configbool('web', 'push_ssl', True) |
124 if ssl_req: | 124 if ssl_req: |
125 if req.env.get('wsgi.url_scheme') != 'https': | 125 if req.env.get('wsgi.url_scheme') != 'https': |
126 bail(_('ssl required\n')) | 126 bail('ssl required\n') |
127 return | 127 return |
128 proto = 'https' | 128 proto = 'https' |
129 else: | 129 else: |
130 proto = 'http' | 130 proto = 'http' |
131 | 131 |
132 # do not allow push unless explicitly allowed | 132 # do not allow push unless explicitly allowed |
133 if not web.check_perm(req, 'push', False): | 133 if not web.check_perm(req, 'push', False): |
134 bail(_('push not authorized\n'), | 134 bail('push not authorized\n', |
135 headers={'status': '401 Unauthorized'}) | 135 headers={'status': '401 Unauthorized'}) |
136 return | 136 return |
137 | 137 |
138 their_heads = req.form['heads'][0].split(' ') | 138 their_heads = req.form['heads'][0].split(' ') |
139 | 139 |
141 heads = map(hex, web.repo.heads()) | 141 heads = map(hex, web.repo.heads()) |
142 return their_heads == [hex('force')] or their_heads == heads | 142 return their_heads == [hex('force')] or their_heads == heads |
143 | 143 |
144 # fail early if possible | 144 # fail early if possible |
145 if not check_heads(): | 145 if not check_heads(): |
146 bail(_('unsynced changes\n')) | 146 bail('unsynced changes\n') |
147 return | 147 return |
148 | 148 |
149 req.respond(HTTP_OK, HGTYPE) | 149 req.respond(HTTP_OK, HGTYPE) |
150 | 150 |
151 # do not lock repo until all changegroup data is | 151 # do not lock repo until all changegroup data is |
161 try: | 161 try: |
162 lock = web.repo.lock() | 162 lock = web.repo.lock() |
163 try: | 163 try: |
164 if not check_heads(): | 164 if not check_heads(): |
165 req.write('0\n') | 165 req.write('0\n') |
166 req.write(_('unsynced changes\n')) | 166 req.write('unsynced changes\n') |
167 return | 167 return |
168 | 168 |
169 fp.seek(0) | 169 fp.seek(0) |
170 header = fp.read(6) | 170 header = fp.read(6) |
171 if header.startswith('HG') and not header.startswith('HG10'): | 171 if header.startswith('HG') and not header.startswith('HG10'): |