Skip to content

Commit

Permalink
Compat fix for earlier OCamls, and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AltGr committed Oct 19, 2015
1 parent 6711e8d commit e54c3cc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 107 deletions.
1 change: 1 addition & 0 deletions src/client/opamMain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ open Cmdliner
open OpamArg
open OpamTypes
open OpamTypesBase
open OpamStd.Op

let self_upgrade_exe opamroot =
OpamFilename.Op.(opamroot // "opam", opamroot // "opam.version")
Expand Down
2 changes: 2 additions & 0 deletions src/core/opamUrl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
(* *)
(**************************************************************************)

open OpamStd.Op

type version_control = [ `git | `darcs | `hg ]

type backend = [ `http | `rsync | version_control ]
Expand Down
2 changes: 1 addition & 1 deletion src/format/opamFormat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ module Pp = struct
(fun ~pos:_ -> function String (_,s) -> s | _ -> unexpected ())
(fun str -> String (pos_null,str))

let string_tr = string -| pp (fun ~pos:_ -> String.trim) (fun x -> x)
let string_tr = string -| pp (fun ~pos:_ -> OpamStd.String.strip) (fun x -> x)

let simple_arg =
pp ~name:"ident-or-string"
Expand Down
108 changes: 2 additions & 106 deletions src/format/opamTypesBase.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
(* *)
(**************************************************************************)

open OpamStd.Op

open OpamTypes

include OpamCompat
Expand All @@ -36,112 +38,6 @@ let string_of_generic_file = function
| D d -> OpamFilename.Dir.to_string d
| F f -> OpamFilename.to_string f



(*
let url_kind_of_string = function
| "http" | "https" | "ftp" | "wget" | "curl" -> `http
| "file" -> `rsync
| "git" -> `git
| "darcs" -> `darcs
| "hg" -> `hg
| "local" | "rsync" | "ssh" | "scp" | "sftp" -> `rsync
| p -> failwith (Printf.sprintf "Unsupported protocol %s" p)
let string_of_url_kind = function
| `http -> "http"
| `rsync -> "file"
| `git -> "git"
| `darcs -> "darcs"
| `hg -> "hg"
let unsplit_url (vc, transport, path, _suffix) =
String.concat "" [
(match vc with
| Some vc -> vc ^ "+"
| None -> "");
(match transport with
| Some t -> t ^ "://"
| _ -> "");
path
]
let string_of_address ?kind (url,hash) =
let url =
match kind with
| None -> url
| Some k ->
match split_url url with
| Some v, _, _, _ | None, Some v, _, _ when url_kind_of_string v = k ->
url
| _, Some t, path, _ ->
unsplit_url (Some (string_of_url_kind k), Some t, path, None)
| _, None, _, _ ->
unsplit_url (None, Some (string_of_url_kind k), url, None)
in
match hash with
| None -> url
| Some c -> Printf.sprintf "%s#%s" url c
let path_of_address (url,_) =
let _vc, transport, path, suffix = split_url url in
(* let transport = *)
(* match transport with *)
(* | Some ("https"|"http"|"ftp" as t) -> Some t *)
(* | _ -> None *)
(* in *)
unsplit_url (None, transport, path, suffix)
let address_of_string str =
let addr, hash =
match OpamStd.String.cut_at str '#' with
| None -> str, None
| Some (addr,hash) -> addr, Some hash
in
let vc, transport, path, suffix = split_url addr in
let path =
match transport with
| Some tr when url_kind_of_string tr = `rsync -> OpamSystem.real_path path
| Some _ -> path
| None -> OpamSystem.real_path path
in
unsplit_url (vc, transport, path, suffix), hash
let parse_url (s,c) =
match split_url s with
| Some vc, Some transport, path, _ ->
(Printf.sprintf "%s://%s" transport path, c), url_kind_of_string vc
| None, Some ("git"|"hg"|"darcs" as t), path, _ ->
(* VC without specified transport *)
let kind = url_kind_of_string t in
(if Re.(execp (compile @@ seq [rep1 any; str "://"])) path then
(path, c), kind
else if
Re.(execp (compile @@ seq [repn (diff any (char '/')) 2 None; char ':']))
path
then
(* Assume ssh for "host:..." (like git does) *)
("ssh://" ^ path, c), kind
else
("file://" ^ OpamSystem.real_path path, c), `rsync)
| None, _, _, Some ("git"|"hg"|"darcs" as suffix) ->
(s,c), url_kind_of_string suffix
| None, Some("file"|"rsync"|"ssh"|"scp"|"sftp"), path, _ ->
(path, c), `rsync (* strip the leading xx:// *)
| None, Some t, path, _ ->
let kind = url_kind_of_string t in
(match split_url path with
| _, Some _, _, _ -> (path,c), kind
| _, None, _, _ -> ("http://" ^ path, c), kind) (* assume http transport *)
| None, None, _, _ ->
(s, c), `rsync
| Some _, None, _, _ -> assert false
let string_of_repository_kind = string_of_url_kind
let repository_kind_of_string = url_kind_of_string
*)

let string_of_shell = function
| `fish -> "fish"
| `csh -> "csh"
Expand Down
1 change: 1 addition & 0 deletions src/repository/opamVCS.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

open OpamTypes
open OpamTypesBase
open OpamStd.Op
open OpamProcess.Job.Op

module type VCS = sig
Expand Down

0 comments on commit e54c3cc

Please sign in to comment.