Permalink
Browse files

Long lines (no semantic changes)

  • Loading branch information...
1 parent 00fe3a2 commit 57e39efa7584647799a6ae107dc29d6fcafb7673 @samoht committed Mar 29, 2013
Showing with 65 additions and 48 deletions.
  1. +65 −48 src/client/opamClient.ml
View
@@ -21,9 +21,12 @@ let log fmt = OpamGlobals.log "CLIENT" fmt
let print_updated_packages t updated pinned_updated =
let new_packages =
- OpamPackage.Set.filter (fun nv -> not (OpamPackage.Set.mem nv t.installed)) updated in
+ OpamPackage.Set.filter
+ (fun nv -> not (OpamPackage.Set.mem nv t.installed))
+ updated in
let updated_packages =
- let aux set = OpamPackage.Set.filter (fun nv -> OpamPackage.Set.mem nv t.installed) set in
+ let aux set =
+ OpamPackage.Set.filter (fun nv -> OpamPackage.Set.mem nv t.installed) set in
OpamPackage.Set.union (aux updated) (aux pinned_updated) in
if not (OpamPackage.Set.is_empty new_packages) then (
if OpamPackage.Set.cardinal new_packages = 1 then
@@ -289,13 +292,16 @@ let names_of_regexp t ~installed_only ~name_only ~case_sensitive ~all regexps =
else match installed_version with
| Some v -> v
| None ->
- let nv = OpamPackage.Set.max_elt (OpamPackage.Set.filter has_name packages) in
+ let nv =
+ OpamPackage.Set.max_elt (OpamPackage.Set.filter has_name packages) in
OpamPackage.version nv in
let nv = OpamPackage.create name current_version in
let descr_f = OpamPackage.Map.find nv t.descrs in
let synopsis = OpamFile.Descr.synopsis descr_f in
let descr = OpamFile.Descr.full descr_f in
- OpamPackage.Name.Map.add name { name; current_version; installed_version; synopsis; descr }map
+ OpamPackage.Name.Map.add
+ name { name; current_version; installed_version; synopsis; descr }
+ map
) names OpamPackage.Name.Map.empty in
(* Filter the list of packages, depending on user predicates *)
@@ -318,9 +324,13 @@ let names_of_regexp t ~installed_only ~name_only ~case_sensitive ~all regexps =
module API = struct
- let list ~print_short ~installed_only ~installed_roots ?(name_only = true) ?(case_sensitive = false) regexp =
+ let list
+ ~print_short ~installed_only ~installed_roots
+ ?(name_only = true) ?(case_sensitive = false)
+ regexp =
let t = OpamState.load_state "list" in
- let names = names_of_regexp t ~installed_only ~name_only ~case_sensitive ~all:false regexp in
+ let names =
+ names_of_regexp t ~installed_only ~name_only ~case_sensitive ~all:false regexp in
let names =
if installed_roots then
OpamPackage.Name.Map.filter (fun name { current_version } ->
@@ -386,8 +396,10 @@ module API = struct
(* Compute the installed versions, for each switch *)
let installed =
OpamSwitch.Map.fold (fun switch _ map ->
- let installed = OpamFile.Installed.safe_read (OpamPath.Switch.installed t.root switch) in
- let pinned = OpamFile.Pinned.safe_read (OpamPath.Switch.pinned t.root switch) in
+ let installed =
+ OpamFile.Installed.safe_read (OpamPath.Switch.installed t.root switch) in
+ let pinned =
+ OpamFile.Pinned.safe_read (OpamPath.Switch.pinned t.root switch) in
if OpamState.mem_installed_package_by_name_aux installed name then
let nv =
if is_locally_pinned pinned then
@@ -476,30 +488,13 @@ module API = struct
| _ -> [ "installed-versions", installed_str ] in
let available_versions =
- match List.map OpamPackage.Version.to_string (OpamPackage.Version.Set.elements versions) with
+ let strings = List.map OpamPackage.Version.to_string
+ (OpamPackage.Version.Set.elements versions) in
+ match strings with
| [] -> []
| [v] -> [ "available-version" , v ]
| l -> [ "available-versions", String.concat ", " l ] in
- (*let libraries, syntax = match OpamPackage.Map.cardinal installed with
- | 0 -> [], []
- | _ ->
- let fold f =
- let m =
- OpamPackage.Map.fold (fun nv _ set ->
- let opam = OpamState.opam t nv in
- let incr = OpamVariable.Section.Set.of_list (f opam) in
- OpamVariable.Section.Set.union set incr
- ) installed OpamVariable.Section.Set.empty in
- OpamVariable.Section.Set.elements m in
- let libraries = match fold OpamFile.OPAM.libraries with
- | [] -> []
- | l -> [ "libraries", String.concat ", " (List.map OpamVariable.Section.to_string l) ] in
- let syntax = match fold OpamFile.OPAM.syntax with
- | [] -> []
- | l -> [ "syntax", String.concat ", " (List.map OpamVariable.Section.to_string l) ] in
- libraries, syntax in*)
-
let mk (empty, get, to_string) name field =
let v = field opam in
if empty = v then
@@ -598,7 +593,9 @@ module API = struct
OpamPackage.Name.Set.of_list (OpamPackage.Name.Map.keys t.pinned)
else
let names =
- List.rev_map (OpamRepositoryName.to_string |> OpamPackage.Name.of_string) repos in
+ List.rev_map
+ (OpamRepositoryName.to_string |> OpamPackage.Name.of_string)
+ repos in
OpamPackage.Name.Set.of_list (List.filter (OpamState.is_pinned t) names) in
let pinned_packages_need_update =
not (OpamPackage.Name.Set.is_empty pinned_packages) in
@@ -616,15 +613,17 @@ module API = struct
[], []
else
let all =
- OpamMisc.StringSet.of_list (List.rev_map OpamRepositoryName.to_string repos) in
+ OpamMisc.StringSet.of_list
+ (List.rev_map OpamRepositoryName.to_string repos) in
let valid_names =
OpamMisc.StringSet.of_list
(List.rev_map
(OpamPackage.name |> OpamPackage.Name.to_string)
(OpamPackage.Set.elements t.packages)) in
let (--) = OpamMisc.StringSet.diff in
let unknown_names = all -- valid_repositories -- valid_names in
- let not_pinned = (OpamMisc.StringSet.inter all valid_names) -- valid_pinned_packages in
+ let not_pinned =
+ (OpamMisc.StringSet.inter all valid_names) -- valid_pinned_packages in
OpamMisc.StringSet.elements unknown_names,
OpamMisc.StringSet.elements not_pinned in
@@ -716,7 +715,8 @@ module API = struct
if OpamState.mem_installed_package_by_name t n then
Some (OpamState.find_installed_package_by_name t n)
else (
- OpamGlobals.msg "%s is not installed.\n" (OpamPackage.Name.to_string n);
+ OpamGlobals.msg
+ "%s is not installed.\n" (OpamPackage.Name.to_string n);
None
)
) names in
@@ -756,14 +756,18 @@ module API = struct
OpamState.create_system_compiler_description root system_version;
(* Create ~/.opam/config *)
- let config = OpamFile.Config.create OpamVersion.current switch [repo.repo_name] jobs in
+ let config =
+ OpamFile.Config.create OpamVersion.current switch [repo.repo_name] jobs in
OpamFile.Config.write config_f config;
(* Create ~/.opam/aliases *)
- OpamFile.Aliases.write (OpamPath.aliases root) (OpamSwitch.Map.add switch compiler OpamSwitch.Map.empty);
+ OpamFile.Aliases.write
+ (OpamPath.aliases root)
+ (OpamSwitch.Map.add switch compiler OpamSwitch.Map.empty);
(* Init repository *)
- OpamFile.Repo_index.write (OpamPath.repo_index root) OpamPackage.Name.Map.empty;
+ OpamFile.Repo_index.write
+ (OpamPath.repo_index root) OpamPackage.Name.Map.empty;
OpamFile.Repo_config.write (OpamPath.Repository.config repo_p) repo;
OpamRepository.init repo;
@@ -785,14 +789,17 @@ module API = struct
let quiet = (compiler = OpamCompiler.system) in
OpamState.install_compiler t ~quiet switch compiler;
OpamState.update_switch_config t switch;
- update_packages t ~show_packages:false t.repositories OpamPackage.Name.Set.empty;
+ update_packages t ~show_packages:false t.repositories
+ OpamPackage.Name.Set.empty;
(* Finally, load the complete state and install the compiler packages *)
log "installing compiler packages";
let t = OpamState.load_state "init-2" in
let compiler_packages = OpamState.get_compiler_packages t compiler in
- let compiler_names = OpamPackage.Name.Set.of_list (List.rev_map fst compiler_packages) in
- let _solution = OpamSolution.resolve_and_apply ~force:true t (Init compiler_names)
+ let compiler_names =
+ OpamPackage.Name.Set.of_list (List.rev_map fst compiler_packages) in
+ let _solution =
+ OpamSolution.resolve_and_apply ~force:true t (Init compiler_names)
{ wish_install = [];
wish_remove = [];
wish_upgrade = compiler_packages } in
@@ -936,10 +943,13 @@ module API = struct
atoms in
if does_not_exist <> [] then (
- List.iter (OpamAction.remove_package ~rm_build:true ~metadata:false t) does_not_exist;
+ List.iter
+ (OpamAction.remove_package ~rm_build:true ~metadata:false t)
+ does_not_exist;
let installed_f = OpamPath.Switch.installed t.root t.switch in
let installed = OpamFile.Installed.read installed_f in
- let installed = OpamPackage.Set.filter (fun nv -> not (List.mem nv does_not_exist)) installed in
+ let installed =
+ OpamPackage.Set.filter (fun nv -> not (List.mem nv does_not_exist)) installed in
OpamFile.Installed.write installed_f installed;
);
@@ -952,25 +962,29 @@ module API = struct
if List.length not_installed = 1 then
OpamGlobals.msg "%s is not installed.\n" (to_string (List.hd not_installed))
else
- OpamGlobals.msg "%s are not installed.\n" (OpamMisc.string_of_list to_string not_installed)
+ OpamGlobals.msg "%s are not installed.\n"
+ (OpamMisc.string_of_list to_string not_installed)
);
if autoremove || atoms <> [] then (
let packages =
- OpamPackage.Set.of_list
- (List.rev_map (fun (n,_) -> OpamState.find_installed_package_by_name t n) atoms) in
+ OpamPackage.Set.of_list (List.rev_map (fun (n,_) ->
+ OpamState.find_installed_package_by_name t n
+ ) atoms) in
let universe = OpamState.universe t Depends in
let to_remove =
OpamPackage.Set.of_list
- (OpamSolver.reverse_dependencies ~depopts:false ~installed:true universe packages) in
+ (OpamSolver.reverse_dependencies
+ ~depopts:false ~installed:true universe packages) in
let installed_roots =
if autoremove then
OpamPackage.Set.diff t.installed_roots to_remove
else
OpamPackage.Set.diff t.installed to_remove in
let installed =
OpamPackage.Set.of_list
- (OpamSolver.dependencies ~depopts:true ~installed:true universe installed_roots) in
+ (OpamSolver.dependencies
+ ~depopts:true ~installed:true universe installed_roots) in
let to_remove =
if atoms = [] then
OpamPackage.Set.diff t.installed installed
@@ -1018,9 +1032,11 @@ module API = struct
let reinstall = OpamPackage.Set.of_list reinstall in
let depends =
let universe = OpamState.universe t Depends in
- OpamSolver.reverse_dependencies ~depopts:true ~installed:true universe reinstall in
+ OpamSolver.reverse_dependencies
+ ~depopts:true ~installed:true universe reinstall in
let to_process = List.map (fun pkg -> To_recompile pkg) depends in
- let solution = OpamSolution.apply t Reinstall (OpamSolver.sequential_solution to_process) in
+ let solution =
+ OpamSolution.apply t Reinstall (OpamSolver.sequential_solution to_process) in
OpamSolution.check_solution solution
let upload upload repo =
@@ -1156,7 +1172,8 @@ module SafeAPI = struct
global_lock (fun () -> API.SWITCH.switch ~quiet ~warning name)
let install ~quiet ~warning ~update_config switch ocaml_version =
- global_lock (fun () -> API.SWITCH.install ~quiet ~warning ~update_config switch ocaml_version)
+ global_lock (fun () ->
+ API.SWITCH.install ~quiet ~warning ~update_config switch ocaml_version)
let import filename =
switch_lock (fun () -> API.SWITCH.import filename)

0 comments on commit 57e39ef

Please sign in to comment.