mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
move some operations under read path
Summary: Move some commit cloud operations under infinitepush read path: those are: * `hg cloud check` command * `hg cloud sync` command when the local repo is clean * `hg cloud switch` command will normally use the read path for the dest workspace because we clean up the repo before performing the switch * `hg cloud rejoin` command we use in fbclone will normally go through the read path as it runs in a fresh repo If something is broken, there is always a way to rerun any of these command with '--dest' flag pointing it to the write path. ``` ./hg cloud check -r 0c9596fd1 --remote --dest infinitepush-write ./hg cloud sync --dest infinitepush-write ./hg cloud switch -w other --dest infinitepush-write ``` Those use cases are limited and the lag of forward filler shouldn't be noticeable for them but we will be able to collect more signal how Mononoke performs with Commit Cloud. Sitevar to control the routing of read traffic: https://www.internalfb.com/intern/sv/HG_SSH_WRAPPER_MONONOKE_ROLLOUT/#revisions_list Reviewed By: mitrandir77 Differential Revision: D23840914 fbshipit-source-id: 40fbe2e72756e7a4cf8bc5be6a0b94f6cf4906b4
This commit is contained in:
parent
e7846a1776
commit
c5328d9d0e
@ -1459,7 +1459,7 @@ def cloudcheck(ui, repo, dest=None, **opts):
|
||||
if not revs:
|
||||
revs = ["."]
|
||||
|
||||
remotepath = ccutil.getremotepath(repo, dest)
|
||||
remotepath = ccutil.getremotereadpath(repo, dest)
|
||||
unfi = repo
|
||||
revs = scmutil.revrange(repo, revs)
|
||||
nodestocheck = [repo[r].hex() for r in revs]
|
||||
|
@ -124,11 +124,6 @@ def _sync(
|
||||
ui = repo.ui
|
||||
start = util.timer()
|
||||
|
||||
remotepath = ccutil.getremotepath(repo, dest)
|
||||
getconnection = lambda: repo.connectionpool.get(
|
||||
remotepath, connect_opts, reason="cloudsync"
|
||||
)
|
||||
|
||||
startnode = repo["."].node()
|
||||
|
||||
if full:
|
||||
@ -187,6 +182,16 @@ def _sync(
|
||||
origheads = _getheads(repo)
|
||||
origbookmarks = _getbookmarks(repo)
|
||||
|
||||
readonly = not origheads and not origbookmarks
|
||||
remotepath = (
|
||||
ccutil.getremotereadpath(repo, dest)
|
||||
if readonly
|
||||
else ccutil.getremotepath(repo, dest)
|
||||
)
|
||||
getconnection = lambda: repo.connectionpool.get(
|
||||
remotepath, connect_opts, reason="cloudsync"
|
||||
)
|
||||
|
||||
# Back up all local commits that are not already backed up.
|
||||
# Load the backup state under the repo lock to ensure a consistent view.
|
||||
with repo.lock():
|
||||
|
@ -65,17 +65,44 @@ def getreponame(repo):
|
||||
return reponame
|
||||
|
||||
|
||||
def getremotepath(repo, dest):
|
||||
# If dest is empty, pass in None to get the default path.
|
||||
def getremotewritepath(repo, dest):
|
||||
"""Select an appopriate remote repository to connect to for read/write commit cloud operations.
|
||||
|
||||
If dest is empty, pass in None to get the default path.
|
||||
Priorities: 'infinitepushwrite', 'infinitepush', 'default'
|
||||
"""
|
||||
pathname = dependencies.infinitepush.constants.pathname
|
||||
path = repo.ui.paths.getpath(
|
||||
dest or None,
|
||||
default=(pathname.infinitepushwrite, pathname.infinitepush, pathname.default),
|
||||
)
|
||||
|
||||
if not path:
|
||||
raise error.Abort(
|
||||
_("default repository not configured!"),
|
||||
_(
|
||||
"none of 'infinitepushwrite', 'infinitepush', 'default' repositories configured!"
|
||||
),
|
||||
hint=_("see 'hg help config.paths'"),
|
||||
)
|
||||
return path.pushloc or path.loc
|
||||
|
||||
|
||||
# alias
|
||||
getremotepath = getremotewritepath
|
||||
|
||||
|
||||
def getremotereadpath(repo, dest):
|
||||
"""Select an appopriate remote repository to connect to for readonly commit cloud operations.
|
||||
|
||||
If dest is empty, pass in None to get the default path.
|
||||
Priorities: 'infinitepush', 'default'
|
||||
"""
|
||||
pathname = dependencies.infinitepush.constants.pathname
|
||||
path = repo.ui.paths.getpath(
|
||||
dest or None, default=(pathname.infinitepush, pathname.default)
|
||||
)
|
||||
if not path:
|
||||
raise error.Abort(
|
||||
_("none of 'infinitepush', 'default' repositories configured!"),
|
||||
hint=_("see 'hg help config.paths'"),
|
||||
)
|
||||
return path.pushloc or path.loc
|
||||
|
@ -43,6 +43,6 @@ Verify smartlog shows only the configured data
|
||||
stable
|
||||
|
||||
note: background backup is currently disabled so your commits are not being backed up.
|
||||
abort: default repository not configured!
|
||||
abort: none of 'infinitepushwrite', 'infinitepush', 'default' repositories configured!
|
||||
(see 'hg help config.paths')
|
||||
[255]
|
||||
|
Loading…
Reference in New Issue
Block a user