Patchwork D7046: phabricator: add the uploadchunks function

login
register
mail settings
Submitter phabricator
Date Oct. 10, 2019, 9:52 p.m.
Message ID <differential-rev-PHID-DREV-bmj3er2i6fpfgjjcvicr-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42202/
State Superseded
Headers show

Comments

phabricator - Oct. 10, 2019, 9:52 p.m.
Kwan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7046

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS




To: Kwan, #hg-reviewers
Cc: mercurial-devel
phabricator - Oct. 12, 2019, 1:48 a.m.
This revision is now accepted and ready to land.
indygreg added inline comments.
indygreg accepted this revision.

INLINE COMMENTS

> phabricator.py:608
> +        )
> +    progress.complete()
> +

Could you please follow up and use the context manager form of progress. Otherwise exceptions can result in an orphaned progress bar.

REPOSITORY
  rHG Mercurial

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7046/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7046

To: Kwan, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
phabricator - March 2, 2022, 1:46 p.m.
Herald added a subscriber: mercurial-patches.
RoryCrona added a comment.


  As said in this article using the airdorid 4.0 is very easy and smooth. The https://www.resumehelpservices.com/resumespice-com-review/ blog developers has done very good job in this latest version by bringing new features into it and making it user friendly app which can run on any user interface and operating system which is very good thing for the users.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7046/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7046

To: Kwan, #hg-reviewers, indygreg
Cc: mercurial-patches, RoryCrona, indygreg, mercurial-devel

Patch

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -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()