Mercurial > public > mercurial-scm > hg
diff hgext/lfs/blobstore.py @ 36926:0dcf50dc90b6
lfs: debug print HTTP headers and JSON payload received from the server
This has been extremely valuable to show divergences between `hg serve` and
`lfs-test-server`. Once the `hg serve` code lands, there will be a certain
amount of conditionalizing that needs to be done, because `lfs-test-server`
doesn't always follow its spec.
The $ISO_8601_DATE_TIME$ pattern masks the fact that `lfs-test-serve` is sending
out an expires_at value of "0001-01-01T00:00:00Z". `hg serve` will (probably)
use current time + 10 minutes or similar. The $HTTP_DATE$ is the current time.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 12 Mar 2018 23:08:47 -0400 |
parents | 4da09b46451e |
children | 56c7cd067477 |
line wrap: on
line diff
--- a/hgext/lfs/blobstore.py Mon Mar 12 22:30:01 2018 -0400 +++ b/hgext/lfs/blobstore.py Mon Mar 12 23:08:47 2018 -0400 @@ -217,7 +217,8 @@ batchreq.add_header('Accept', 'application/vnd.git-lfs+json') batchreq.add_header('Content-Type', 'application/vnd.git-lfs+json') try: - rawjson = self.urlopener.open(batchreq).read() + rsp = self.urlopener.open(batchreq) + rawjson = rsp.read() except util.urlerr.httperror as ex: raise LfsRemoteError(_('LFS HTTP error: %s (action=%s)') % (ex, action)) @@ -226,6 +227,19 @@ except ValueError: raise LfsRemoteError(_('LFS server returns invalid JSON: %s') % rawjson) + + if self.ui.debugflag: + self.ui.debug('Status: %d\n' % rsp.status) + # lfs-test-server and hg serve return headers in different order + self.ui.debug('%s\n' + % '\n'.join(sorted(str(rsp.info()).splitlines()))) + + if 'objects' in response: + response['objects'] = sorted(response['objects'], + key=lambda p: p['oid']) + self.ui.debug('%s\n' + % json.dumps(response, indent=2, sort_keys=True)) + return response def _checkforservererror(self, pointers, responses, action): @@ -301,6 +315,13 @@ response = b'' try: req = self.urlopener.open(request) + + if self.ui.debugflag: + self.ui.debug('Status: %d\n' % req.status) + # lfs-test-server and hg serve return headers in different order + self.ui.debug('%s\n' + % '\n'.join(sorted(str(req.info()).splitlines()))) + if action == 'download': # If downloading blobs, store downloaded data to local blobstore localstore.download(oid, req)