Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgwebdir_mod.py @ 36908:e473a032f38a
hgweb: rewrite path generation for index entries
I think this code is easier to read. But the real reason to do this
is to eliminate a consumer of wsgirequest.
Differential Revision: https://phab.mercurial-scm.org/D2824
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 11 Mar 2018 15:15:02 -0700 |
parents | 006165d4d7e2 |
children | 803e0fc0cc9a |
comparison
equal
deleted
inserted
replaced
36907:006165d4d7e2 | 36908:e473a032f38a |
---|---|
7 # GNU General Public License version 2 or any later version. | 7 # GNU General Public License version 2 or any later version. |
8 | 8 |
9 from __future__ import absolute_import | 9 from __future__ import absolute_import |
10 | 10 |
11 import os | 11 import os |
12 import re | |
13 import time | 12 import time |
14 | 13 |
15 from ..i18n import _ | 14 from ..i18n import _ |
16 | 15 |
17 from .common import ( | 16 from .common import ( |
159 r = hg.repository(ui, path) | 158 r = hg.repository(ui, path) |
160 directory = False | 159 directory = False |
161 except (IOError, error.RepoError): | 160 except (IOError, error.RepoError): |
162 pass | 161 pass |
163 | 162 |
164 parts = [name] | 163 parts = [ |
165 parts.insert(0, '/' + subdir.rstrip('/')) | 164 wsgireq.req.apppath.strip('/'), |
166 if wsgireq.env['SCRIPT_NAME']: | 165 subdir.strip('/'), |
167 parts.insert(0, wsgireq.env['SCRIPT_NAME']) | 166 name.strip('/'), |
168 url = re.sub(r'/+', '/', '/'.join(parts) + '/') | 167 ] |
168 url = '/' + '/'.join(p for p in parts if p) + '/' | |
169 | 169 |
170 # show either a directory entry or a repository | 170 # show either a directory entry or a repository |
171 if directory: | 171 if directory: |
172 # get the directory's time information | 172 # get the directory's time information |
173 try: | 173 try: |