/* Parse the conflict info fields from SKEL into *VERSION_INFO. */ static svn_error_t * read_node_version_info(const svn_wc_conflict_version_t **version_info, const svn_skel_t *skel, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { int n; const char *repos_root; const char *repos_relpath; svn_revnum_t peg_rev; svn_node_kind_t kind; if (!is_valid_version_info_skel(skel)) return svn_error_create(SVN_ERR_WC_CORRUPT, NULL, _("Invalid version info in tree conflict " "description")); repos_root = apr_pstrmemdup(scratch_pool, skel->children->next->data, skel->children->next->len); if (*repos_root == '\0') { *version_info = NULL; return SVN_NO_ERROR; } /* Apply the Subversion 1.7+ url canonicalization rules to a pre 1.7 url */ repos_root = svn_uri_canonicalize(repos_root, result_pool); peg_rev = SVN_STR_TO_REV(apr_pstrmemdup(scratch_pool, skel->children->next->next->data, skel->children->next->next->len)); repos_relpath = apr_pstrmemdup(result_pool, skel->children->next->next->next->data, skel->children->next->next->next->len); SVN_ERR(read_enum_field(&n, node_kind_map, skel->children->next->next->next->next)); kind = (svn_node_kind_t)n; *version_info = svn_wc_conflict_version_create2(repos_root, NULL, repos_relpath, peg_rev, kind, result_pool); return SVN_NO_ERROR; }
static svn_error_t * raise_tree_conflict(int argc, const char **argv, apr_pool_t *pool) { int i = 0; svn_wc_conflict_version_t *left, *right; svn_wc_conflict_description2_t *c; svn_wc_context_t *wc_ctx; /* Conflict description parameters */ const char *wc_path, *wc_abspath; const char *repos_url1, *repos_url2, *path_in_repos1, *path_in_repos2; int operation, action, reason; long peg_rev1, peg_rev2; int kind, kind1, kind2; if (argc != 13) return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL, "Wrong number of arguments"); /* Read the parameters */ wc_path = svn_dirent_internal_style(argv[i++], pool); SVN_ERR(read_enum_field(&kind, node_kind_map, argv[i++], pool)); SVN_ERR(read_enum_field(&operation, operation_map, argv[i++], pool)); SVN_ERR(read_enum_field(&action, action_map, argv[i++], pool)); SVN_ERR(read_enum_field(&reason, reason_map, argv[i++], pool)); repos_url1 = argv[i++]; path_in_repos1 = argv[i++]; peg_rev1 = atol(argv[i++]); SVN_ERR(read_enum_field(&kind1, node_kind_map, argv[i++], pool)); repos_url2 = argv[i++]; path_in_repos2 = argv[i++]; peg_rev2 = atol(argv[i++]); SVN_ERR(read_enum_field(&kind2, node_kind_map, argv[i++], pool)); /* Allocate and fill in the description data structures */ SVN_ERR(svn_dirent_get_absolute(&wc_abspath, wc_path, pool)); left = svn_wc_conflict_version_create2(repos_url1, NULL, path_in_repos1, peg_rev1, kind1, pool); right = svn_wc_conflict_version_create2(repos_url2, NULL, path_in_repos2, peg_rev2, kind2, pool); c = svn_wc_conflict_description_create_tree2(wc_abspath, kind, operation, left, right, pool); c->action = (svn_wc_conflict_action_t)action; c->reason = (svn_wc_conflict_reason_t)reason; /* Raise the conflict */ SVN_ERR(svn_wc_context_create(&wc_ctx, NULL, pool, pool)); SVN_ERR(svn_wc__add_tree_conflict(wc_ctx, c, pool)); return SVN_NO_ERROR; }
svn_error_t * svn_wc__deserialize_conflict(const svn_wc_conflict_description2_t **conflict, const svn_skel_t *skel, const char *dir_path, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { const char *victim_basename; const char *victim_abspath; svn_node_kind_t node_kind; svn_wc_operation_t operation; svn_wc_conflict_action_t action; svn_wc_conflict_reason_t reason; const svn_wc_conflict_version_t *src_left_version; const svn_wc_conflict_version_t *src_right_version; int n; svn_wc_conflict_description2_t *new_conflict; if (!is_valid_conflict_skel(skel)) return svn_error_createf(SVN_ERR_WC_CORRUPT, NULL, _("Invalid conflict info '%s' in tree conflict " "description"), skel ? svn_skel__unparse(skel, scratch_pool)->data : "(null)"); /* victim basename */ victim_basename = apr_pstrmemdup(scratch_pool, skel->children->next->data, skel->children->next->len); if (victim_basename[0] == '\0') return svn_error_create(SVN_ERR_WC_CORRUPT, NULL, _("Empty 'victim' field in tree conflict " "description")); /* node_kind */ SVN_ERR(read_enum_field(&n, node_kind_map, skel->children->next->next)); node_kind = (svn_node_kind_t)n; if (node_kind != svn_node_file && node_kind != svn_node_dir) return svn_error_create(SVN_ERR_WC_CORRUPT, NULL, _("Invalid 'node_kind' field in tree conflict description")); /* operation */ SVN_ERR(read_enum_field(&n, svn_wc__operation_map, skel->children->next->next->next)); operation = (svn_wc_operation_t)n; SVN_ERR(svn_dirent_get_absolute(&victim_abspath, svn_dirent_join(dir_path, victim_basename, scratch_pool), scratch_pool)); /* action */ SVN_ERR(read_enum_field(&n, svn_wc__conflict_action_map, skel->children->next->next->next->next)); action = n; /* reason */ SVN_ERR(read_enum_field(&n, svn_wc__conflict_reason_map, skel->children->next->next->next->next->next)); reason = n; /* Let's just make it a bit easier on ourself here... */ skel = skel->children->next->next->next->next->next->next; /* src_left_version */ SVN_ERR(read_node_version_info(&src_left_version, skel, result_pool, scratch_pool)); /* src_right_version */ SVN_ERR(read_node_version_info(&src_right_version, skel->next, result_pool, scratch_pool)); new_conflict = svn_wc_conflict_description_create_tree2(victim_abspath, node_kind, operation, src_left_version, src_right_version, result_pool); new_conflict->action = action; new_conflict->reason = reason; *conflict = new_conflict; return SVN_NO_ERROR; }