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
cc0a6ea95d98
Commit
cc0a6ea95d98
authored
7 years ago
by
Matt Harbison
Browse files
Options
Downloads
Patches
Plain Diff
lfs: add support for serving blob files
parent
ea6fc58524d7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hgext/lfs/wireprotolfsserver.py
+39
-1
39 additions, 1 deletion
hgext/lfs/wireprotolfsserver.py
mercurial/hgweb/common.py
+1
-0
1 addition, 0 deletions
mercurial/hgweb/common.py
with
40 additions
and
1 deletion
hgext/lfs/wireprotolfsserver.py
+
39
−
1
View file @
cc0a6ea9
...
...
@@ -10,6 +10,7 @@
import
datetime
import
errno
import
json
import
os
from
mercurial.hgweb
import
(
common
as
hgwebcommon
,
...
...
@@ -20,6 +21,7 @@
)
HTTP_OK
=
hgwebcommon
.
HTTP_OK
HTTP_CREATED
=
hgwebcommon
.
HTTP_CREATED
HTTP_BAD_REQUEST
=
hgwebcommon
.
HTTP_BAD_REQUEST
def
handlewsgirequest
(
orig
,
rctx
,
req
,
res
,
checkperm
):
...
...
@@ -237,6 +239,8 @@
"""
method
=
req
.
method
oid
=
os
.
path
.
basename
(
req
.
dispatchpath
)
localstore
=
repo
.
svfs
.
lfslocalblobstore
if
method
==
b
'
PUT
'
:
checkperm
(
'
upload
'
)
...
...
@@ -240,6 +244,29 @@
if
method
==
b
'
PUT
'
:
checkperm
(
'
upload
'
)
# TODO: verify Content-Type?
existed
=
localstore
.
has
(
oid
)
# TODO: how to handle timeouts? The body proxy handles limiting to
# Content-Length, but what happens if a client sends less than it
# says it will?
# TODO: download() will abort if the checksum fails. It should raise
# something checksum specific that can be caught here, and turned
# into an http code.
localstore
.
download
(
oid
,
req
.
bodyfh
)
statusmessage
=
hgwebcommon
.
statusmessage
res
.
status
=
statusmessage
(
HTTP_OK
if
existed
else
HTTP_CREATED
)
# There's no payload here, but this is the header that lfs-test-server
# sends back. This eliminates some gratuitous test output conditionals.
res
.
headers
[
b
'
Content-Type
'
]
=
b
'
text/plain; charset=utf-8
'
res
.
setbodybytes
(
b
''
)
return
True
elif
method
==
b
'
GET
'
:
checkperm
(
'
pull
'
)
...
...
@@ -243,4 +270,15 @@
elif
method
==
b
'
GET
'
:
checkperm
(
'
pull
'
)
return
False
res
.
status
=
hgwebcommon
.
statusmessage
(
HTTP_OK
)
res
.
headers
[
b
'
Content-Type
'
]
=
b
'
application/octet-stream
'
# TODO: figure out how to send back the file in chunks, instead of
# reading the whole thing.
res
.
setbodybytes
(
localstore
.
read
(
oid
))
return
True
else
:
_sethttperror
(
res
,
HTTP_BAD_REQUEST
,
message
=
b
'
Unsupported LFS transfer method: %s
'
%
method
)
return
True
This diff is collapsed.
Click to expand it.
mercurial/hgweb/common.py
+
1
−
0
View file @
cc0a6ea9
...
...
@@ -23,6 +23,7 @@
httpserver
=
util
.
httpserver
HTTP_OK
=
200
HTTP_CREATED
=
201
HTTP_NOT_MODIFIED
=
304
HTTP_BAD_REQUEST
=
400
HTTP_UNAUTHORIZED
=
401
...
...
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