Ejemplo n.º 1
0
svn_error_t *
svn_wc__serialize_conflict(svn_skel_t **skel,
                           const svn_wc_conflict_description2_t *conflict,
                           apr_pool_t *result_pool,
                           apr_pool_t *scratch_pool)
{
  /* A conflict version struct with all fields null/invalid. */
  static const svn_wc_conflict_version_t null_version = {
    NULL, SVN_INVALID_REVNUM, NULL, svn_node_unknown };
  svn_skel_t *c_skel = svn_skel__make_empty_list(result_pool);
  const char *victim_basename;

  /* src_right_version */
  if (conflict->src_right_version)
    SVN_ERR(prepend_version_info_skel(c_skel, conflict->src_right_version,
                                      result_pool));
  else
    SVN_ERR(prepend_version_info_skel(c_skel, &null_version, result_pool));

  /* src_left_version */
  if (conflict->src_left_version)
    SVN_ERR(prepend_version_info_skel(c_skel, conflict->src_left_version,
                                      result_pool));
  else
    SVN_ERR(prepend_version_info_skel(c_skel, &null_version, result_pool));

  /* local change */
  skel_prepend_enum(c_skel, svn_wc__conflict_reason_map,
                    conflict->reason, result_pool);

  /* incoming change */
  skel_prepend_enum(c_skel, svn_wc__conflict_action_map,
                    conflict->action, result_pool);

  /* operation */
  skel_prepend_enum(c_skel, svn_wc__operation_map, conflict->operation,
                    result_pool);

  /* node_kind */
  SVN_ERR_ASSERT(conflict->node_kind == svn_node_dir
                 || conflict->node_kind == svn_node_file
                 || conflict->node_kind == svn_node_none);
  skel_prepend_enum(c_skel, node_kind_map, conflict->node_kind,
                    result_pool);

  /* Victim path (escaping separator chars). */
  victim_basename = svn_dirent_basename(conflict->local_abspath, result_pool);
  SVN_ERR_ASSERT(victim_basename[0]);
  svn_skel__prepend(svn_skel__str_atom(victim_basename, result_pool), c_skel);

  svn_skel__prepend(svn_skel__str_atom("conflict", result_pool), c_skel);

  SVN_ERR_ASSERT(is_valid_conflict_skel(c_skel));

  *skel = c_skel;

  return SVN_NO_ERROR;
}
Ejemplo n.º 2
0
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;
}