##// END OF EJS Templates
lfs: add the 'Authorization' property to the Batch API response, if present...
lfs: add the 'Authorization' property to the Batch API response, if present The client copies all of these properties under 'header' to the HTTP Headers of the subsequent GET or PUT request that it performs. That allows the Basic HTTP authentication used to authorize the Batch API request to also authorize the upload/download action. There's likely further work to do here. There's an 'authenticated' boolean key in the Batch API response that can be set, and there is an 'LFS-Authenticate' header that is used instead of 'WWW-Authenticate'[1]. (We likely need to support both, since some hosting solutions are likely to only respond with the latter.) In any event, this works with SCM Manager, so there is real world benefit. I'm limiting the headers returned to 'Basic', because that's all the lfs spec calls out. In practice, I've seen gitbucket emit custom header content[2]. [1] https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md#response-errors [2] https://github.com/gitbucket/gitbucket/blob/35655f33c7713f08515ed640ece0948acd6d6168/src/main/scala/gitbucket/core/servlet/GitRepositoryServlet.scala#L119

File last commit:

r36490:d0d5eef5 default
r37784:925707ac default
Show More
narrowmerge.py
77 lines | 2.9 KiB | text/x-python | PythonLexer
# narrowmerge.py - extensions to mercurial merge module to support narrow clones
#
# Copyright 2017 Google, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from mercurial.i18n import _
from mercurial import (
copies,
error,
extensions,
merge,
)
def setup():
def _manifestmerge(orig, repo, wctx, p2, pa, branchmerge, *args, **kwargs):
"""Filter updates to only lay out files that match the narrow spec."""
actions, diverge, renamedelete = orig(
repo, wctx, p2, pa, branchmerge, *args, **kwargs)
narrowmatch = repo.narrowmatch()
if narrowmatch.always():
return actions, diverge, renamedelete
nooptypes = set(['k']) # TODO: handle with nonconflicttypes
nonconflicttypes = set('a am c cm f g r e'.split())
# We mutate the items in the dict during iteration, so iterate
# over a copy.
for f, action in list(actions.items()):
if narrowmatch(f):
pass
elif not branchmerge:
del actions[f] # just updating, ignore changes outside clone
elif action[0] in nooptypes:
del actions[f] # merge does not affect file
elif action[0] in nonconflicttypes:
raise error.Abort(_('merge affects file \'%s\' outside narrow, '
'which is not yet supported') % f,
hint=_('merging in the other direction '
'may work'))
else:
raise error.Abort(_('conflict in file \'%s\' is outside '
'narrow clone') % f)
return actions, diverge, renamedelete
extensions.wrapfunction(merge, 'manifestmerge', _manifestmerge)
def _checkcollision(orig, repo, wmf, actions):
narrowmatch = repo.narrowmatch()
if not narrowmatch.always():
wmf = wmf.matches(narrowmatch)
if actions:
narrowactions = {}
for m, actionsfortype in actions.iteritems():
narrowactions[m] = []
for (f, args, msg) in actionsfortype:
if narrowmatch(f):
narrowactions[m].append((f, args, msg))
actions = narrowactions
return orig(repo, wmf, actions)
extensions.wrapfunction(merge, '_checkcollision', _checkcollision)
def _computenonoverlap(orig, repo, *args, **kwargs):
u1, u2 = orig(repo, *args, **kwargs)
narrowmatch = repo.narrowmatch()
if narrowmatch.always():
return u1, u2
u1 = [f for f in u1 if narrowmatch(f)]
u2 = [f for f in u2 if narrowmatch(f)]
return u1, u2
extensions.wrapfunction(copies, '_computenonoverlap', _computenonoverlap)