split full sync into 3 passes

Summary:
split full sync into 3 steps

Commit cloud by default pulls only 30 days of commits.

Users often see some of their commits are missing in their smartlog.

I discovered that most of the users know the '--full' option (`hg cloud sync --full`) but not the 'max_sync_age' config option.

So, they try --full option but it could fail due to very very old commits we haven't migrated to Mononoke.

Users often don't really need those commits but it's not nice that the whole sync run failed.

We know that at least latest 2 years of commits are present in Mononoke.

So if we split a bit how we sync with --full option works, it would at least result in partially successfully sync for the latest 2/3 years of commits.

Reviewed By: mitrandir77

Differential Revision: D28352355

fbshipit-source-id: b5bacd7d5256191528613e3c0bcbb21b0104ac3c
This commit is contained in:
Liubov Dmitrieva 2021-05-11 13:59:06 -07:00 committed by Facebook GitHub Bot
parent 6e9934c4a9
commit 297ab79a2a
2 changed files with 36 additions and 0 deletions

View File

@ -137,6 +137,32 @@ def _sync(
startnode = repo["."].node()
if full:
# split the full sync into few passes:
# sync the first 2 years of commits (commits should be present on the server)
# sync the first 3 years of commits (commits should be probably present on the server for most of repos)
# sync the rest of commits (some commits could be missing, haven't been migrated from the old backend)
for years in [2, 3]:
with ui.configoverride({("commitcloud", "max_sync_age"): years * 365}):
ui.status(
_(
"latest %d years of commits will be attempted to synchronize first\n"
)
% years,
component="commitcloud",
)
_sync(
repo,
cloudrefs=cloudrefs,
full=False,
cloudversion=cloudversion,
cloudworkspace=cloudworkspace,
connect_opts=connect_opts,
dest=dest,
)
ui.status(
_("latest %d years of commits synchronized\n") % years,
component="commitcloud",
)
maxage = None
else:
maxage = ui.configint("commitcloud", "max_sync_age", None)

View File

@ -552,6 +552,7 @@ Move the bookmark locally - this still gets synced ok.
A full sync pulls the old commits in
$ cd ../client3
$ hgfakedate 1990-03-05T12:01Z cloud sync --full
commitcloud: latest 2 years of commits will be attempted to synchronize first
commitcloud: synchronizing 'server' with 'user/test/default'
pulling d133b886da68 from ssh://user@dummy/server
searching for changes
@ -561,6 +562,15 @@ A full sync pulls the old commits in
added 2 changesets with 2 changes to 2 files
commitcloud: commits synchronized
finished in * (glob)
commitcloud: latest 2 years of commits synchronized
commitcloud: latest 3 years of commits will be attempted to synchronize first
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in * (glob)
commitcloud: latest 3 years of commits synchronized
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in * (glob)
$ tglogp
o d133b886da68 draft 'midstack-feb9'