From 52b0ff3942ce984a0b65e73b109fe05837323efb Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Fri, 12 Dec 2025 20:19:16 -0600 Subject: T8061: simplify allowed_edit_node with path_type --- src/reference_tree.ml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/reference_tree.ml') diff --git a/src/reference_tree.ml b/src/reference_tree.ml index 82604f4..c78529e 100644 --- a/src/reference_tree.ml +++ b/src/reference_tree.ml @@ -742,30 +742,21 @@ let get_path_type_str ?(legacy_format=false) rtree cpath = assuming that it is (1) a valid path of the reference tree (2) neither a tag nor leaf node - To confirm (2) in the case of a tag node, one has to allow for a - 'potential' tag value as final element of the path. *) let allowed_edit_level rtree path = if Util.is_empty path then Error {|The "edit" command cannot be issued at an empty path|} else - let refp = refpath rtree path - in - if Util.is_empty refp then + match get_path_type rtree path with + | `Invalid -> Error {|The "edit" command cannot be issued at a non-existent path of the reference tree|} - else - if is_tag rtree refp && not (potential_tag_value rtree path) - then + | `Tag -> Error {|The "edit" command cannot be issued at the level of tag node|} - else - if potential_leaf_value rtree path - then - Error {|The "edit" command cannot be issued at the level of leaf value|} - else - if is_leaf rtree refp - then + | `Leaf -> Error {|The "edit" command cannot be issued at the level of leaf node|} - else Ok () + | `Leaf_value -> + Error {|The "edit" command cannot be issued at the level of leaf value|} + | _ -> Ok () let get_ceil_data f reftree path = (* raises: -- cgit v1.2.3