Skip to content

Commit 1cc3b11

Browse files
authored
Apply suggestions from code review
Co-authored-by: R. Boujbel <rjbou@ocamlpro.com>
1 parent fd9655c commit 1cc3b11

1 file changed

Lines changed: 4 additions & 15 deletions

File tree

src/state/opamFormatUpgrade.ml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,38 +1272,31 @@ let upgrades root_version root config =
12721272
if cond root config then Some v else None)
12731273
from_root_version)
12741274
in
1275-
if tdebug then
1276-
OpamConsole.error "hard upgrad all %s " (OpamStd.List.to_string OpamVersion.to_string all_hard_upgrades);
1277-
if tdebug then
1278-
OpamConsole.error "from_root_version %s" (OpamStd.List.to_string (fun (v,_,_) -> OpamVersion.to_string v) from_root_version);
12791275
let hard_upg, light_upg =
12801276
(* We take the last hard upgrade *)
12811277
let hard_upgrades =
12821278
List.filter (fun v ->
12831279
OpamVersion.compare root_version v < 0)
12841280
all_hard_upgrades
1285-
|> List.sort OpamVersion.compare
1286-
|> List.rev
1281+
|> List.sort (fun v v' -> -(OpamVersion.compare v v'))
12871282
in
1288-
if tdebug then
1289-
OpamConsole.error "hard upgrades list %s " (OpamStd.List.to_string OpamVersion.to_string hard_upgrades);
12901283
match hard_upgrades with
12911284
| latest_hard_upgrade::_ ->
12921285
List.partition (fun (v,_,_cond) ->
12931286
OpamVersion.compare v latest_hard_upgrade <= 0)
12941287
from_root_version
12951288
| [] ->
12961289
[],
1297-
(* If there is no hard upgrade, we can remove upgrade function of
1298-
conditional hard upgrade from light upgrade list safely *)
1290+
(* If there is no hard upgrade, we add a light upgrade for conditional
1291+
hard upgrade versions *)
12991292
let conditional_hard_upgs =
13001293
List.filter_map (function
13011294
| v, _, Some _ -> Some v
13021295
| _, _, _ -> None) from_root_version
13031296
in
13041297
List.map (fun (v, f, c) ->
13051298
let f =
1306-
if (List.mem v conditional_hard_upgs) then
1299+
if OpamStd.List.mem OpamVersion.equal v conditional_hard_upgs then
13071300
fun ~on_the_fly:_ _ conf -> conf, gtc_none
13081301
else f
13091302
in
@@ -1312,10 +1305,6 @@ let upgrades root_version root config =
13121305
from_root_version
13131306
in
13141307
let clean (x,y,_) = (x,y) in
1315-
if tdebug then
1316-
OpamConsole.error "hard upgrades %s" (OpamStd.List.to_string (fun (v,_,_) -> OpamVersion.to_string v) hard_upg);
1317-
if tdebug then
1318-
OpamConsole.error "light upgrades %s" (OpamStd.List.to_string (fun (v,_,_) -> OpamVersion.to_string v) light_upg);
13191308
List.map clean hard_upg, List.map clean light_upg
13201309

13211310
let default_opam_root_version = v2_1_alpha

0 commit comments

Comments
 (0)