data tree FEATURE implement LYD_DUP_WITH_FLAGS
diff --git a/src/tree_data.c b/src/tree_data.c
index 01a4a33..7ec7004 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1980,8 +1980,11 @@
}
LY_CHECK_ERR_GOTO(!dup, LOGMEM(LYD_NODE_CTX(node)); ret = LY_EMEM, error);
- /* TODO implement LYD_DUP_WITH_WHEN */
- dup->flags = node->flags;
+ if (options & LYD_DUP_WITH_FLAGS) {
+ dup->flags = node->flags;
+ } else {
+ dup->flags = (node->flags & LYD_DEFAULT) | LYD_NEW;
+ }
dup->schema = node->schema;
dup->prev = dup;
diff --git a/src/tree_data.h b/src/tree_data.h
index ade5b7c..8e021d6 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -1023,18 +1023,14 @@
#define LYD_DUP_WITH_PARENTS 0x04 /**< If a nested node is being duplicated, duplicate also all the parents.
Keys are also duplicated for lists. Return value does not change! */
#define LYD_DUP_WITH_SIBLINGS 0x08 /**< Duplicate also all the sibling of the given node. */
-#define LYD_DUP_WITH_WHEN 0x10 /**< Also copy any when evaluation state flags. This is useful in case the copied
- nodes are actually still part of the same datastore meaning no dependency data
- could have changed. Otherwise nothing is assumed about the copied node when
- state and it is evaluated from scratch during validation. */
+#define LYD_DUP_WITH_FLAGS 0x10 /**< Also copy any data node flags. That will cause the duplicated data to preserve
+ its validation/default node state. */
/** @} dupoptions */
/**
* @brief Create a copy of the specified data tree \p node. Schema references are kept the same.
*
- * __PARTIAL CHANGE__ - validate after the final change on the data tree (see @ref howtodatamanipulators).
- *
* @param[in] node Data tree node to be duplicated.
* @param[in] parent Optional parent node where to connect the duplicated node(s).
* If set in combination with LYD_DUP_WITH_PARENTS, the parents chain is duplicated until it comes to and connect with the @p parent