Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opam admin add-constraint does too much reformatting #3993

Closed
kit-ty-kate opened this issue Sep 25, 2019 · 1 comment · Fixed by #4302
Closed

opam admin add-constraint does too much reformatting #3993

kit-ty-kate opened this issue Sep 25, 2019 · 1 comment · Fixed by #4302

Comments

@kit-ty-kate
Copy link
Member

I tried to use opam admin add-constraint and I found out that apart from adding the correct constraint it also reformat unrelated lines in the depends field.
This makes it a bit impractical to use.

For example opam admin add-constraint dune>=1.11 changes hardcaml.v0.12.0, lwt.4.2.1 and other similar files in the following manner:

diff --git a/packages/hardcaml/hardcaml.v0.12.0/opam b/packages/hardcaml/hardcaml.v0.12.0/opam
index ca3c8171bf..87f513d55c 100644
--- a/packages/hardcaml/hardcaml.v0.12.0/opam
+++ b/packages/hardcaml/hardcaml.v0.12.0/opam
@@ -10,13 +10,13 @@ build: [
   ["dune" "build" "-p" name "-j" jobs]
 ]
 depends: [
-  "ocaml"            {>= "4.07.0"}
-  "base"             {>= "v0.12" & < "v0.13"}
-  "ppx_jane"         {>= "v0.12" & < "v0.13"}
-  "stdio"            {>= "v0.12" & < "v0.13"}
+  "ocaml" {>= "4.07.0"}
+  "base" {>= "v0.12" & < "v0.13"}
+  "ppx_jane" {>= "v0.12" & < "v0.13"}
+  "stdio" {>= "v0.12" & < "v0.13"}
   "topological_sort" {>= "v0.12" & < "v0.13"}
-  "dune"             {>= "1.5.1"}
-  "zarith"           {>= "1.5"}
+  "dune" {>= "1.11"}
+  "zarith" {>= "1.5"}
 ]
 synopsis: "RTL Hardware Design in OCaml"
 description: "
diff --git a/packages/lwt/lwt.4.2.1/opam b/packages/lwt/lwt.4.2.1/opam
index 6c4fb5e040..431af99ad7 100644
--- a/packages/lwt/lwt.4.2.1/opam
+++ b/packages/lwt/lwt.4.2.1/opam
@@ -20,12 +20,11 @@ dev-repo: "git+https://github.com/ocsigen/lwt.git"
 
 depends: [
   "cppo" {build & >= "1.1.0"}
-  "dune"
-  "mmap"  # mmap is needed as long as Lwt supports OCaml < 4.06.0.
+  "dune" {>= "1.11"}
+  "mmap"
   "ocaml" {>= "4.02.0"}
-  "result" # result is needed as long as Lwt supports OCaml 4.02.
-  "seq" # seq is needed as long as Lwt supports OCaml < 4.07.0.
-
+  "result"
+  "seq"
   "bisect_ppx" {dev & >= "1.3.0"}
   "ocamlfind" {dev & >= "1.7.3-1"}
 ]

This would require to modify OpamFile.Syntax.to_string_with_preserved_format by detecting which elements changed and only modifying the constraints bloc for those elements only, leaving the rest of the line untouched.

Tested with opam 2.0.5

@rjbou
Copy link
Collaborator

rjbou commented Oct 7, 2019

Handling it is not so trivial, as we work on an unformatted input, and not having the end position of values & fields lead to try to determine it via the next one.
Thanks for the report!

@rjbou rjbou added this to To do in Opam 2.2.0 via automation May 22, 2020
@rjbou rjbou added this to the 2.2.0~alpha milestone May 22, 2020
@rjbou rjbou moved this from To do to In progress in Opam 2.2.0 May 22, 2020
@rjbou rjbou added this to To do in Feature Wish via automation Aug 5, 2020
@rjbou rjbou moved this from To do to In progress in Feature Wish Aug 5, 2020
Opam 2.2.0 automation moved this from In progress to Done Dec 11, 2020
Feature Wish automation moved this from In progress to Done Dec 11, 2020
@rjbou rjbou modified the milestones: 2.2.0~alpha, 2.1.0~beta4 Feb 15, 2021
@rjbou rjbou removed this from Done in Opam 2.2.0 Feb 15, 2021
@rjbou rjbou added this to To do in Opam 2.1.x via automation Feb 15, 2021
@kit-ty-kate kit-ty-kate moved this from To do to Done in Opam 2.1.x Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Feature Wish
  
Done
Opam 2.1.x
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants