--- a/hgext/phabricator.py Sun Oct 06 14:54:46 2019 +0100
+++ b/hgext/phabricator.py Sun Oct 06 15:04:54 2019 +0100
@@ -41,6 +41,7 @@
from __future__ import absolute_import
+import base64
import contextlib
import itertools
import json
@@ -579,6 +580,34 @@
)
+def uploadchunks(fctx, fphid):
+ """upload large binary files as separate chunks.
+ Phab requests chunking over 8MiB, and splits into 4MiB chunks
+ """
+ ui = fctx.repo().ui
+ chunks = callconduit(ui, b'file.querychunks', {b'filePHID': fphid})
+ progress = ui.makeprogress(
+ _(b'uploading file chunks'), unit=_(b'chunks'), total=len(chunks)
+ )
+ for chunk in chunks:
+ progress.increment()
+ if chunk[b'complete']:
+ continue
+ bstart = int(chunk[b'byteStart'])
+ bend = int(chunk[b'byteEnd'])
+ callconduit(
+ ui,
+ b'file.uploadchunk',
+ {
+ b'filePHID': fphid,
+ b'byteStart': bstart,
+ b'data': base64.b64encode(fctx.data()[bstart:bend]),
+ b'dataEncoding': b'base64',
+ },
+ )
+ progress.complete()
+
+
def creatediff(ctx):
"""create a Differential Diff"""
repo = ctx.repo()