From 7493ba7135bdffcd789da826aa7dac1264f98707 Mon Sep 17 00:00:00 2001 From: Guillem Rieu Date: Tue, 18 Dec 2012 16:31:06 +0100 Subject: [PATCH] [change] Updating OPAM modules to integrate the darcs backend --- src/client/opamMain.ml | 14 ++++++++------ src/client/opamState.ml | 6 ++++++ src/core/opamFile.ml | 1 + src/core/opamFile.mli | 2 +- src/core/opamTypes.ml | 16 ++++++++++++++-- src/core/opamTypes.mli | 9 +++++---- src/repositories/opamLocal.ml | 2 +- src/repositories/repositories.ocp | 1 + src/scripts/opam_mk_repo.ml | 1 + 9 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/client/opamMain.ml b/src/client/opamMain.ml index aed52eb2b36..0d8753381e6 100644 --- a/src/client/opamMain.ml +++ b/src/client/opamMain.ml @@ -173,6 +173,7 @@ let repo_kind_flag = "http" , `http; "local", `local; "git" , `git; + "darcs" , `darcs; (* aliases *) "wget" , `http; @@ -181,7 +182,7 @@ let repo_kind_flag = ] in mk_opt ["k";"kind"] "KIND" "Specify the kind of the repository to be set (the main ones \ - are 'http', 'local' or 'git')." + are 'http', 'local', 'git' or 'darcs')." Arg.(some (enum kinds)) None let pattern_list = @@ -663,7 +664,7 @@ let pin = let pin_option = let doc = Arg.info ~docv:"PIN" ~doc: - "Specific version, local path or git url to pin the package to, + "Specific version, local path, git or darcs url to pin the package to, or 'none' to unpin the package." [] in Arg.(value & pos 0 (some string) None & doc) in let list = mk_flag ["l";"list"] "List the currently pinned packages." in @@ -671,6 +672,7 @@ let pin = let doc = Arg.info ~docv:"KIND" ~doc:"Force the kind of pinning." ["k";"kind"] in let kinds = [ "git" , `git; + "darcs" , `darcs; "version", `version; "local" , `local; "rsync" , `local; @@ -725,10 +727,10 @@ let default = `P "OPAM is a package manager for OCaml. It uses the powerful mancoosi tools to handle dependencies, including support for version constraints, optional dependencies, and conflicts management."; - `P "It has support for different repository backends such as HTTP, rsync and - git. It handles multiple OCaml versions concurrently, and is flexible - enough to allow you to use your own repositories and packages in - addition of the ones it provides."; + `P "It has support for different repository backends such as HTTP, rsync, git + and darcs. It handles multiple OCaml versions concurrently, and is + flexible enough to allow you to use your own repositories and packages + in addition of the ones it provides."; ] @ help_sections in Term.(ret (pure (fun _ -> `Help (`Pager, None)) $ global_options)), diff --git a/src/client/opamState.ml b/src/client/opamState.ml index e72fbe0dd54..cbf701dcb32 100644 --- a/src/client/opamState.ml +++ b/src/client/opamState.ml @@ -23,6 +23,7 @@ let log fmt = let () = OpamHTTP.register (); OpamGit.register (); + OpamDarcs.register(); OpamLocal.register () let confirm fmt = @@ -773,6 +774,11 @@ let update_pinned_package t nv pin = let module B = (val OpamRepository.find_backend `git: OpamRepository.BACKEND) in let build = OpamPath.Switch.build t.root t.switch nv in B.download_dir nv ~dst:build path + | `darcs -> + let path = OpamFilename.raw_dir (path_of_pin_option pin) in + let module B = (val OpamRepository.find_backend `darcs: OpamRepository.BACKEND) in + let build = OpamPath.Switch.build t.root t.switch nv in + B.download_dir nv ~dst:build path | _ -> OpamGlobals.error_and_exit "Cannot update the pinned package %s: wrong backend." diff --git a/src/core/opamFile.ml b/src/core/opamFile.ml index 83f80219e22..760433b0f6f 100644 --- a/src/core/opamFile.ml +++ b/src/core/opamFile.ml @@ -172,6 +172,7 @@ module URL = struct let to_string filename t = let url_name = match t.kind with | Some `git -> "git" + | Some `darcs -> "darcs" | None | Some `http -> "archive" | Some `local -> OpamGlobals.error_and_exit "Local packages are not (yet) supported." in diff --git a/src/core/opamFile.mli b/src/core/opamFile.mli index 6e873edecaa..e381406be2c 100644 --- a/src/core/opamFile.mli +++ b/src/core/opamFile.mli @@ -368,7 +368,7 @@ module URL: sig (** URL address *) val url: t -> string - (** Backend kind (could be curl/rsync/git at the moment) *) + (** Backend kind (could be curl/rsync/git/darcs at the moment) *) val kind: t -> repository_kind option (** Archive checksum *) diff --git a/src/core/opamTypes.ml b/src/core/opamTypes.ml index d9944da14dc..45418cdbdbe 100644 --- a/src/core/opamTypes.ml +++ b/src/core/opamTypes.ml @@ -54,7 +54,7 @@ type repository_name = OpamRepositoryName.t type 'a repository_name_map = 'a OpamRepositoryName.Map.t -type repository_kind = [`http|`local|`git] +type repository_kind = [`http|`local|`git|`darcs] type repository = { repo_name : repository_name; @@ -67,6 +67,7 @@ let string_of_repository_kind = function | `http -> "http" | `local -> "local" | `git -> "git" + | `darcs -> "darcs" let repository_kind_of_string = function | "wget" @@ -75,6 +76,7 @@ let repository_kind_of_string = function | "rsync" | "local" -> `local | "git" -> `git + | "darcs" -> `darcs | s -> OpamGlobals.error_and_exit "%s is not a valid repository kind." s type variable = OpamVariable.t @@ -172,6 +174,7 @@ type pin_option = | Version of version | Path of dirname | Git of dirname + | Darcs of dirname | Unpin let pin_option_of_string ?kind s = @@ -182,6 +185,11 @@ let pin_option_of_string ?kind s = Git (OpamFilename.Dir.of_string s) else Git (OpamFilename.raw_dir s) + | Some `darcs -> + if Sys.file_exists s then + Darcs (OpamFilename.Dir.of_string s) + else + Darcs (OpamFilename.raw_dir s) | Some `local -> Path (OpamFilename.Dir.of_string s) | Some `unpin -> Unpin | None -> @@ -194,17 +202,19 @@ let pin_option_of_string ?kind s = else Version (OpamPackage.Version.of_string s) -type pin_kind = [`version|`git|`local|`unpin] +type pin_kind = [`version|`git|`darcs|`local|`unpin] let string_of_pin_kind = function | `version -> "version" | `git -> "git" + | `darcs -> "darcs" | `local -> "local" | `unpin -> "unpin" let pin_kind_of_string = function | "version" -> `version | "git" -> `git + | "darcs" -> `darcs | "local" -> `local | "unpin" -> `unpin | s -> OpamGlobals.error_and_exit "%s is not a valid kind of pinning." s @@ -217,12 +227,14 @@ type pin = { let path_of_pin_option = function | Version v -> OpamPackage.Version.to_string v | Git p + | Darcs p | Path p -> OpamFilename.Dir.to_string p | Unpin -> "none" let kind_of_pin_option = function | Version _ -> `version | Git _ -> `git + | Darcs _ -> `darcs | Path _ -> `local | Unpin -> `unpin diff --git a/src/core/opamTypes.mli b/src/core/opamTypes.mli index 7fc341b3e83..6061967f693 100644 --- a/src/core/opamTypes.mli +++ b/src/core/opamTypes.mli @@ -142,13 +142,13 @@ type repository_name = OpamRepositoryName.t type 'a repository_name_map = 'a OpamRepositoryName.Map.t (** Repository kind *) -type repository_kind = [`http|`local|`git] +type repository_kind = [`http|`local|`git|`darcs] (** Pretty-print repository kinds. *) -val string_of_repository_kind: [`http|`local|`git] -> string +val string_of_repository_kind: [`http|`local|`git|`darcs] -> string (** Parser of repository kinds. Raise an error if the kind is not valid. *) -val repository_kind_of_string: string -> [`http|`local|`git] +val repository_kind_of_string: string -> [`http|`local|`git|`darcs] (** Repositories *) type repository = { @@ -289,6 +289,7 @@ type pin_option = | Version of version | Path of dirname | Git of dirname + | Darcs of dirname | Unpin (** Pinned packages *) @@ -301,7 +302,7 @@ type pin = { val string_of_pin: pin -> string (** Pin kind *) -type pin_kind = [`version|`git|`local|`unpin] +type pin_kind = [`version|`git|`darcs|`local|`unpin] (** Pretty-printing of pin kinds. *) val pin_kind_of_string: string -> pin_kind diff --git a/src/repositories/opamLocal.ml b/src/repositories/opamLocal.ml index a7ebadfcd85..a6e442fd030 100644 --- a/src/repositories/opamLocal.ml +++ b/src/repositories/opamLocal.ml @@ -25,7 +25,7 @@ let rsync ?(delete=true) src dst = OpamSystem.mkdir dst; let delete = if delete then ["--delete"] else [] in try - let lines = OpamSystem.read_command_output (["rsync" ; "-arv"; "--exclude"; ".git/*"; src; dst] @ delete) in + let lines = OpamSystem.read_command_output (["rsync" ; "-arv"; "--exclude"; ".git/*"; "--exclude"; "_darcs/*"; src; dst] @ delete) in match OpamMisc.rsync_trim lines with | [] -> Up_to_date [] | lines -> Result lines diff --git a/src/repositories/repositories.ocp b/src/repositories/repositories.ocp index 2841d22c6b0..bec771ee998 100644 --- a/src/repositories/repositories.ocp +++ b/src/repositories/repositories.ocp @@ -6,6 +6,7 @@ begin library "opam-repositories" "opamHTTP.ml" "opamLocal.ml" "opamGit.ml" + "opamDarcs.ml" ] requires = [ diff --git a/src/scripts/opam_mk_repo.ml b/src/scripts/opam_mk_repo.ml index 10d87ed1fa8..5eb6326ece8 100644 --- a/src/scripts/opam_mk_repo.ml +++ b/src/scripts/opam_mk_repo.ml @@ -19,6 +19,7 @@ open OpamFilename.OP let () = OpamHTTP.register (); OpamGit.register (); + OpamDarcs.register (); OpamLocal.register () let log fmt = OpamGlobals.log "OPAM-MK-REPO" fmt