Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
mercurial-devel
Commits
ef36536abea3
Commit
ef36536abea3
authored
9 years ago
by
Matt Mackall
Browse files
Options
Downloads
Patches
Plain Diff
hgweb: use try/except/finally
parent
e30b66bb7d4d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mercurial/hgweb/hgwebdir_mod.py
+55
-56
55 additions, 56 deletions
mercurial/hgweb/hgwebdir_mod.py
with
55 additions
and
56 deletions
mercurial/hgweb/hgwebdir_mod.py
+
55
−
56
View file @
ef36536a
...
...
@@ -176,6 +176,5 @@
def
run_wsgi
(
self
,
req
):
try
:
try
:
self
.
refresh
()
self
.
refresh
()
...
...
@@ -181,6 +180,6 @@
virtual
=
req
.
env
.
get
(
"
PATH_INFO
"
,
""
).
strip
(
'
/
'
)
tmpl
=
self
.
templater
(
req
)
ctype
=
tmpl
(
'
mimetype
'
,
encoding
=
encoding
.
encoding
)
ctype
=
templater
.
stringify
(
ctype
)
virtual
=
req
.
env
.
get
(
"
PATH_INFO
"
,
""
).
strip
(
'
/
'
)
tmpl
=
self
.
templater
(
req
)
ctype
=
tmpl
(
'
mimetype
'
,
encoding
=
encoding
.
encoding
)
ctype
=
templater
.
stringify
(
ctype
)
...
...
@@ -186,17 +185,17 @@
# a static file
if
virtual
.
startswith
(
'
static/
'
)
or
'
static
'
in
req
.
form
:
if
virtual
.
startswith
(
'
static/
'
):
fname
=
virtual
[
7
:]
else
:
fname
=
req
.
form
[
'
static
'
][
0
]
static
=
self
.
ui
.
config
(
"
web
"
,
"
static
"
,
None
,
untrusted
=
False
)
if
not
static
:
tp
=
self
.
templatepath
or
templater
.
templatepaths
()
if
isinstance
(
tp
,
str
):
tp
=
[
tp
]
static
=
[
os
.
path
.
join
(
p
,
'
static
'
)
for
p
in
tp
]
staticfile
(
static
,
fname
,
req
)
return
[]
# a static file
if
virtual
.
startswith
(
'
static/
'
)
or
'
static
'
in
req
.
form
:
if
virtual
.
startswith
(
'
static/
'
):
fname
=
virtual
[
7
:]
else
:
fname
=
req
.
form
[
'
static
'
][
0
]
static
=
self
.
ui
.
config
(
"
web
"
,
"
static
"
,
None
,
untrusted
=
False
)
if
not
static
:
tp
=
self
.
templatepath
or
templater
.
templatepaths
()
if
isinstance
(
tp
,
str
):
tp
=
[
tp
]
static
=
[
os
.
path
.
join
(
p
,
'
static
'
)
for
p
in
tp
]
staticfile
(
static
,
fname
,
req
)
return
[]
...
...
@@ -202,6 +201,6 @@
# top-level index
elif
not
virtual
:
req
.
respond
(
HTTP_OK
,
ctype
)
return
self
.
makeindex
(
req
,
tmpl
)
# top-level index
elif
not
virtual
:
req
.
respond
(
HTTP_OK
,
ctype
)
return
self
.
makeindex
(
req
,
tmpl
)
...
...
@@ -207,3 +206,3 @@
# nested indexes and hgwebs
# nested indexes and hgwebs
...
...
@@ -209,17 +208,17 @@
repos
=
dict
(
self
.
repos
)
virtualrepo
=
virtual
while
virtualrepo
:
real
=
repos
.
get
(
virtualrepo
)
if
real
:
req
.
env
[
'
REPO_NAME
'
]
=
virtualrepo
try
:
# ensure caller gets private copy of ui
repo
=
hg
.
repository
(
self
.
ui
.
copy
(),
real
)
return
hgweb
(
repo
).
run_wsgi
(
req
)
except
IOError
,
inst
:
msg
=
inst
.
strerror
raise
ErrorResponse
(
HTTP_SERVER_ERROR
,
msg
)
except
error
.
RepoError
,
inst
:
raise
ErrorResponse
(
HTTP_SERVER_ERROR
,
str
(
inst
))
repos
=
dict
(
self
.
repos
)
virtualrepo
=
virtual
while
virtualrepo
:
real
=
repos
.
get
(
virtualrepo
)
if
real
:
req
.
env
[
'
REPO_NAME
'
]
=
virtualrepo
try
:
# ensure caller gets private copy of ui
repo
=
hg
.
repository
(
self
.
ui
.
copy
(),
real
)
return
hgweb
(
repo
).
run_wsgi
(
req
)
except
IOError
,
inst
:
msg
=
inst
.
strerror
raise
ErrorResponse
(
HTTP_SERVER_ERROR
,
msg
)
except
error
.
RepoError
,
inst
:
raise
ErrorResponse
(
HTTP_SERVER_ERROR
,
str
(
inst
))
...
...
@@ -225,6 +224,6 @@
up
=
virtualrepo
.
rfind
(
'
/
'
)
if
up
<
0
:
break
virtualrepo
=
virtualrepo
[:
up
]
up
=
virtualrepo
.
rfind
(
'
/
'
)
if
up
<
0
:
break
virtualrepo
=
virtualrepo
[:
up
]
...
...
@@ -230,7 +229,7 @@
# browse subdirectories
subdir
=
virtual
+
'
/
'
if
[
r
for
r
in
repos
if
r
.
startswith
(
subdir
)]:
req
.
respond
(
HTTP_OK
,
ctype
)
return
self
.
makeindex
(
req
,
tmpl
,
subdir
)
# browse subdirectories
subdir
=
virtual
+
'
/
'
if
[
r
for
r
in
repos
if
r
.
startswith
(
subdir
)]:
req
.
respond
(
HTTP_OK
,
ctype
)
return
self
.
makeindex
(
req
,
tmpl
,
subdir
)
...
...
@@ -236,5 +235,5 @@
# prefixes not found
req
.
respond
(
HTTP_NOT_FOUND
,
ctype
)
return
tmpl
(
"
notfound
"
,
repo
=
virtual
)
# prefixes not found
req
.
respond
(
HTTP_NOT_FOUND
,
ctype
)
return
tmpl
(
"
notfound
"
,
repo
=
virtual
)
...
...
@@ -240,7 +239,7 @@
except
ErrorResponse
,
err
:
req
.
respond
(
err
,
ctype
)
return
tmpl
(
'
error
'
,
error
=
err
.
message
or
''
)
except
ErrorResponse
,
err
:
req
.
respond
(
err
,
ctype
)
return
tmpl
(
'
error
'
,
error
=
err
.
message
or
''
)
finally
:
tmpl
=
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment