Skip to content

Commit

Permalink
Revert cb3d541
Browse files Browse the repository at this point in the history
  • Loading branch information
samoht committed Apr 24, 2015
1 parent ec766f8 commit 1073678
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
1 change: 0 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## 0.9.5
* Change `View.empty` return type to not mention `Lwt` anymore.
* Add `Task.empty` (the empty task) and `Task.none` (the empty task constructor)
* Completely rewrite the notification mechanism. All the watch functions now
take a callback as argument and return a de-allocation function. The callbacks
Expand Down
7 changes: 4 additions & 3 deletions bin/ir_cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,11 @@ let watch = {
printf "%s%s\n%!" v k
in
let x, y = match d with
| `Updated (x, y) -> snd x, snd y
| `Added x -> View.empty (), snd x
| `Removed x -> snd x, View.empty ()
| `Updated (x, y) -> Lwt.return (snd x), Lwt.return (snd y)
| `Added x -> View.empty (), Lwt.return (snd x)
| `Removed x -> Lwt.return (snd x), View.empty ()
in
x >>= fun x -> y >>= fun y ->
View.diff x y >>= fun diff ->
List.iter pr diff;
return_unit
Expand Down
2 changes: 1 addition & 1 deletion examples/contacts.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module Contact = struct
let view_of_t t =
let name = Contents.String t.name in
let phones = Contents.Set t.phones in
let v = View.empty () in
View.empty () >>= fun v ->
View.update v [t.id; "name" ] name >>= fun () ->
View.update v [t.id; "phones"] phones >>= fun () ->
return v
Expand Down
4 changes: 2 additions & 2 deletions examples/intrusion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let provision () =

Store.of_tag config task "upstream" >>= fun t ->

let v = View.empty () in
View.empty () >>= fun v ->
View.update v ["etc"; "manpath"]
"/usr/share/man\n\
/usr/local/share/man"
Expand All @@ -52,7 +52,7 @@ let configure () =
Lwt_unix.sleep 2. >>= fun () ->

Store.clone_force task (t "Switching to upstream") "upstream" >>= fun t ->
let v = View.empty () in
View.empty () >>= fun v ->

(*
Store.View.update v ["etc";"passwd"]
Expand Down
2 changes: 1 addition & 1 deletion examples/views.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type t = t2 list

let view_of_t t =
Log.debug "view_of_t";
let v = View.empty () in
View.empty () >>= fun v ->
Lwt_list.iteri_s (fun i t2 ->
let i = string_of_int i in
View.update v [i;"x"] t2.x >>= fun () ->
Expand Down
6 changes: 3 additions & 3 deletions lib/ir_view.ml
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ module Internal (Node: NODE) = struct
let ops = ref [] in
let parents = ref [] in
let lock = Lwt_mutex.create () in
{ parents; view; ops; lock }
Lwt.return { parents; view; ops; lock }

let create _conf _task =
Log.debug "create";
let t = empty () in
empty () >>= fun t ->
Lwt.return (fun _ -> t)

let task _ = failwith "Not task for views"
Expand Down Expand Up @@ -864,7 +864,7 @@ end

module type S = sig
include Ir_rw.HIERARCHICAL
val empty: unit -> t
val empty: unit -> t Lwt.t
val rebase: t -> into:t -> unit Ir_merge.result Lwt.t
val rebase_exn: t -> into:t -> unit Lwt.t
type db
Expand Down
2 changes: 1 addition & 1 deletion lib/ir_view.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

module type S = sig
include Ir_rw.HIERARCHICAL
val empty: unit -> t
val empty: unit -> t Lwt.t
val rebase: t -> into:t -> unit Ir_merge.result Lwt.t
val rebase_exn: t -> into:t -> unit Lwt.t
type db
Expand Down
2 changes: 1 addition & 1 deletion lib/irmin.mli
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ module type VIEW = sig
(** A view is a read-write temporary store, mirroring the main
store. *)

val empty: unit -> t
val empty: unit -> t Lwt.t
(** Create an empty view. Empty views do not have associated backend
configuration values, as they can perform in-memory operation,
independently of any given backend. *)
Expand Down
13 changes: 7 additions & 6 deletions lib_test/test_store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ module Make (S: Irmin.S) = struct
S.remove_rec (t1 "fresh") (p ["a"]) >>= fun () ->

S.head_exn (t1 "head") >>= fun h ->
let init = h, View.empty () in
View.empty () >>= fun v ->
let init = h, v in

View.watch_path (t2 "wath-path") ~init (p ["a";"b"]) (State.process state)
>>= fun unwatch ->
Expand Down Expand Up @@ -912,7 +913,7 @@ module Make (S: Irmin.S) = struct

(* Testing [View.remove] *)

let v1 = View.empty () in
View.empty () >>= fun v1 ->

View.update v1 (p ["foo";"1"]) foo1 >>= fun () ->
View.update v1 (p ["foo";"2"]) foo2 >>= fun () ->
Expand Down Expand Up @@ -954,9 +955,9 @@ module Make (S: Irmin.S) = struct
if not (cmp x y) then error msg (printer x) (printer y)
in

let v0 = View.empty () in
let v1 = View.empty () in
let v2 = View.empty () in
View.empty () >>= fun v0 ->
View.empty () >>= fun v1 ->
View.empty () >>= fun v2 ->
View.update v1 (p ["foo";"1"]) foo1 >>= fun () ->
View.update v2 (p ["foo";"1"]) foo2 >>= fun () ->
View.update v2 (p ["foo";"2"]) foo1 >>= fun () ->
Expand All @@ -973,7 +974,7 @@ module Make (S: Irmin.S) = struct

(* Testing other View operations. *)

let v0 = View.empty () in
View.empty () >>= fun v0 ->

View.update v0 (p []) foo1 >>= fun () ->
View.read v0 (p []) >>= fun foo1' ->
Expand Down

0 comments on commit 1073678

Please sign in to comment.