commitcloud: advertise Cloud Sync when user uses short hashes and also updates to own commit

Summary:
Currently many users use hg up to move own commits between the repos because unaware about cloud sync.
The hint will be shown on ambiguous prefix only, so it will not distract anyone.

Reviewed By: markbt

Differential Revision: D8732276

fbshipit-source-id: ae8fa10b28873134da013bc56ff9ebc33e9ed303
This commit is contained in:
Liubov Dmitrieva 2018-07-06 07:04:31 -07:00 committed by Facebook Github Bot
parent 28e570113e
commit b159ed37b8
2 changed files with 25 additions and 3 deletions

View File

@ -166,10 +166,23 @@ def reposetup(ui, repo):
@hint("commitcloud-update-on-move")
def hintunpdateonmove():
def hintupdateonmove():
return _(
"if you would like to update to the moved version automatically add\n"
"[commitcloud]\n"
"updateonmove = true\n"
"to your .hgrc config file\n"
)
@hint("commitcloud-sync-education")
def hintcommitcloudeducation(ui):
education = ui.config("commitcloud", "education_page")
if education:
return (
_(
"for syncing your own commits between machines try Commit Cloud Sync\n"
"read more information at %s"
)
% education
)

View File

@ -125,6 +125,7 @@ from mercurial import (
exchange,
extensions,
hg,
hintutil,
i18n,
localrepo,
node as nodemod,
@ -143,7 +144,6 @@ getscratchbranchparts = bundleparts.getscratchbranchparts
scratchbookmarksparttype = bundleparts.scratchbookmarksparttype
scratchbranchparttype = bundleparts.scratchbranchparttype
batchable = peer.batchable
bin = nodemod.bin
decodelist = wireproto.decodelist
@ -869,12 +869,21 @@ def _update(orig, ui, repo, node=None, rev=None, **opts):
remoteerror = remoteerror.replace(kw, ui.label(kw, label))
ui.warn(_("pull failed: %s\n") % remoteerror)
# User updates to own commit from Commit Cloud
if ui.username() in remoteerror:
hintutil.trigger("commitcloud-sync-education", ui)
else:
ui.warn(_("'%s' found remotely\n") % mayberemote)
pulltime = time.time() - pullstarttime
ui.warn(_("pull finished in %.3f sec\n") % pulltime)
return orig(ui, repo, node, rev, **opts)
try:
return orig(ui, repo, node, rev, **opts)
except Exception:
# Show the triggered hints anyway
hintutil.show(ui)
raise
def _pull(orig, ui, repo, source="default", **opts):