488 if not localstore.verify(oid): |
488 if not localstore.verify(oid): |
489 raise error.Abort( |
489 raise error.Abort( |
490 _(b'detected corrupt lfs object: %s') % oid, |
490 _(b'detected corrupt lfs object: %s') % oid, |
491 hint=_(b'run hg verify'), |
491 hint=_(b'run hg verify'), |
492 ) |
492 ) |
493 request.data = lfsuploadfile(localstore.open(oid)) |
|
494 request.get_method = lambda: 'PUT' |
|
495 request.add_header('Content-Type', 'application/octet-stream') |
|
496 request.add_header('Content-Length', len(request.data)) |
|
497 |
493 |
498 for k, v in headers: |
494 for k, v in headers: |
499 request.add_header(pycompat.strurl(k), pycompat.strurl(v)) |
495 request.add_header(pycompat.strurl(k), pycompat.strurl(v)) |
500 |
496 |
501 try: |
497 try: |
|
498 if action == b'upload': |
|
499 request.data = lfsuploadfile(localstore.open(oid)) |
|
500 request.get_method = lambda: 'PUT' |
|
501 request.add_header('Content-Type', 'application/octet-stream') |
|
502 request.add_header('Content-Length', len(request.data)) |
|
503 |
502 with contextlib.closing(self.urlopener.open(request)) as res: |
504 with contextlib.closing(self.urlopener.open(request)) as res: |
503 contentlength = res.info().get(b"content-length") |
505 contentlength = res.info().get(b"content-length") |
504 ui = self.ui # Shorten debug lines |
506 ui = self.ui # Shorten debug lines |
505 if self.ui.debugflag: |
507 if self.ui.debugflag: |
506 ui.debug(b'Status: %d\n' % res.status) |
508 ui.debug(b'Status: %d\n' % res.status) |