@@ -144,6 +144,8 @@ schema_diff_changed2str(enum lys_diff_changed_e ch)
144144 return "unique" ;
145145 case LYS_CHANGED_WHEN :
146146 return "when" ;
147+ case LYS_CHANGED_YANG_VERSION :
148+ return "yang-version" ;
147149 }
148150
149151 return NULL ;
@@ -1555,6 +1557,53 @@ schema_diff_imports(const struct lys_module *mod, const struct lysc_node *schema
15551557 return rc ;
15561558}
15571559
1560+ /**
1561+ * @brief Create cmp YANG data from direct text substatement of 'module'.
1562+ *
1563+ * @param[in] change Change to use.
1564+ * @param[in] mod1 Old module.
1565+ * @param[in] mod2 New module.
1566+ * @param[in] with_parsed Whether 'parsed-schema' feature is enabled.
1567+ * @param[in,out] diff_list Node to append to.
1568+ * @return LY_ERR value.
1569+ */
1570+ static LY_ERR
1571+ schema_diff_module_version (const struct lys_diff_change_s * change , const struct lys_module * mod1 ,
1572+ const struct lys_module * mod2 , struct lyd_node * diff_list )
1573+ {
1574+ LY_ERR rc = LY_SUCCESS ;
1575+ struct lyd_node * mod_cmp_list , * cont ;
1576+ const char * node_name ;
1577+
1578+ /* The only change handled. */
1579+ if (change -> changed != LYS_CHANGED_YANG_VERSION ) {
1580+ goto cleanup ;
1581+ }
1582+
1583+ node_name = "yang-version" ;
1584+
1585+ /* module comparison */
1586+ LY_CHECK_GOTO (rc = lyd_new_list (diff_list , NULL , "module-comparison" , 0 , & mod_cmp_list ), cleanup );
1587+
1588+ /* change info */
1589+ LY_CHECK_GOTO (rc = schema_diff_change_info (change , mod_cmp_list ), cleanup );
1590+
1591+ if (mod1 -> version ) {
1592+ LY_CHECK_GOTO (rc = lyd_new_inner (mod_cmp_list , NULL , "old" , 0 , & cont ), cleanup );
1593+ LY_CHECK_GOTO (rc = lyd_new_term (cont , NULL , node_name ,
1594+ mod1 -> version == LYS_VERSION_1_1 ? "1.1" : "1" , 0 , NULL ), cleanup );
1595+ }
1596+
1597+ if (mod2 -> version ) {
1598+ LY_CHECK_GOTO (rc = lyd_new_inner (mod_cmp_list , NULL , "new" , 0 , & cont ), cleanup );
1599+ LY_CHECK_GOTO (rc = lyd_new_term (cont , NULL , node_name ,
1600+ mod2 -> version == LYS_VERSION_1_1 ? "1.1" : "1" , 0 , NULL ), cleanup );
1601+ }
1602+
1603+ cleanup :
1604+ return rc ;
1605+ }
1606+
15581607/**
15591608 * @brief Create cmp YANG data from direct text substatement of 'module'.
15601609 *
@@ -1605,6 +1654,9 @@ schema_diff_module_text(const struct lys_diff_change_s *change, const struct lys
16051654 text_old = mod1 -> ref ;
16061655 text_new = mod2 -> ref ;
16071656 break ;
1657+ case LYS_CHANGED_YANG_VERSION :
1658+ /* not a textual field, ignore */
1659+ goto cleanup ;
16081660 default :
16091661 LOGINT (mod1 -> ctx );
16101662 rc = LY_EINT ;
@@ -3024,6 +3076,12 @@ schema_diff_module(const struct lys_diff_s *diff, const struct lys_module *mod1,
30243076 LY_ERR rc = LY_SUCCESS ;
30253077 uint32_t i ;
30263078
3079+ /* yang-version */
3080+ for (i = 0 ; i < diff -> module_changes .count ; ++ i ) {
3081+ LY_CHECK_GOTO (rc = schema_diff_module_version (& diff -> module_changes .changes [i ], mod1 , mod2 , diff_list ),
3082+ cleanup );
3083+ }
3084+
30273085 /* text substmts */
30283086 for (i = 0 ; i < diff -> module_changes .count ; ++ i ) {
30293087 LY_CHECK_GOTO (rc = schema_diff_module_text (& diff -> module_changes .changes [i ], mod1 , mod2 , diff -> with_parsed ,
0 commit comments