diff --git a/CHANGES.md b/CHANGES.md index 528b601..dd5487a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,19 +1,14 @@ -## 0.0.7 (unreleased) - -### Added +## 0.0.7 (2024-09-20) ### Changed +- Rename `tree` to `graph` to designate the commit graph of a repository (breaking change). - Upgrade to `cmdlang.0.0.5`. -### Deprecated - ### Fixed - Retrieve some code coverage lost during the last release. -### Removed - ## 0.0.6 (2024-09-07) ### Changed @@ -48,20 +43,20 @@ Release a version compatible with the latest renames in the provider library. ### Added - Expose gca function in the `ocaml-vcs` command line. -- Add function and tests to compute GCAs in `Vcs.Tree`. +- Add function and tests to compute GCAs in `Vcs.Graph`. ### Changed - Rename `Vcs.Descendance.t` constructors for clarity. -- Improve `Vcs.Tree.Node` interface. -- Improve `Vcs.Tree.sexp_of_t` to help with debugging. +- Improve `Vcs.Graph.Node` interface. +- Improve `Vcs.Graph.sexp_of_t` to help with debugging. - Rename `git_cli` library to `vcs_git_cli` for consistency. -- Remove type parameter for `Vcs.Tree.Node_kind` (simplify interface). -- Renamed constructors for root nodes in vcs trees (`Init` => `Root`). +- Remove type parameter for `Vcs.Graph.Node_kind` (simplify interface). +- Renamed constructors for root nodes in vcs graphs (`Init` => `Root`). ### Fixed -- Fix `Vcs.Tree.add_nodes` raising when adding nodes incrementally. +- Fix `Vcs.Graph.add_nodes` raising when adding nodes incrementally. ## 0.0.2 (2024-07-26) @@ -69,7 +64,7 @@ Release a version compatible with the latest renames in the provider library. - Add documentation website powered by Docusaurus. (#7, @mbarbin) - Initiate a library `vcs-test-helpers` to help writing tests. (#4, @mbarbin) -- Add test showing how to do revision lookup from references using `Vcs.refs` and `Vcs.tree`. +- Add test showing how to do revision lookup from references using `Vcs.refs` and `Vcs.graph`. - Added dependabot config for automatically upgrading action files. ### Changed diff --git a/README.md b/README.md index 1d4b815..54b1e95 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Deploy Doc Status

-Vcs is an OCaml library for interacting with Git repositories. It provides a type-safe and direct-style API to programmatically perform Git operations - ranging from creating commits and branches, to loading and navigating commit trees in memory, computing diffs between revisions, and more. +Vcs is an OCaml library for interacting with Git repositories. It provides a type-safe and direct-style API to programmatically perform Git operations - ranging from creating commits and branches, to loading and navigating commit graphs in memory, computing diffs between revisions, and more. Designed as an interface composed of traits, Vcs dynamically dispatches its implementation at runtime. It is currently distributed with two distinct backends: a non-blocking version built atop Eio, and a blocking variant based on OCaml's standard library. Both backends operate by executing git as an external process. diff --git a/doc/docs/tests/exploratory_tests.md b/doc/docs/tests/exploratory_tests.md index 8e9a571..68da92d 100644 --- a/doc/docs/tests/exploratory_tests.md +++ b/doc/docs/tests/exploratory_tests.md @@ -45,6 +45,9 @@ COMMANDS git [OPTION]… [ARG]… run the git cli + graph [OPTION]… + compute graph of current repo + init [--quiet] [OPTION]… file initialize a new repository @@ -81,9 +84,6 @@ COMMANDS show-file-at-rev [--rev=REV] [OPTION]… file show the contents of file at a given revision - tree [OPTION]… - compute tree of current repo - COMMON OPTIONS --help[=FMT] (default=auto) Show this help in format FMT. The value FMT must be one of auto, diff --git a/doc/src/pages/index.md b/doc/src/pages/index.md index 6dcc754..605f837 100644 --- a/doc/src/pages/index.md +++ b/doc/src/pages/index.md @@ -13,6 +13,6 @@ Deploy Doc Status

