check the result of the update operation in hg cloud hide and `hg

Summary:
check the result of the update operation in `hg cloud hide` and `hg
cloud move`

The result of the operation wasn't checked in previous existed implemetation of
the `hg hide` command and it wasn't aslo checked in the implementation of `hg
move` command

The updates don't need to be transactional. It's ok if the second one fails and the first one succeeds. In this case it will be rather a 'copy' operation rather than a 'move', but it still can be fixed by a retry (as we advice here in the diff) due to the deduplication logic we have in place when we update the destination workspace. So, the changes won't be applied twice, and it will not fail if we try to apply twice, we will just ignore the duplicated update.

Reviewed By: markbt

Differential Revision: D40295995

fbshipit-source-id: 5e612bd97f5601e4ec2f5ea8e7316d8c115d1615
This commit is contained in:
Liubov Dmitrieva 2022-10-12 05:16:22 -07:00 committed by Facebook GitHub Bot
parent 1fa0c8f52f
commit fcd4f89728

View File

@ -188,7 +188,7 @@ def moveorhide(
]
with progress.spinner(ui, _("updating destination workspace")):
serv.updatereferences(
res, _refs = serv.updatereferences(
reponame,
destination,
destcloudrefs.version,
@ -199,9 +199,16 @@ def moveorhide(
newremotebookmarks=newremotebookmarks,
oldremotebookmarks=oldremotebookmarks,
)
if not res:
raise error.Abort(
_(
"conflict: the workspace '%s' was modified at the same time by another operation, please retry"
)
% destination
)
with progress.spinner(ui, _("updating commit cloud workspace")):
serv.updatereferences(
res, _refs = serv.updatereferences(
reponame,
workspacename,
cloudrefs.version,
@ -210,6 +217,14 @@ def moveorhide(
oldbookmarks=list(removebookmarks),
oldremotebookmarks=list(removeremotes),
)
if not res:
raise error.Abort(
_(
"conflict: the workspace '%s' has been modified during this operation by another participant\n"
"please, retry!"
)
% destination
)
return 1
else:
ui.status(_("nothing to change\n"))