Navigation Menu

Skip to content

Commit

Permalink
[change] Updating OPAM modules to integrate the darcs backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillem Rieu committed Dec 18, 2012
1 parent db84faa commit 7493ba7
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 14 deletions.
14 changes: 8 additions & 6 deletions src/client/opamMain.ml
Expand Up @@ -173,6 +173,7 @@ let repo_kind_flag =
"http" , `http;
"local", `local;
"git" , `git;
"darcs" , `darcs;

(* aliases *)
"wget" , `http;
Expand All @@ -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 =
Expand Down Expand Up @@ -663,14 +664,15 @@ 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
let kind =
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;
Expand Down Expand Up @@ -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)),
Expand Down
6 changes: 6 additions & 0 deletions src/client/opamState.ml
Expand Up @@ -23,6 +23,7 @@ let log fmt =
let () =
OpamHTTP.register ();
OpamGit.register ();
OpamDarcs.register();
OpamLocal.register ()

let confirm fmt =
Expand Down Expand Up @@ -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."
Expand Down
1 change: 1 addition & 0 deletions src/core/opamFile.ml
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/opamFile.mli
Expand Up @@ -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 *)
Expand Down
16 changes: 14 additions & 2 deletions src/core/opamTypes.ml
Expand Up @@ -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;
Expand All @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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 =
Expand All @@ -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 ->
Expand All @@ -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
Expand All @@ -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

Expand Down
9 changes: 5 additions & 4 deletions src/core/opamTypes.mli
Expand Up @@ -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 = {
Expand Down Expand Up @@ -289,6 +289,7 @@ type pin_option =
| Version of version
| Path of dirname
| Git of dirname
| Darcs of dirname
| Unpin

(** Pinned packages *)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/repositories/opamLocal.ml
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/repositories/repositories.ocp
Expand Up @@ -6,6 +6,7 @@ begin library "opam-repositories"
"opamHTTP.ml"
"opamLocal.ml"
"opamGit.ml"
"opamDarcs.ml"
]

requires = [
Expand Down
1 change: 1 addition & 0 deletions src/scripts/opam_mk_repo.ml
Expand Up @@ -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
Expand Down

0 comments on commit 7493ba7

Please sign in to comment.