Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file hg_lib_factory_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131openHg_privateopenAsyncmoduletypeArg=sig(** A type that is intended to be used to add additional arguments to every function.
E.g. the provided default uses this type to represent flags that can be passed to
any hg command, like "--cwd". *)moduleWith_args:sigtype'atvalmap:'at->f:('a->'b)->'btend(** The output type of an hg call, such as [Deferred.t], [Or_error.t], etc. *)moduleOutput:sigtype'atvalreturn:'a->'atend(** [run] should be a function that runs hg with the command line arguments [args].
The [handle_output] function passed to [run] will be a function that can parse the
output of the particular hg command being run -- for example, `hg push` exits with a
different status depending on whether there are any changesets to push, so the
[handle_output] function provided for the "push" commands will recognize which exit
codes correspond to [`Ok] and which ones correspond to [`Nothing_to_push].
Giving [run] this type, rather than a type that just returns a [Process.Output.t],
makes it more flexible and allows it to supply more complete information in error
cases. For example, if [run] adds additional arguments (as happens in the top-level
instantiation of this functor), [run] can add them to the error provided by
[handle_output].
It's not even necessary for [run] to call [handle_output], if the type ['a Output.t]
doesn't reference ['a]. An example of this is running hg in the foreground with
[Unix.fork_exec] and [Unix.waitpid], and using [unit Deferred.t] for the output
type.
*)valrun:(args:stringlist->handle_output:(Process.Output.t->'aOr_simple_error.t)->unit->'aOutput.t)With_args.tendmoduletypeMake_s=functor(_:Arg)->sigmoduletypeSendmoduletypeHg_env=sigvalhg_binary:stringvalhgrc_path:stringvalhg_user:stringLazy.tvalhg_config_options:(string*string)listendtype'awith_global_args=?repository:string->?cwd:string->?config:(string*string)list->?env:Process.env->'atype'awith_global_args_remote=server:Command_server.t->?repository:string->?cwd:string->?config:(string*string)list->'amoduletypeHg_lib_factory=sigmoduletypeArg=ArgmoduletypeHg_env=Hg_envtypenonrec'awith_global_args='awith_global_argstypenonrec'awith_global_args_remote='awith_global_args_remotemoduleSimple:Argwithtype'aWith_args.t='awith_global_argswithtype'aOutput.t='amoduleAsync:Argwithtype'aWith_args.t='awith_global_argswithtype'aOutput.t='aDeferred.Or_error.t(** Same as Async, but with the following changes to fix the hg environment:
- hardwire a particular version of hg as stated by [hg_binary]
- set [HGUSER] to [hg_user]
- set [HGRCPATH] to [hgrc_path]. hg will now only load this file and the [.hg/hgrc]
for the repo.
*)moduleFixed_hg_environment(_:Hg_env):Argwithtype'aWith_args.t='awith_global_argswithtype'aOutput.t='aDeferred.Or_error.tmoduleRemote:Argwithtype'aWith_args.t='awith_global_args_remotewithtype'aOutput.t='aDeferred.Or_error.t(** To satisfy this functor, define a signature [S] for your hg library with respect to
the abstract type constructors ['a with_args] and ['a output]. Then generate the
interface for your library as follows:
{[
module Make_s (A : Hg_lib_factory.Arg) = struct
module type S = S
with type 'a with_args := 'a A.With_args.t
with type 'a output := 'a A.Output.t
end
module type Hg = Hg_lib_factory.Make_lib(Make_s).S
]}
This is necessary because a module type passed to a functor must either be fully
abstract or fully concrete -- you can't say the functor input has a module type [S]
which has types ['a with_args] and ['a output] unless you fully specify [S]. We want
[S] to be different for different callers, so we have to do this workaround.
*)moduleMake_lib(M:Make_s):sigmoduletypeS=sigmoduleMake(A:Arg):M(A).SmoduleSimple:M(Simple).SmoduleAsync:M(Async).SmoduleFixed_hg_environment(E:Hg_env):M(Fixed_hg_environment(E)).SmoduleRemote:M(Remote).Sendendend