package hg_lib

  1. Overview
  2. Docs
module With_args : sig ... end

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".

module Output : sig ... end

The output type of an hg call, such as Deferred.t, Or_error.t, etc.

val run : (args:string list -> handle_output:(Async.Process.Output.t -> 'a Core.Or_error.t) -> unit -> 'a Output.t) With_args.t

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.

OCaml

Innovation. Community. Security.