123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170(*
* Copyright (c) 2018-2022 Tarides <contact@tarides.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)open!ImportmoduleAtomic_write(K:Irmin.Type.S)(V:Irmin.Hash.S)=structmoduleAW=Irmin_mem.Atomic_write(K)(V)includeAWletv()=AW.v(Irmin_mem.config())letflush_t=()endmoduleIndexable_mem(Hash:Irmin.Hash.S)(Value:Irmin_pack.Pack_value.Swithtypehash:=Hash.tandtypekey=Hash.t)=structmodulePack=Indexable.Maker(Hash)moduleIndexable_mem=Pack.Make(Value)includeIrmin_pack.Indexable.Closeable(Indexable_mem)letvx=Indexable_mem.vx>|=make_closeableendmoduleMaker(Config:Irmin_pack.Conf.S)=structtypeendpoint=unitincludeIrmin.Key.Store_spec.Hash_keyedmoduleMake(Schema:Irmin.Schema.Extended)=structmoduleH=Schema.HashmoduleC=Schema.ContentsmoduleP=Schema.PathmoduleM=Schema.MetadatamoduleB=Schema.BranchmodulePack=Indexable.Maker(H)moduleXKey=structincludeIrmin.Key.Of_hash(H)letunfindable_of_hashx=xendmoduleX=structmoduleSchema=SchemamoduleHash=HmoduleInfo=Schema.InfomoduleContents=structmodulePack_value=Irmin_pack.Pack_value.Of_contents(Config)(H)(XKey)(C)moduleIndexable=Indexable_mem(H)(Pack_value)includeIrmin.Contents.Store_indexable(Indexable)(H)(C)endmoduleNode=structmoduleValue=Schema.Node(XKey)(XKey)moduleIndexable=structmoduleInter=Irmin_pack.Inode.Make_internal(Config)(H)(XKey)(Value)moduleCA=Pack.Make(Inter.Raw)includeIrmin_pack.Inode.Make(H)(XKey)(Value)(Inter)(CA)letv=CA.vendincludeIrmin.Node.Generic_key.Store(Contents)(Indexable)(H)(Indexable.Val)(M)(P)endmoduleNode_portable=Node.Indexable.Val.PortablemoduleCommit=structmoduleValue=structincludeSchema.Commit(Node.Key)(XKey)moduleInfo=Schema.Infotypehash=Hash.t[@@derivingirmin]endmodulePack_value=Irmin_pack.Pack_value.Of_commit(H)(XKey)(Value)moduleIndexable=Indexable_mem(H)(Pack_value)includeIrmin.Commit.Generic_key.Store(Info)(Node)(Indexable)(H)(Value)endmoduleCommit_portable=Irmin.Commit.Portable.Of_commit(Commit.Value)moduleBranch=structmoduleKey=BmoduleVal=structincludeHincludeCommit.KeyendmoduleAW=Atomic_write(Key)(Val)includeIrmin_pack.Atomic_write.Closeable(AW)letv()=AW.v()>|=make_closeableendmoduleSlice=Irmin.Backend.Slice.Make(Contents)(Node)(Commit)moduleRemote=Irmin.Backend.Remote.None(H)(B)moduleRepo=structtypet={config:Irmin.Backend.Conf.t;contents:readContents.Indexable.t;node:readNode.Indexable.t;commit:readCommit.Indexable.t;branch:Branch.t;}letcontents_tt:'aContents.t=t.contentsletnode_tt:'aNode.t=(contents_tt,t.node)letcommit_tt:'aCommit.t=(node_tt,t.commit)letbranch_tt=t.branchletconfigt=t.configletbatchtf=Commit.Indexable.batcht.commit(funcommit->Node.Indexable.batcht.node(funnode->Contents.Indexable.batcht.contents(funcontents->letcontents:'aContents.t=contentsinletnode:'aNode.t=(contents,node)inletcommit:'aCommit.t=(node,commit)infcontentsnodecommit)))letvconfig=letroot=Irmin_pack.Conf.rootconfiginlet*contents=Contents.Indexable.vrootinlet*node=Node.Indexable.vrootinlet*commit=Commit.Indexable.vrootinlet+branch=Branch.v()in{contents;node;commit;branch;config}letcloset=Contents.Indexable.close(contents_tt)>>=fun()->Node.Indexable.close(snd(node_tt))>>=fun()->Commit.Indexable.close(snd(commit_tt))>>=fun()->Branch.closet.branchendendincludeIrmin.Of_backend(X)endend