Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/common.py @ 45306:9a5c4875a88c
hgweb: simplify staticfile() now that we always pass it a single directory
I didn't realize this further simplifications enabled by D8786 until
now.
Differential Revision: https://phab.mercurial-scm.org/D8874
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 03 Aug 2020 22:15:45 -0700 |
parents | 29adf0a087a1 |
children | dc9fe90bdbd5 |
comparison
equal
deleted
inserted
replaced
45305:e2320bb7a99f | 45306:9a5c4875a88c |
---|---|
189 """ | 189 """ |
190 if not ispathsafe(fname): | 190 if not ispathsafe(fname): |
191 return | 191 return |
192 | 192 |
193 fpath = os.path.join(*fname.split(b'/')) | 193 fpath = os.path.join(*fname.split(b'/')) |
194 if isinstance(directory, bytes): | 194 path = os.path.join(directory, fpath) |
195 directory = [directory] | |
196 for d in directory: | |
197 path = os.path.join(d, fpath) | |
198 if os.path.exists(path): | |
199 break | |
200 try: | 195 try: |
201 os.stat(path) | 196 os.stat(path) |
202 ct = pycompat.sysbytes( | 197 ct = pycompat.sysbytes( |
203 mimetypes.guess_type(pycompat.fsdecode(path))[0] or r"text/plain" | 198 mimetypes.guess_type(pycompat.fsdecode(path))[0] or r"text/plain" |
204 ) | 199 ) |