12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs, <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)openPersistenceletmigrate_mockup~(cctxt:Tezos_client_base.Client_context.full)~protocol_hash~next_protocol_hash=letopenLwt_result_syntaxinletbase_dir=cctxt#get_base_dirinletexplain_will_not_workexplain=let*!()=cctxt#error"@[<hv>Base directory %s %a@ This command will not work.@ Please \
specify a correct mockup base directory.@]"base_direxplain()inreturn_unitinlet*base_dir_class=classify_base_dirbase_dirinlet*()=matchbase_dir_classwith|Base_dir_does_not_exist->explain_will_not_work(funfmtr()->Format.fprintffmtr"does not exist.")|Base_dir_is_empty->explain_will_not_work(funfmtr()->Format.fprintffmtr"is empty.")|Base_dir_is_file->explain_will_not_work(funfmtr()->Format.fprintffmtr"is a file.")|Base_dir_is_nonempty->explain_will_not_work(funfmtr()->Format.fprintffmtr"is not a mockup base directory.")|Base_dir_is_mockup->return_unitinlet*(moduleCurrent_mockup_env),registration_data=get_mockup_context_from_disk~base_dir~protocol_hashcctxtinlet*(moduleNext_mockup_env)=get_registered_mockup(Somenext_protocol_hash)cctxtinlet*{chain=chain_id;rpc_context;protocol_data}=Next_mockup_env.migrateregistration_datainlet*()=overwrite_mockup~protocol_hash:next_protocol_hash~chain_id~rpc_context~protocol_data~base_dirinlet*!()=cctxt#message"Migration successful."inreturn_unit