-Vcs is an OCaml library for interacting with Git repositories. It provides a type-safe and direct-style API to programmatically perform Git operations - ranging from creating commits and branches, to loading and navigating commit trees in memory, computing diffs between revisions, and more. +Vcs is an OCaml library for interacting with Git repositories. It provides a type-safe and direct-style API to programmatically perform Git operations - ranging from creating commits and branches, to loading and navigating commit graphs in memory, computing diffs between revisions, and more. Designed as an interface composed of traits, Vcs dynamically dispatches its implementation at runtime. It is currently distributed with two distinct backends: a non-blocking version built atop Eio, and a blocking variant based on OCaml's standard library. Both backends operate by executing git as an external process. diff --git a/lib/vcs/src/tree.ml b/lib/vcs/src/graph.ml similarity index 96% rename from lib/vcs/src/tree.ml rename to lib/vcs/src/graph.ml index 979c884..d9ac944 100644 --- a/lib/vcs/src/tree.ml +++ b/lib/vcs/src/graph.ml @@ -367,7 +367,7 @@ let tips t = let log t = Array.mapi t.nodes ~f:(fun node _ -> log_line t node) |> Array.to_list -module Subtree = struct +module Subgraph = struct module T = struct [@@@coverage off] @@ -383,14 +383,14 @@ module Subtree = struct let is_empty { log; refs } = List.is_empty log && List.is_empty refs end -let of_subtree { Subtree.log; refs } = +let of_subgraph { Subgraph.log; refs } = let t = create () in add_nodes t ~log; set_refs t ~refs; t ;; -let subtrees t = +let subgraphs t = let dummy_cell = Union_find.create (-1) in let components = Array.map t.nodes ~f:(fun _ -> dummy_cell) in let component_id = ref 0 in @@ -415,8 +415,8 @@ let subtrees t = let id = Union_find.get components.(index) in Queue.enqueue refs.(id) { Refs.Line.rev = Node_kind.rev t.$(index); ref_kind }); Array.map2_exn logs refs ~f:(fun log refs -> - { Subtree.log = Queue.to_list log; refs = Queue.to_list refs }) - |> Array.filter ~f:(fun subtree -> not (Subtree.is_empty subtree)) + { Subgraph.log = Queue.to_list log; refs = Queue.to_list refs }) + |> Array.filter ~f:(fun subgraph -> not (Subgraph.is_empty subgraph)) |> Array.to_list ;; @@ -427,7 +427,7 @@ module Summary = struct { refs : (Rev.t * string) list ; roots : Rev.t list ; tips : (Rev.t * string list) list - ; subtrees : t list [@sexp_drop_if List.is_empty] + ; subgraphs : t list [@sexp_drop_if List.is_empty] } [@@deriving sexp_of] end @@ -441,12 +441,12 @@ let rec summary t = List.map (tips t) ~f:(fun node -> rev t node, node_refs t node |> List.map ~f:Ref_kind.to_string) in - let subtrees = - match subtrees t with + let subgraphs = + match subgraphs t with | [] | [ _ ] -> [] - | subtrees -> List.map subtrees ~f:(fun subtree -> summary (of_subtree subtree)) + | subgraphs -> List.map subgraphs ~f:(fun subgraph -> summary (of_subgraph subgraph)) in - { Summary.refs; roots = roots t |> List.map ~f:(fun id -> rev t id); tips; subtrees } + { Summary.refs; roots = roots t |> List.map ~f:(fun id -> rev t id); tips; subgraphs } ;; let check_index_exn t ~index = diff --git a/lib/vcs/src/tree.mli b/lib/vcs/src/graph.mli similarity index 80% rename from lib/vcs/src/tree.mli rename to lib/vcs/src/graph.mli index c75b121..c891587 100644 --- a/lib/vcs/src/tree.mli +++ b/lib/vcs/src/graph.mli @@ -19,41 +19,41 @@ (*_ and , respectively. *) (*_******************************************************************************) -(** Building an in-memory representation of a git tree, for queries about - history contents. +(** Building an in-memory representation of the commit graph of a git repository + for queries related to the structure of its nodes and edges. This data structure only contains the nodes, as well as the location of known branches (local and remotes) and tags. The design is such that it is easy to add new nodes, and to compute the diff of what needs to be sent to a process holding such a value in memory to - complete its view of a tree. *) + complete its view of a graph. *) type t [@@deriving sexp_of] -(** Create an empty tree that has no nodes. *) +(** Create an empty graph that has no nodes. *) val create : unit -> t -(** {1 Initializing the tree} +(** {1 Initializing the graph} - This part of the interface is the only part that mutates the tree. The tree + This part of the interface is the only part that mutates the graph. The graph manipulated in memory needs to know about the nodes and refs that are present in the git log. The calls to the functions [add_nodes] and [set_refs] are typically handled - for you by the function [Vcs.tree], however they are exposed if you want to - manually build trees in more advanced ways (such as incrementally), or for + for you by the function [Vcs.graph], however they are exposed if you want to + manually build graphs in more advanced ways (such as incrementally), or for testing purposes. - Adding nodes or refs to a tree does not affect the git repository. These are + Adding nodes or refs to a graph does not affect the git repository. These are simply operations that needs to be called to feed to [t] the information that already exists in the git log. *) -(** [add t ~log] add to [t] all the nodes from the tree log. This is idempotent +(** [add t ~log] add to [t] all the nodes from the log. This is idempotent this doesn't add the nodes that if [t] already knows.*) val add_nodes : t -> log:Log.t -> unit -(** [set_refs t ~refs] add to [t] all the refs from the tree log. *) +(** [set_refs t ~refs] add to [t] all the refs from the log. *) val set_refs : t -> refs:Refs.t -> unit (** Same as [set_refs], but one ref at a time. *) @@ -62,17 +62,17 @@ val set_ref : t -> rev:Rev.t -> ref_kind:Ref_kind.t -> unit (** {1 Nodes} The node itself doesn't carry much information, rather it is simply a - pointer to a location in the tree. Thus the functions operating on nodes - typically also require to be supplied the tree. + pointer to a location in the graph. Thus the functions operating on nodes + typically also require to be supplied the graph. - For convenience to users writing algorithms on git trees, the type [t] + For convenience to users writing algorithms on git graphs, the type [t] exposes an efficient comparable signature, meaning you can e.g. manipulate containers indexed by nodes. {1:ordering_invariant Ordering invariant} An invariant that holds in the structure and on which you can rely is that - the parents of a node are always inserted in the tree before the node itself + the parents of a node are always inserted in the graph before the node itself (from left to right), and thus if [n1 > n2] (using the node comparison function) then you can be certain that [n1] is not a parent of [n2]. *) @@ -108,21 +108,21 @@ val rev : t -> Node.t -> Rev.t merge nodes. *) val parents : t -> Node.t -> Node.t list -(** [prepend_parents tree node nodes] is an equivalent but more efficient - version of [parents tree node @ nodes]. It may be useful for recursive +(** [prepend_parents graph node nodes] is an equivalent but more efficient + version of [parents graph node @ nodes]. It may be useful for recursive traversal algorithms. *) val prepend_parents : t -> Node.t -> Node.t list -> Node.t list -(** Access the given node from the tree and return its node kind. *) +(** Access the given node from the graph and return its node kind. *) val node_kind : t -> Node.t -> Node_kind.t -(** If the tree has refs (such as tags or branches) attached to this node, - they will all be returned by [refs tree node]. The order of the refs in +(** If the graph has refs (such as tags or branches) attached to this node, + they will all be returned by [refs graph node]. The order of the refs in the resulting list is not specified. *) val node_refs : t -> Node.t -> Ref_kind.t list module Descendance : sig - (** Descendance is a relation between 2 nodes of the tree. Matching on it is + (** Descendance is a relation between 2 nodes of the graph. Matching on it is useful for example when considering the status of a branch head with respect to its upstream counterpart. *) type t = @@ -135,7 +135,7 @@ end val descendance : t -> Node.t -> Node.t -> Descendance.t -(** Return the number of nodes the tree currently holds. *) +(** Return the number of nodes the graph currently holds. *) val node_count : t -> int (** {1 Refs} *) @@ -151,7 +151,7 @@ val find_ref : t -> ref_kind:Ref_kind.t -> Node.t option (** Find the node pointed by the rev if any. *) val find_rev : t -> rev:Rev.t -> Node.t option -(** Tell if a revision points to a valid node of the tree. *) +(** Tell if a revision points to a valid node of the graph. *) val mem_rev : t -> rev:Rev.t -> bool (** {1 Roots & Tips} *) @@ -174,7 +174,7 @@ val is_strict_ancestor : t -> ancestor:Node.t -> descendant:Node.t -> bool val is_ancestor_or_equal : t -> ancestor:Node.t -> descendant:Node.t -> bool (** [greatest_common_ancestors t nodes] returns the list of nodes that are the - greatest common ancestors of the nodes in the list [nodes] in the tree [t]. + greatest common ancestors of the nodes in the list [nodes] in the graph [t]. A greatest common ancestor of a set of nodes is a node that is an ancestor of all the nodes in the set and is not a strict ancestor of any other common @@ -197,9 +197,9 @@ val log_line : t -> Node.t -> Log.Line.t (** Rebuild the entire log. *) val log : t -> Log.t -(** {1 Subtree} *) +(** {1 Subgraph} *) -module Subtree : sig +module Subgraph : sig type t = { log : Log.t ; refs : Refs.t @@ -209,8 +209,8 @@ module Subtree : sig val is_empty : t -> bool end -val subtrees : t -> Subtree.t list -val of_subtree : Subtree.t -> t +val subgraphs : t -> Subgraph.t list +val of_subgraph : Subgraph.t -> t (** {1 Summary} *) @@ -228,9 +228,9 @@ val summary : t -> Summary.t We make no guarantee about the stability of node ordering across vcs versions. The order in which nodes be inserted is not fully specified, outside of the ordering invariant discussed {{!ordering_invariant} here}. It - is considered to be only valid for the lifetime of the tree. + is considered to be only valid for the lifetime of the graph. - This is exposed if you want to write algorithms working on tree that take + This is exposed if you want to write algorithms working on graph that take advantage of operations working on int, if the rest of the exposed API isn't enough for your use case. *) diff --git a/lib/vcs/src/non_raising.ml b/lib/vcs/src/non_raising.ml index 361521b..3fb2442 100644 --- a/lib/vcs/src/non_raising.ml +++ b/lib/vcs/src/non_raising.ml @@ -65,7 +65,7 @@ module Make (M : M) : let log vcs ~repo_root = try_with (fun () -> Vcs0.log vcs ~repo_root) let refs vcs ~repo_root = try_with (fun () -> Vcs0.refs vcs ~repo_root) - let tree vcs ~repo_root = try_with (fun () -> Vcs0.tree vcs ~repo_root) + let graph vcs ~repo_root = try_with (fun () -> Vcs0.graph vcs ~repo_root) let current_branch vcs ~repo_root = try_with (fun () -> Vcs0.current_branch vcs ~repo_root) diff --git a/lib/vcs/src/refs.mli b/lib/vcs/src/refs.mli index bbcc85d..0e23bc9 100644 --- a/lib/vcs/src/refs.mli +++ b/lib/vcs/src/refs.mli @@ -48,6 +48,6 @@ val remote_branches : t -> Remote_branch_name.t list quite cheap to get all refs using {!val:Vcs.refs}, turn the result into a map with this function, and use the map for the lookups rather than trying to run one git command per lookup. You may also use - {!val:Vcs.Tree.find_ref} if you build the complete tree with - {!val:Vcs.tree}. *) + {!val:Vcs.Graph.find_ref} if you build the complete graph with + {!val:Vcs.graph}. *) val to_map : t -> Rev.t Map.M(Ref_kind).t diff --git a/lib/vcs/src/vcs.ml b/lib/vcs/src/vcs.ml index b52c07a..1f11f8e 100644 --- a/lib/vcs/src/vcs.ml +++ b/lib/vcs/src/vcs.ml @@ -27,6 +27,7 @@ module Exn = Vcs_exn module File_contents = File_contents module For_test = For_test module Git = Git +module Graph = Graph module Log = Log module Mock_rev_gen = Mock_rev_gen module Mock_revs = Mock_revs @@ -47,7 +48,6 @@ module Result = Vcs_result module Rev = Rev module Tag_name = Tag_name module Trait = Trait -module Tree = Tree module Url = Url module User_email = User_email module User_handle = User_handle diff --git a/lib/vcs/src/vcs.mli b/lib/vcs/src/vcs.mli index 91e8700..e67ab5f 100644 --- a/lib/vcs/src/vcs.mli +++ b/lib/vcs/src/vcs.mli @@ -175,16 +175,16 @@ val num_status -> changed:Num_status.Changed.t -> Num_status.t -(** {1 Manipulating the tree in memory} *) +(** {1 Manipulating the graph in memory} *) module Log = Log module Ref_kind = Ref_kind module Refs = Refs -module Tree = Tree +module Graph = Graph val log : [> Trait.log ] t -> repo_root:Repo_root.t -> Log.t val refs : [> Trait.refs ] t -> repo_root:Repo_root.t -> Refs.t -val tree : [> Trait.log | Trait.refs ] t -> repo_root:Repo_root.t -> Tree.t +val graph : [> Trait.log | Trait.refs ] t -> repo_root:Repo_root.t -> Graph.t (** {1 Rev parse utils} *) diff --git a/lib/vcs/src/vcs0.ml b/lib/vcs/src/vcs0.ml index 5c591fd..11c8b06 100644 --- a/lib/vcs/src/vcs0.ml +++ b/lib/vcs/src/vcs0.ml @@ -126,16 +126,16 @@ let refs (Provider.T { t; handler }) ~repo_root = |> of_result ~step:(lazy [%sexp "Vcs.refs", { repo_root : Repo_root.t }]) ;; -let tree (Provider.T { t; handler }) ~repo_root = +let graph (Provider.T { t; handler }) ~repo_root = let module L = (val Provider.Handler.lookup handler ~trait:Trait.Log) in let module R = (val Provider.Handler.lookup handler ~trait:Trait.Refs) in - let tree = Tree.create () in + let graph = Graph.create () in (let%bind log = L.all t ~repo_root in let%bind refs = R.show_ref t ~repo_root in - Tree.add_nodes tree ~log; - Tree.set_refs tree ~refs; - return tree) - |> of_result ~step:(lazy [%sexp "Vcs.tree", { repo_root : Repo_root.t }]) + Graph.add_nodes graph ~log; + Graph.set_refs graph ~refs; + return graph) + |> of_result ~step:(lazy [%sexp "Vcs.graph", { repo_root : Repo_root.t }]) ;; let set_user_name (Provider.T { t; handler }) ~repo_root ~user_name = diff --git a/lib/vcs/src/vcs_interface.mli b/lib/vcs/src/vcs_interface.mli index 447ba9f..45203d2 100644 --- a/lib/vcs/src/vcs_interface.mli +++ b/lib/vcs/src/vcs_interface.mli @@ -120,7 +120,7 @@ module type S = sig val log : [> Trait.log ] t -> repo_root:Repo_root.t -> Log.t result val refs : [> Trait.refs ] t -> repo_root:Repo_root.t -> Refs.t result - val tree : [> Trait.log | Trait.refs ] t -> repo_root:Repo_root.t -> Tree.t result + val graph : [> Trait.log | Trait.refs ] t -> repo_root:Repo_root.t -> Graph.t result val set_user_name : [> Trait.config ] t diff --git a/lib/vcs/test/test__tree.ml b/lib/vcs/test/test__graph.ml similarity index 74% rename from lib/vcs/test/test__tree.ml rename to lib/vcs/test/test__graph.ml index 341d8e9..b997f65 100644 --- a/lib/vcs/test/test__tree.ml +++ b/lib/vcs/test/test__graph.ml @@ -19,7 +19,7 @@ (* and , respectively. *) (*******************************************************************************) -let%expect_test "tree" = +let%expect_test "graph" = Eio_main.run @@ fun env -> let log = @@ -34,21 +34,21 @@ let%expect_test "tree" = let lines = String.split_lines contents in Vcs_git_cli.Refs.parse_lines_exn ~lines in - let tree = Vcs.Tree.create () in - print_s [%sexp { node_count = (Vcs.Tree.node_count tree : int) }]; + let graph = Vcs.Graph.create () in + print_s [%sexp { node_count = (Vcs.Graph.node_count graph : int) }]; [%expect {| ((node_count 0)) |}]; - Vcs.Tree.add_nodes tree ~log; - print_s [%sexp { node_count = (Vcs.Tree.node_count tree : int) }]; + Vcs.Graph.add_nodes graph ~log; + print_s [%sexp { node_count = (Vcs.Graph.node_count graph : int) }]; [%expect {| ((node_count 180)) |}]; - List.iter refs ~f:(fun { rev; ref_kind } -> Vcs.Tree.set_ref tree ~rev ~ref_kind); - let refs = Vcs.Tree.refs tree in + List.iter refs ~f:(fun { rev; ref_kind } -> Vcs.Graph.set_ref graph ~rev ~ref_kind); + let refs = Vcs.Graph.refs graph in List.iter refs ~f:(fun { rev; ref_kind } -> - let node = Vcs.Tree.find_ref tree ~ref_kind |> Option.value_exn ~here:[%here] in - let rev' = Vcs.Tree.rev tree node in + let node = Vcs.Graph.find_ref graph ~ref_kind |> Option.value_exn ~here:[%here] in + let rev' = Vcs.Graph.rev graph node in require_equal [%here] (module Vcs.Rev) rev rev'; - let node' = Vcs.Tree.find_rev tree ~rev |> Option.value_exn ~here:[%here] in - require_equal [%here] (module Vcs.Tree.Node) node node'; - let parents = Vcs.Tree.parents tree node |> List.map ~f:(Vcs.Tree.rev tree) in + let node' = Vcs.Graph.find_rev graph ~rev |> Option.value_exn ~here:[%here] in + require_equal [%here] (module Vcs.Graph.Node) node node'; + let parents = Vcs.Graph.parents graph node |> List.map ~f:(Vcs.Graph.rev graph) in print_s [%sexp { ref_kind : Vcs.Ref_kind.t; rev : Vcs.Rev.t; parents : Vcs.Rev.t list }]); [%expect @@ -109,7 +109,7 @@ let%expect_test "tree" = ((ref_kind (Tag (tag_name 0.0.3-preview.1))) (rev 1887c81ebf9b84c548bc35038f7af82a18eb77bf) (parents (b258b0cde128083c4f05bcf276bcc1322f1d36a2))) |}]; - print_s [%sexp (Vcs.Tree.summary tree : Vcs.Tree.Summary.t)]; + print_s [%sexp (Vcs.Graph.summary graph : Vcs.Graph.Summary.t)]; [%expect {| ((refs ( @@ -141,7 +141,7 @@ let%expect_test "tree" = refs/heads/gh-pages refs/remotes/origin/gh-pages)) (2e4fbeae154ec896262decf1ab3bee5687b93f21 ( refs/heads/main refs/heads/subrepo refs/remotes/origin/main)))) - (subtrees ( + (subgraphs ( ((refs ( (2e4fbeae154ec896262decf1ab3bee5687b93f21 refs/heads/main) (2e4fbeae154ec896262decf1ab3bee5687b93f21 refs/heads/subrepo) @@ -174,20 +174,20 @@ let%expect_test "tree" = 7135b7f4790562e94d9122365478f0d39f5ffead ( refs/heads/gh-pages refs/remotes/origin/gh-pages)))))))) |}]; let main = - Vcs.Tree.find_ref - tree + Vcs.Graph.find_ref + graph ~ref_kind:(Local_branch { branch_name = Vcs.Branch_name.v "main" }) |> Option.value_exn ~here:[%here] in let subrepo = - Vcs.Tree.find_ref - tree + Vcs.Graph.find_ref + graph ~ref_kind:(Local_branch { branch_name = Vcs.Branch_name.v "subrepo" }) |> Option.value_exn ~here:[%here] in let progress_bar = - Vcs.Tree.find_ref - tree + Vcs.Graph.find_ref + graph ~ref_kind: (Remote_branch { remote_branch_name = @@ -198,18 +198,18 @@ let%expect_test "tree" = |> Option.value_exn ~here:[%here] in let tag_0_0_1 = - Vcs.Tree.find_ref tree ~ref_kind:(Tag { tag_name = Vcs.Tag_name.v "0.0.1" }) + Vcs.Graph.find_ref graph ~ref_kind:(Tag { tag_name = Vcs.Tag_name.v "0.0.1" }) |> Option.value_exn ~here:[%here] in let tag_0_0_2 = - Vcs.Tree.find_ref tree ~ref_kind:(Tag { tag_name = Vcs.Tag_name.v "0.0.2" }) + Vcs.Graph.find_ref graph ~ref_kind:(Tag { tag_name = Vcs.Tag_name.v "0.0.2" }) |> Option.value_exn ~here:[%here] in List.iter [ main; subrepo; progress_bar; tag_0_0_1; tag_0_0_2 ] ~f:(fun node -> print_s [%sexp - { node = (Vcs.Tree.rev tree node : Vcs.Rev.t) - ; refs = (Vcs.Tree.node_refs tree node : Vcs.Ref_kind.t list) + { node = (Vcs.Graph.rev graph node : Vcs.Rev.t) + ; refs = (Vcs.Graph.node_refs graph node : Vcs.Ref_kind.t list) }]); [%expect {| @@ -240,16 +240,16 @@ let%expect_test "tree" = ((node 0d4750ff594236a4bd970e1c90b8bbad80fcadff) (refs ((Tag (tag_name 0.0.2))))) |}]; (* Log. *) - print_s [%sexp (List.length (Vcs.Tree.log tree) : int)]; + print_s [%sexp (List.length (Vcs.Graph.log graph) : int)]; [%expect {| 180 |}]; (* Ancestor. *) let is_ancestor ancestor descendant = print_s [%sexp { is_ancestor_or_equal = - (Vcs.Tree.is_ancestor_or_equal tree ~ancestor ~descendant : bool) + (Vcs.Graph.is_ancestor_or_equal graph ~ancestor ~descendant : bool) ; is_strict_ancestor = - (Vcs.Tree.is_strict_ancestor tree ~ancestor ~descendant : bool) + (Vcs.Graph.is_strict_ancestor graph ~ancestor ~descendant : bool) }] in is_ancestor tag_0_0_1 tag_0_0_2; @@ -268,10 +268,10 @@ let%expect_test "tree" = let root_node = Vcs.Rev.v "da46f0d60bfbb9dc9340e95f5625c10815c24af7" in let tip = Vcs.Rev.v "2e4fbeae154ec896262decf1ab3bee5687b93f21" in (* ref_kind. *) - let node_exn rev = Vcs.Tree.find_rev tree ~rev |> Option.value_exn ~here:[%here] in + let node_exn rev = Vcs.Graph.find_rev graph ~rev |> Option.value_exn ~here:[%here] in let ref_kind rev = let node = node_exn rev in - let line = Vcs.Tree.log_line tree node in + let line = Vcs.Graph.log_line graph node in print_s [%sexp (line : Vcs.Log.Line.t)] in ref_kind tip; @@ -293,7 +293,7 @@ let%expect_test "tree" = let parents rev = let node = node_exn rev in let parents = - Vcs.Tree.parents tree node |> List.map ~f:(fun node -> Vcs.Tree.rev tree node) + Vcs.Graph.parents graph node |> List.map ~f:(fun node -> Vcs.Graph.rev graph node) in print_s [%sexp (parents : Vcs.Rev.t list)] in @@ -310,7 +310,8 @@ let%expect_test "tree" = let test r1 r2 = print_s [%sexp - (Vcs.Tree.descendance tree (node_exn r1) (node_exn r2) : Vcs.Tree.Descendance.t)] + (Vcs.Graph.descendance graph (node_exn r1) (node_exn r2) + : Vcs.Graph.Descendance.t)] in test tip tip; [%expect {| Same_node |}]; @@ -329,8 +330,8 @@ let%expect_test "tree" = (* Additional tests to help covering corner cases. *) let%expect_test "empty summary" = - let tree = Vcs.Tree.create () in - print_s [%sexp (Vcs.Tree.summary tree : Vcs.Tree.Summary.t)]; + let graph = Vcs.Graph.create () in + print_s [%sexp (Vcs.Graph.summary graph : Vcs.Graph.Summary.t)]; [%expect {| ((refs ()) (roots ()) @@ -338,23 +339,23 @@ let%expect_test "empty summary" = () ;; -let%expect_test "Subtree.is_empty" = - let subtree = { Vcs.Tree.Subtree.log = []; refs = [] } in - print_s [%sexp (Vcs.Tree.Subtree.is_empty subtree : bool)]; +let%expect_test "Subgraph.is_empty" = + let subgraph = { Vcs.Graph.Subgraph.log = []; refs = [] } in + print_s [%sexp (Vcs.Graph.Subgraph.is_empty subgraph : bool)]; [%expect {| true |}]; - let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-tree" in - let subtree = - { Vcs.Tree.Subtree.log = [ Root { rev = Vcs.Mock_rev_gen.next mock_rev_gen } ] + let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-graph" in + let subgraph = + { Vcs.Graph.Subgraph.log = [ Root { rev = Vcs.Mock_rev_gen.next mock_rev_gen } ] ; refs = [] } in - print_s [%sexp (Vcs.Tree.Subtree.is_empty subtree : bool)]; + print_s [%sexp (Vcs.Graph.Subgraph.is_empty subgraph : bool)]; [%expect {| false |}]; () ;; let%expect_test "add_nodes" = - let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-tree" in + let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-graph" in let revs = Array.init 10 ~f:(fun _ -> Vcs.Mock_rev_gen.next mock_rev_gen) in let log = (* Contrary to [git] we prepare the log with the oldest commits first, as I @@ -366,9 +367,9 @@ let%expect_test "add_nodes" = Vcs.Log.Line.Commit { rev = revs.(i + 2); parent = revs.(i + 1) }) ] in - let tree = Vcs.Tree.create () in - Vcs.Tree.add_nodes tree ~log:(List.rev log); - print_s [%sexp (List.length (Vcs.Tree.log tree) : int)]; + let graph = Vcs.Graph.create () in + Vcs.Graph.add_nodes graph ~log:(List.rev log); + print_s [%sexp (List.length (Vcs.Graph.log graph) : int)]; [%expect {| 6 |}]; (* Adding log is idempotent. Only new nodes are effectively added. *) let log = @@ -377,38 +378,39 @@ let%expect_test "add_nodes" = ; [ Vcs.Log.Line.Merge { rev = revs.(6); parent1 = revs.(2); parent2 = revs.(5) } ] ] in - Vcs.Tree.add_nodes tree ~log:(List.rev log); - print_s [%sexp (List.length (Vcs.Tree.log tree) : int)]; + Vcs.Graph.add_nodes graph ~log:(List.rev log); + print_s [%sexp (List.length (Vcs.Graph.log graph) : int)]; [%expect {| 7 |}]; - (* This tree has a merge node (r.6) which present some corner cases for the + (* This graph has a merge node (r.6) which present some corner cases for the logic in [is_strict_ancestor] that are hard to cover otherwise. *) - let node_exn rev = Vcs.Tree.find_rev tree ~rev |> Option.value_exn ~here:[%here] in - print_s [%sexp (Vcs.Tree.log tree : Vcs.Log.t)]; + let node_exn rev = Vcs.Graph.find_rev graph ~rev |> Option.value_exn ~here:[%here] in + print_s [%sexp (Vcs.Graph.log graph : Vcs.Log.t)]; [%expect {| - ((Root (rev b4009f9c14eab4c931474f7647481517b4009f9c)) - (Root (rev 356b5838cce64758f4fa99b48c4a4552356b5838)) + ((Root (rev 5cd237e9598b11065c344d1eb33bc8c15cd237e9)) + (Root (rev f453b802f640c6888df978c712057d17f453b802)) (Commit - (rev 463eed936ec17915e6a76d135aecc4e0463eed93) - (parent 356b5838cce64758f4fa99b48c4a4552356b5838)) + (rev 5deb4aaec51a75ef58765038b7c20b3f5deb4aae) + (parent f453b802f640c6888df978c712057d17f453b802)) (Commit - (rev 08eb34026333c8825254e31ce2921cba08eb3402) - (parent 463eed936ec17915e6a76d135aecc4e0463eed93)) + (rev 9a81fba7a18f740120f1141b1ed109bb9a81fba7) + (parent 5deb4aaec51a75ef58765038b7c20b3f5deb4aae)) (Commit - (rev f610a31854ad58032204ab00120776e4f610a318) - (parent 08eb34026333c8825254e31ce2921cba08eb3402)) + (rev 7216231cd107946841cc3eebe5da287b7216231c) + (parent 9a81fba7a18f740120f1141b1ed109bb9a81fba7)) (Commit - (rev fec942a1014d1c42354c41583584c1a4fec942a1) - (parent f610a31854ad58032204ab00120776e4f610a318)) + (rev b155b82523d24ea82eb0ad45a5e89adcb155b825) + (parent 7216231cd107946841cc3eebe5da287b7216231c)) (Merge - (rev e47ca7129177810c1a02e01049eb3fd3e47ca712) - (parent1 463eed936ec17915e6a76d135aecc4e0463eed93) - (parent2 fec942a1014d1c42354c41583584c1a4fec942a1))) |}]; + (rev ed2a9ed9f5d7bee45156ba272651656ced2a9ed9) + (parent1 5deb4aaec51a75ef58765038b7c20b3f5deb4aae) + (parent2 b155b82523d24ea82eb0ad45a5e89adcb155b825))) + |}]; let is_strict_ancestor r1 r2 = print_s [%sexp - (Vcs.Tree.is_strict_ancestor - tree + (Vcs.Graph.is_strict_ancestor + graph ~ancestor:(node_exn r1) ~descendant:(node_exn r2) : bool)] @@ -423,62 +425,63 @@ let%expect_test "add_nodes" = ;; let%expect_test "set invalid rev" = - let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-tree" in + let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-graph" in let r1 = Vcs.Mock_rev_gen.next mock_rev_gen in - let tree = Vcs.Tree.create () in + let graph = Vcs.Graph.create () in let set_ref_r1 () = - Vcs.Tree.set_ref - tree + Vcs.Graph.set_ref + graph ~rev:r1 ~ref_kind:(Local_branch { branch_name = Vcs.Branch_name.v "main" }) in require_does_raise [%here] (fun () -> set_ref_r1 ()); - [%expect {| ("Rev not found" b4009f9c14eab4c931474f7647481517b4009f9c) |}]; - Vcs.Tree.add_nodes tree ~log:[ Root { rev = r1 } ]; + [%expect {| ("Rev not found" 5cd237e9598b11065c344d1eb33bc8c15cd237e9) |}]; + Vcs.Graph.add_nodes graph ~log:[ Root { rev = r1 } ]; set_ref_r1 (); - print_s [%sexp (Vcs.Tree.refs tree : Vcs.Refs.t)]; + print_s [%sexp (Vcs.Graph.refs graph : Vcs.Refs.t)]; [%expect {| (( - (rev b4009f9c14eab4c931474f7647481517b4009f9c) - (ref_kind (Local_branch (branch_name main))))) |}]; + (rev 5cd237e9598b11065c344d1eb33bc8c15cd237e9) + (ref_kind (Local_branch (branch_name main))))) + |}]; () ;; let%expect_test "greatest_common_ancestors" = - let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-tree" in + let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-graph" in let rev () = Vcs.Mock_rev_gen.next mock_rev_gen in - let tree = Vcs.Tree.create () in - let node ~rev = Vcs.Tree.find_rev tree ~rev |> Option.value_exn ~here:[%here] in + let graph = Vcs.Graph.create () in + let node ~rev = Vcs.Graph.find_rev graph ~rev |> Option.value_exn ~here:[%here] in let tag ~rev tag_name = - Vcs.Tree.set_ref tree ~rev ~ref_kind:(Tag { tag_name = Vcs.Tag_name.v tag_name }) + Vcs.Graph.set_ref graph ~rev ~ref_kind:(Tag { tag_name = Vcs.Tag_name.v tag_name }) in let root () = let rev = rev () in - Vcs.Tree.add_nodes tree ~log:[ Vcs.Log.Line.Root { rev } ]; + Vcs.Graph.add_nodes graph ~log:[ Vcs.Log.Line.Root { rev } ]; rev in let commit ~parent = let rev = rev () in - Vcs.Tree.add_nodes tree ~log:[ Vcs.Log.Line.Commit { rev; parent } ]; + Vcs.Graph.add_nodes graph ~log:[ Vcs.Log.Line.Commit { rev; parent } ]; rev in let merge ~parent1 ~parent2 = let rev = rev () in - Vcs.Tree.add_nodes tree ~log:[ Vcs.Log.Line.Merge { rev; parent1; parent2 } ]; + Vcs.Graph.add_nodes graph ~log:[ Vcs.Log.Line.Merge { rev; parent1; parent2 } ]; rev in let gcas revs = let gcas = - Vcs.Tree.greatest_common_ancestors tree (List.map revs ~f:(fun rev -> node ~rev)) + Vcs.Graph.greatest_common_ancestors graph (List.map revs ~f:(fun rev -> node ~rev)) |> List.map ~f:(fun node -> - match Vcs.Tree.node_refs tree node with + match Vcs.Graph.node_refs graph node with | ref :: _ -> Vcs.Ref_kind.to_string ref | [] -> (* This branch is kept for debug if it is executed by mistake but we shouldn't exercise this case since this makes the tests results harder to understand. *) - (Vcs.Tree.rev tree node |> Vcs.Rev.to_string) [@coverage off]) + (Vcs.Graph.rev graph node |> Vcs.Rev.to_string) [@coverage off]) in print_s [%sexp { gcas : string list }] in @@ -533,41 +536,41 @@ let%expect_test "greatest_common_ancestors" = ;; (* In this part of the test, we want to monitor that the interface exposed by - [Vcs.Tree] is sufficient to write some algorithm on git trees. As an example + [Vcs.Graph] is sufficient to write some algorithm on git graphs. As an example here, we are implementing from the user land a function that returns the set of nodes that are ancestors of a given node. *) -let ancestors tree node = +let ancestors graph node = let rec loop acc to_visit = match to_visit with | [] -> acc | node :: to_visit -> if Set.mem acc node then loop acc to_visit - else loop (Set.add acc node) (Vcs.Tree.prepend_parents tree node to_visit) + else loop (Set.add acc node) (Vcs.Graph.prepend_parents graph node to_visit) in - loop (Set.empty (module Vcs.Tree.Node)) [ node ] + loop (Set.empty (module Vcs.Graph.Node)) [ node ] ;; -let%expect_test "debug tree" = +let%expect_test "debug graph" = (* If needed, sexp_of_t should show helpful indices for nodes. *) - let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-tree" in + let mock_rev_gen = Vcs.Mock_rev_gen.create ~name:"test-graph" in let rev () = Vcs.Mock_rev_gen.next mock_rev_gen in - let tree = Vcs.Tree.create () in - let node ~rev = Vcs.Tree.find_rev tree ~rev |> Option.value_exn ~here:[%here] in + let graph = Vcs.Graph.create () in + let node ~rev = Vcs.Graph.find_rev graph ~rev |> Option.value_exn ~here:[%here] in let root () = let rev = rev () in - Vcs.Tree.add_nodes tree ~log:[ Vcs.Log.Line.Root { rev } ]; + Vcs.Graph.add_nodes graph ~log:[ Vcs.Log.Line.Root { rev } ]; rev in let commit ~parent = let rev = rev () in - Vcs.Tree.add_nodes tree ~log:[ Vcs.Log.Line.Commit { rev; parent } ]; + Vcs.Graph.add_nodes graph ~log:[ Vcs.Log.Line.Commit { rev; parent } ]; rev in let merge ~parent1 ~parent2 = let rev = rev () in - Vcs.Tree.add_nodes tree ~log:[ Vcs.Log.Line.Merge { rev; parent1; parent2 } ]; + Vcs.Graph.add_nodes graph ~log:[ Vcs.Log.Line.Merge { rev; parent1; parent2 } ]; rev in let r1 = root () in @@ -575,8 +578,8 @@ let%expect_test "debug tree" = let r3 = commit ~parent:r1 in let m1 = merge ~parent1:r2 ~parent2:r3 in let r4 = commit ~parent:m1 in - Vcs.Tree.set_refs - tree + Vcs.Graph.set_refs + graph ~refs: [ { rev = r2 ; ref_kind = @@ -585,34 +588,34 @@ let%expect_test "debug tree" = ; { rev = r4; ref_kind = Tag { tag_name = Vcs.Tag_name.v "0.1.0" } } ; { rev = r4; ref_kind = Local_branch { branch_name = Vcs.Branch_name.main } } ]; - print_s [%sexp (tree : Vcs.Tree.t)]; + print_s [%sexp (graph : Vcs.Graph.t)]; [%expect {| ((nodes ( (#4 ( Commit - (rev f610a31854ad58032204ab00120776e4f610a318) + (rev 7216231cd107946841cc3eebe5da287b7216231c) (parent #3))) (#3 ( Merge - (rev 08eb34026333c8825254e31ce2921cba08eb3402) + (rev 9a81fba7a18f740120f1141b1ed109bb9a81fba7) (parent1 #1) (parent2 #2))) (#2 ( Commit - (rev 463eed936ec17915e6a76d135aecc4e0463eed93) + (rev 5deb4aaec51a75ef58765038b7c20b3f5deb4aae) (parent #0))) (#1 ( Commit - (rev 356b5838cce64758f4fa99b48c4a4552356b5838) + (rev f453b802f640c6888df978c712057d17f453b802) (parent #0))) - (#0 (Root (rev b4009f9c14eab4c931474f7647481517b4009f9c))))) + (#0 (Root (rev 5cd237e9598b11065c344d1eb33bc8c15cd237e9))))) (revs ( - (#4 f610a31854ad58032204ab00120776e4f610a318) - (#3 08eb34026333c8825254e31ce2921cba08eb3402) - (#2 463eed936ec17915e6a76d135aecc4e0463eed93) - (#1 356b5838cce64758f4fa99b48c4a4552356b5838) - (#0 b4009f9c14eab4c931474f7647481517b4009f9c))) + (#4 7216231cd107946841cc3eebe5da287b7216231c) + (#3 9a81fba7a18f740120f1141b1ed109bb9a81fba7) + (#2 5deb4aaec51a75ef58765038b7c20b3f5deb4aae) + (#1 f453b802f640c6888df978c712057d17f453b802) + (#0 5cd237e9598b11065c344d1eb33bc8c15cd237e9))) (refs ( (#4 ( (Local_branch (branch_name main)) @@ -624,27 +627,27 @@ let%expect_test "debug tree" = (branch_name main))))))))) |}]; (* node_count *) - print_s [%sexp { node_count = (Vcs.Tree.node_count tree : int) }]; + print_s [%sexp { node_count = (Vcs.Graph.node_count graph : int) }]; [%expect {| ((node_count 5)) |}]; (* node_kind *) let node_kind rev = let node = node ~rev in - print_s [%sexp (Vcs.Tree.node_kind tree node : Vcs.Tree.Node_kind.t)] + print_s [%sexp (Vcs.Graph.node_kind graph node : Vcs.Graph.Node_kind.t)] in node_kind r1; - [%expect {| (Root (rev b4009f9c14eab4c931474f7647481517b4009f9c)) |}]; + [%expect {| (Root (rev 5cd237e9598b11065c344d1eb33bc8c15cd237e9)) |}]; node_kind r2; [%expect {| (Commit - (rev 356b5838cce64758f4fa99b48c4a4552356b5838) + (rev f453b802f640c6888df978c712057d17f453b802) (parent #0)) |}]; node_kind m1; [%expect {| (Merge - (rev 08eb34026333c8825254e31ce2921cba08eb3402) + (rev 9a81fba7a18f740120f1141b1ed109bb9a81fba7) (parent1 #1) (parent2 #2)) |}]; @@ -652,12 +655,12 @@ let%expect_test "debug tree" = [%expect {| (Commit - (rev f610a31854ad58032204ab00120776e4f610a318) + (rev 7216231cd107946841cc3eebe5da287b7216231c) (parent #3)) |}]; (* ancestors *) let print_ancestors rev = - print_s [%sexp (ancestors tree (node ~rev) : Set.M(Vcs.Tree.Node).t)] + print_s [%sexp (ancestors graph (node ~rev) : Set.M(Vcs.Graph.Node).t)] in print_ancestors r1; [%expect {| (#0) |}]; @@ -670,13 +673,13 @@ let%expect_test "debug tree" = print_ancestors r4; [%expect {| (#0 #1 #2 #3 #4) |}]; (* Low level int indexing. *) - let node_index node = print_s [%sexp (Vcs.Tree.node_index tree node : int)] in + let node_index node = print_s [%sexp (Vcs.Graph.node_index graph node : int)] in node_index (node ~rev:r1); [%expect {| 0 |}]; node_index (node ~rev:r4); [%expect {| 4 |}]; let get_node_exn index = - print_s [%sexp (Vcs.Tree.get_node_exn tree ~index : Vcs.Tree.Node.t)] + print_s [%sexp (Vcs.Graph.get_node_exn graph ~index : Vcs.Graph.Node.t)] in get_node_exn 0; [%expect {| #0 |}]; diff --git a/lib/vcs/test/test__tree.mli b/lib/vcs/test/test__graph.mli similarity index 100% rename from lib/vcs/test/test__tree.mli rename to lib/vcs/test/test__graph.mli diff --git a/lib/vcs_command/src/vcs_command.ml b/lib/vcs_command/src/vcs_command.ml index 2abc501..a8f76e0 100644 --- a/lib/vcs_command/src/vcs_command.ml +++ b/lib/vcs_command/src/vcs_command.ml @@ -291,17 +291,17 @@ let show_file_at_rev_cmd = ()) ;; -let tree_cmd = +let graph_cmd = Command.make - ~summary:"compute tree of current repo" + ~summary:"compute graph of current repo" (let%map_open.Command config = Vcs_arg.Config.arg in Eio_main.run @@ fun env -> let { Vcs_arg.Initialized.vcs; repo_root; context = _ } = Vcs_arg.initialize ~env ~config in - let tree = Vcs.tree vcs ~repo_root in - Eio_writer.print_sexp ~env [%sexp (Vcs.Tree.summary tree : Vcs.Tree.Summary.t)]; + let graph = Vcs.graph vcs ~repo_root in + Eio_writer.print_sexp ~env [%sexp (Vcs.Graph.summary graph : Vcs.Graph.Summary.t)]; ()) ;; @@ -349,16 +349,16 @@ let greatest_common_ancestors_cmd = let { Vcs_arg.Initialized.vcs; repo_root; context = _ } = Vcs_arg.initialize ~env ~config in - let tree = Vcs.tree vcs ~repo_root in + let graph = Vcs.graph vcs ~repo_root in let nodes = List.map revs ~f:(fun rev -> - match Vcs.Tree.find_rev tree ~rev with + match Vcs.Graph.find_rev graph ~rev with | Some node -> node | None -> Vcs.raise_s "Rev not found" [%sexp { rev : Vcs.Rev.t }]) in let gca = - Vcs.Tree.greatest_common_ancestors tree nodes - |> List.map ~f:(fun node -> Vcs.Tree.rev tree node) + Vcs.Graph.greatest_common_ancestors graph nodes + |> List.map ~f:(fun node -> Vcs.Graph.rev graph node) in Eio_writer.print_sexp ~env [%sexp (gca : Vcs.Rev.t list)]; ()) @@ -396,7 +396,7 @@ sub commands exposed here, plus additional functionality in [more-tests]. ; "save-file", save_file_cmd ; "set-user-config", set_user_config_cmd ; "show-file-at-rev", show_file_at_rev_cmd - ; "tree", tree_cmd + ; "graph", graph_cmd ; "more-tests", more_tests_cmd ] ;; diff --git a/test/cram/run.t b/test/cram/run.t index 146dc81..9c5f52e 100644 --- a/test/cram/run.t +++ b/test/cram/run.t @@ -126,9 +126,9 @@ Log. (parent $REV0)) (Root (rev $REV0))) -Tree. +Graph. - $ ocaml-vcs tree | stabilize_output + $ ocaml-vcs graph | stabilize_output ((refs (($REV2 refs/heads/main))) (roots ($REV0)) (tips (($REV2 (refs/heads/main))))) @@ -211,6 +211,9 @@ Vcs's help for review. git [OPTION]… [ARG]… run the git cli + graph [OPTION]… + compute graph of current repo + init [--quiet] [OPTION]… file initialize a new repository @@ -247,9 +250,6 @@ Vcs's help for review. show-file-at-rev [--rev=REV] [OPTION]… file show the contents of file at a given revision - tree [OPTION]… - compute tree of current repo - COMMON OPTIONS --help[=FMT] (default=auto) Show this help in format FMT. The value FMT must be one of auto, diff --git a/test/expect/find_ref.ml b/test/expect/find_ref.ml index 9ced064..9dae080 100644 --- a/test/expect/find_ref.ml +++ b/test/expect/find_ref.ml @@ -131,13 +131,13 @@ let%expect_test "find ref" = (tag1 dd5aabd331a75b90cd61725223964e47dd5aabd3) (tag2 f452a6f91ee8f448bd58bbd0f3330675f452a6f9)) |}]; - (* Next we do the same lookups, this time using [Vcs.Tree.find_ref], and + (* Next we do the same lookups, this time using [Vcs.Graph.find_ref], and verify that we find the same results. *) - let tree = Vcs.tree vcs ~repo_root in + let graph = Vcs.graph vcs ~repo_root in let sexp2 = let find_exn ref_kind = - match Vcs.Tree.find_ref tree ~ref_kind with - | Some node -> Vcs.Mock_revs.to_mock mock_revs ~rev:(Vcs.Tree.rev tree node) + match Vcs.Graph.find_ref graph ~ref_kind with + | Some node -> Vcs.Mock_revs.to_mock mock_revs ~rev:(Vcs.Graph.rev graph node) | None -> assert false in lookup ~find_exn @@ -154,7 +154,7 @@ let%expect_test "find ref" = This is the reason why we ended up removing [rev_parse] from the vcs api, and replaced it with the 2 technics shown above: - 1. [Vcs.Tree.find_ref] and + 1. [Vcs.Graph.find_ref] and 2. [Vcs.refs |> Vcs.Refs.to_map]. *) let ambiguous_rev = Vcs.git diff --git a/test/expect/nonraising_unit_tests.ml b/test/expect/nonraising_unit_tests.ml index 1111a6e..2784115 100644 --- a/test/expect/nonraising_unit_tests.ml +++ b/test/expect/nonraising_unit_tests.ml @@ -252,9 +252,9 @@ let%expect_test "num stat without lines" = in [%expect {| (((rev rev3) (ref_kind (Local_branch (branch_name main))))) |}]; let () = - match Vcs.Or_error.tree vcs ~repo_root with + match Vcs.Or_error.graph vcs ~repo_root with | Error _ -> assert false - | Ok tree -> print_s (map_sexp [%sexp (tree : Vcs.Tree.t)]) + | Ok graph -> print_s (map_sexp [%sexp (graph : Vcs.Graph.t)]) in [%expect {|