commit cloud: improve handling of failed commits for cloud upload

Summary: Improve handling of failed commits for `hg cloud upload` and `hg cloud sync` (upload mode)

Reviewed By: markbt

Differential Revision: D29734169

fbshipit-source-id: c995f700ea23ff2898f27780c39f2bd1c58c1a02
This commit is contained in:
Liubov Dmitrieva 2021-07-19 06:50:19 -07:00 committed by Facebook GitHub Bot
parent 2e7f9e5e13
commit 2c7e60f30a
3 changed files with 24 additions and 7 deletions

View File

@ -1629,4 +1629,16 @@ def cloudupload(ui, repo, **opts):
else:
revs = None
upload.upload(repo, revs, force=opts.get("force"))
uploaded, failed = upload.upload(repo, revs, force=opts.get("force"))
if failed:
if len(failed) < 10:
while failed:
repo.ui.warn(
_("failed to upload %s\n") % nodemod.short(failed.pop()),
component="commitcloud",
)
else:
repo.ui.warn(
_("failed to upload %d commits\n") % len(failed),
component="commitcloud",
)

View File

@ -232,6 +232,9 @@ def _sync(
uploaded, failed = upload.upload(repo, None)
with repo.lock():
backupstate.BackupState(repo, remotepath, usehttp=True).update(uploaded)
# Upload returns a list of all newly uploaded commits and failed commits (not just heads).
# Backup returns a revset for failed. Create a revset for compatibility.
failed = repo.revs("%ln", failed)
else:
# Back up all local commits that are not already backed up.
# Load the backup state under the repo lock to ensure a consistent view.
@ -310,7 +313,8 @@ def _sync(
if failed:
failedset = set(repo.nodes("%ld::", failed))
if len(failedset) == 1:
if len(failedset) < 10:
while failedset:
repo.ui.warn(
_("failed to synchronize %s\n") % nodemod.short(failedset.pop()),
component="commitcloud",

View File

@ -899,7 +899,8 @@ Simulate failure to backup a commit by setting the server maxbundlesize limit ve
remote: 715c1454ae33 stack commit 2
remote: 9bd68ef10d6b toobig
push of head 9bd68ef10d6b failed: bundle is too big: 1869 bytes. max allowed size is 0 MB
commitcloud: failed to synchronize 2 commits
commitcloud: failed to synchronize a6b97eebbf74
commitcloud: failed to synchronize 9bd68ef10d6b
finished in * (glob)
Run cloud status after failing to synchronize