comparison hgext/lfs/blobstore.py @ 35439:e7bb5fc4570c

lfs: add git to the User-Agent header for blob transfers As we were trying to transition off of the non production lfs-test-server for further experimenting, one of the problems we ran into was interoperability. A coworker setup gitbucket[1] to act as the blob server, tested with git, and passed it off to me. But push failed with a message saying "abort: LFS server returns invalid JSON:", and then proceeded to dump a huge HTML page to the screen. It turns out that it is assuming that git is the only thing that wants to do a blob transfer, and everything else is a web browser wanting HTML. It's only a single data point, but I suspect other things may be doing this too. RFC7231 gives an example [2] of listing multiple products in decreasing order of significance. Since the standard provides for this, and since it works with the one problematic server I found, I'm just enabling this by default for a better UX. There's nothing significant about the version of git chosen, other than it is the current version. [1] https://github.com/gitbucket/gitbucket/ [2] https://tools.ietf.org/html/rfc7231#page-46
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 14 Dec 2017 13:04:08 -0500
parents f98fac24b757
children e333d27514b0
comparison
equal deleted inserted replaced
35438:0ebd94ac56d1 35439:e7bb5fc4570c
123 def __init__(self, repo, url): 123 def __init__(self, repo, url):
124 ui = repo.ui 124 ui = repo.ui
125 self.ui = ui 125 self.ui = ui
126 baseurl, authinfo = url.authinfo() 126 baseurl, authinfo = url.authinfo()
127 self.baseurl = baseurl.rstrip('/') 127 self.baseurl = baseurl.rstrip('/')
128 self.urlopener = urlmod.opener(ui, authinfo) 128 useragent = 'mercurial/%s git/2.15.1' % util.version()
129 self.urlopener = urlmod.opener(ui, authinfo, useragent)
129 self.retry = ui.configint('lfs', 'retry') 130 self.retry = ui.configint('lfs', 'retry')
130 131
131 def writebatch(self, pointers, fromstore): 132 def writebatch(self, pointers, fromstore):
132 """Batch upload from local to remote blobstore.""" 133 """Batch upload from local to remote blobstore."""
133 self._batch(pointers, fromstore, 'upload') 134 self._batch(pointers, fromstore, 'upload')