mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
snapshot: Improve parent uploading to commit cloud
Summary: Right now we continue silently if parent upload to commit cloud fails, which may cause more cryptic errors in Mononoke requests. Let's fail early with a good error message. I also changed slightly how to find the parents, using the same logic as we use to send the parents to Mononoke, for sanity. Reviewed By: mitrandir77 Differential Revision: D35499845 fbshipit-source-id: c97359ebd879554b7ac659db194af22689cba55c
This commit is contained in:
parent
2efa1b5f7f
commit
12de61bfe5
@ -6,6 +6,7 @@
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from edenscm.mercurial import error
|
||||
from edenscm.mercurial.edenapi_upload import (
|
||||
filetypefromfile,
|
||||
uploadhgchangesets,
|
||||
@ -17,14 +18,20 @@ from edenscm.mercurial.revset import parseage
|
||||
from .metalog import fetchlatestbubble, storelatest
|
||||
|
||||
|
||||
def _backupcurrentcommit(repo):
|
||||
"""make sure the current commit is backed up in commitcloud"""
|
||||
currentcommit = (repo["."].node(),)
|
||||
def _backupparents(repo, wctx):
|
||||
"""make sure this commit's ancestors are backed up in commitcloud"""
|
||||
parents = (wctx.p1().node(), wctx.p2().node())
|
||||
draftrevs = repo.changelog.torevset(
|
||||
repo.dageval(lambda: ancestors(currentcommit) & draft())
|
||||
repo.dageval(lambda: ancestors(parents) & draft())
|
||||
)
|
||||
|
||||
uploadhgchangesets(repo, draftrevs)
|
||||
(success, failed) = uploadhgchangesets(repo, draftrevs)
|
||||
if failed:
|
||||
raise error.Abort(
|
||||
_("failed to upload ancestors to commit cloud: {}").format(
|
||||
[repo[node].hex() for node in failed]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _parselifetime(opts):
|
||||
@ -105,11 +112,12 @@ def createremote(ui, repo, **opts):
|
||||
if ui.plain():
|
||||
overrides[("ui", "quiet")] = True
|
||||
with repo.lock(), ui.configoverride(overrides):
|
||||
_backupcurrentcommit(repo)
|
||||
|
||||
# Current working context
|
||||
wctx = repo[None]
|
||||
|
||||
hgparents = parentsfromwctx(ui, wctx)
|
||||
_backupparents(repo, wctx)
|
||||
|
||||
(time, tz) = wctx.date()
|
||||
|
||||
wc = workingcopy.fromrepo(repo, maxuntrackedsize)
|
||||
@ -128,7 +136,7 @@ def createremote(ui, repo, **opts):
|
||||
"author": wctx.user(),
|
||||
"time": int(time),
|
||||
"tz": tz,
|
||||
"hg_parents": parentsfromwctx(ui, wctx),
|
||||
"hg_parents": hgparents,
|
||||
},
|
||||
lifetime,
|
||||
previousbubble,
|
||||
|
Loading…
Reference in New Issue
Block a user