svn_client_status_t * svn_client_status_dup(const svn_client_status_t *status, apr_pool_t *result_pool) { svn_client_status_t *st = apr_palloc(result_pool, sizeof(*st)); *st = *status; if (status->local_abspath) st->local_abspath = apr_pstrdup(result_pool, status->local_abspath); if (status->repos_root_url) st->repos_root_url = apr_pstrdup(result_pool, status->repos_root_url); if (status->repos_uuid) st->repos_uuid = apr_pstrdup(result_pool, status->repos_uuid); if (status->repos_relpath) st->repos_relpath = apr_pstrdup(result_pool, status->repos_relpath); if (status->changed_author) st->changed_author = apr_pstrdup(result_pool, status->changed_author); if (status->lock) st->lock = svn_lock_dup(status->lock, result_pool); if (status->changelist) st->changelist = apr_pstrdup(result_pool, status->changelist); if (status->ood_changed_author) st->ood_changed_author = apr_pstrdup(result_pool, status->ood_changed_author); if (status->repos_lock) st->repos_lock = svn_lock_dup(status->repos_lock, result_pool); if (status->backwards_compatibility_baton) { const svn_wc_status3_t *wc_st = status->backwards_compatibility_baton; st->backwards_compatibility_baton = svn_wc_dup_status3(wc_st, result_pool); } if (status->moved_from_abspath) st->moved_from_abspath = apr_pstrdup(result_pool, status->moved_from_abspath); if (status->moved_to_abspath) st->moved_to_abspath = apr_pstrdup(result_pool, status->moved_to_abspath); return st; }
svn_info_t * svn_info_dup(const svn_info_t *info, apr_pool_t *pool) { svn_info_t *dupinfo = apr_palloc(pool, sizeof(*dupinfo)); /* Perform a trivial copy ... */ *dupinfo = *info; /* ...and then re-copy stuff that needs to be duped into our pool. */ if (info->URL) dupinfo->URL = apr_pstrdup(pool, info->URL); if (info->repos_root_URL) dupinfo->repos_root_URL = apr_pstrdup(pool, info->repos_root_URL); if (info->repos_UUID) dupinfo->repos_UUID = apr_pstrdup(pool, info->repos_UUID); if (info->last_changed_author) dupinfo->last_changed_author = apr_pstrdup(pool, info->last_changed_author); if (info->lock) dupinfo->lock = svn_lock_dup(info->lock, pool); if (info->copyfrom_url) dupinfo->copyfrom_url = apr_pstrdup(pool, info->copyfrom_url); if (info->checksum) dupinfo->checksum = apr_pstrdup(pool, info->checksum); if (info->conflict_old) dupinfo->conflict_old = apr_pstrdup(pool, info->conflict_old); if (info->conflict_new) dupinfo->conflict_new = apr_pstrdup(pool, info->conflict_new); if (info->conflict_wrk) dupinfo->conflict_wrk = apr_pstrdup(pool, info->conflict_wrk); if (info->prejfile) dupinfo->prejfile = apr_pstrdup(pool, info->prejfile); return dupinfo; }
svn_wc_notify_t * svn_wc_dup_notify(const svn_wc_notify_t *notify, apr_pool_t *pool) { svn_wc_notify_t *ret = apr_palloc(pool, sizeof(*ret)); *ret = *notify; if (ret->path) ret->path = apr_pstrdup(pool, ret->path); if (ret->mime_type) ret->mime_type = apr_pstrdup(pool, ret->mime_type); if (ret->lock) ret->lock = svn_lock_dup(ret->lock, pool); if (ret->err) { ret->err = svn_error_dup(ret->err); apr_pool_cleanup_register(pool, ret->err, err_cleanup, apr_pool_cleanup_null); } if (ret->changelist_name) ret->changelist_name = apr_pstrdup(pool, ret->changelist_name); if (ret->merge_range) ret->merge_range = svn_merge_range_dup(ret->merge_range, pool); if (ret->url) ret->url = apr_pstrdup(pool, ret->url); if (ret->path_prefix) ret->path_prefix = apr_pstrdup(pool, ret->path_prefix); if (ret->prop_name) ret->prop_name = apr_pstrdup(pool, ret->prop_name); if (ret->rev_props) ret->rev_props = svn_prop_hash_dup(ret->rev_props, pool); return ret; }
svn_client_info2_t * svn_client_info2_dup(const svn_client_info2_t *info, apr_pool_t *pool) { svn_client_info2_t *new_info = apr_pmemdup(pool, info, sizeof(*new_info)); if (new_info->URL) new_info->URL = apr_pstrdup(pool, info->URL); if (new_info->repos_root_URL) new_info->repos_root_URL = apr_pstrdup(pool, info->repos_root_URL); if (new_info->repos_UUID) new_info->repos_UUID = apr_pstrdup(pool, info->repos_UUID); if (info->last_changed_author) new_info->last_changed_author = apr_pstrdup(pool, info->last_changed_author); if (new_info->lock) new_info->lock = svn_lock_dup(info->lock, pool); if (new_info->wc_info) new_info->wc_info = svn_wc_info_dup(info->wc_info, pool); return new_info; }
/* This implements the svn_fs_get_locks_callback_t interface. */ static svn_error_t * get_locks_callback(void *baton, svn_lock_t *lock, apr_pool_t *pool) { struct get_locks_baton_t *b = baton; svn_boolean_t readable = TRUE; apr_pool_t *hash_pool = apr_hash_pool_get(b->locks); /* If there's auth to deal with, deal with it. */ if (b->authz_read_func) SVN_ERR(b->authz_read_func(&readable, b->head_root, lock->path, b->authz_read_baton, pool)); /* If we can read this lock path, add the lock to the return hash. */ if (readable) svn_hash_sets(b->locks, apr_pstrdup(hash_pool, lock->path), svn_lock_dup(lock, hash_pool)); return SVN_NO_ERROR; }
/* Conforms to svn_ra_serf__xml_closed_t */ static svn_error_t * getlocks_closed(svn_ra_serf__xml_estate_t *xes, void *baton, int leaving_state, const svn_string_t *cdata, apr_hash_t *attrs, apr_pool_t *scratch_pool) { lock_context_t *lock_ctx = baton; if (leaving_state == LOCK) { const char *path = svn_hash_gets(attrs, "path"); svn_boolean_t save_lock = FALSE; /* Filter out unwanted paths. Since Subversion only allows locks on files, we can treat depth=immediates the same as depth=files for filtering purposes. Meaning, we'll keep this lock if: a) its path is the very path we queried, or b) we've asked for a fully recursive answer, or c) we've asked for depth=files or depth=immediates, and this lock is on an immediate child of our query path. */ if (strcmp(lock_ctx->path, path) == 0 || lock_ctx->requested_depth == svn_depth_infinity) { save_lock = TRUE; } else if (lock_ctx->requested_depth == svn_depth_files || lock_ctx->requested_depth == svn_depth_immediates) { const char *relpath = svn_fspath__skip_ancestor(lock_ctx->path, path); if (relpath && (svn_path_component_count(relpath) == 1)) save_lock = TRUE; } if (save_lock) { /* We get to put the structure on the stack rather than using svn_lock_create(). Bwahahaha.... */ svn_lock_t lock = { 0 }; const char *date; svn_lock_t *result_lock; /* Note: these "attributes" came from child elements. Some of them may have not been sent, so the value will be NULL. */ lock.path = path; lock.token = svn_hash_gets(attrs, "token"); lock.owner = svn_hash_gets(attrs, "owner"); lock.comment = svn_hash_gets(attrs, "comment"); date = svn_hash_gets(attrs, SVN_DAV__CREATIONDATE); if (date) SVN_ERR(svn_time_from_cstring(&lock.creation_date, date, scratch_pool)); date = svn_hash_gets(attrs, "expirationdate"); if (date) SVN_ERR(svn_time_from_cstring(&lock.expiration_date, date, scratch_pool)); result_lock = svn_lock_dup(&lock, lock_ctx->pool); svn_hash_sets(lock_ctx->hash, result_lock->path, result_lock); } } else { const char *name; SVN_ERR_ASSERT(cdata != NULL); if (leaving_state == PATH) name = "path"; else if (leaving_state == TOKEN) name = "token"; else if (leaving_state == OWNER) name = "owner"; else if (leaving_state == COMMENT) name = "comment"; else if (leaving_state == CREATION_DATE) name = SVN_DAV__CREATIONDATE; else if (leaving_state == EXPIRATION_DATE) name = "expirationdate"; else SVN_ERR_MALFUNCTION(); /* Store the lock information onto the LOCK elemstate. */ svn_ra_serf__xml_note(xes, LOCK, name, cdata->data); } return SVN_NO_ERROR; }
svn_error_t * svn_wc__status2_from_3(svn_wc_status2_t **status, const svn_wc_status3_t *old_status, svn_wc_context_t *wc_ctx, const char *local_abspath, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { const svn_wc_entry_t *entry = NULL; if (old_status == NULL) { *status = NULL; return SVN_NO_ERROR; } *status = apr_pcalloc(result_pool, sizeof(**status)); if (old_status->versioned) { svn_error_t *err; err= svn_wc__get_entry(&entry, wc_ctx->db, local_abspath, FALSE, svn_node_unknown, result_pool, scratch_pool); if (err && err->apr_err == SVN_ERR_NODE_UNEXPECTED_KIND) svn_error_clear(err); else SVN_ERR(err); } (*status)->entry = entry; (*status)->copied = old_status->copied; (*status)->repos_lock = svn_lock_dup(old_status->repos_lock, result_pool); if (old_status->repos_relpath) (*status)->url = svn_path_url_add_component2(old_status->repos_root_url, old_status->repos_relpath, result_pool); (*status)->ood_last_cmt_rev = old_status->ood_changed_rev; (*status)->ood_last_cmt_date = old_status->ood_changed_date; (*status)->ood_kind = old_status->ood_kind; (*status)->ood_last_cmt_author = old_status->ood_changed_author; if (old_status->conflicted) { const svn_wc_conflict_description2_t *tree_conflict; SVN_ERR(svn_wc__get_tree_conflict(&tree_conflict, wc_ctx, local_abspath, scratch_pool, scratch_pool)); (*status)->tree_conflict = svn_wc__cd2_to_cd(tree_conflict, result_pool); } (*status)->switched = old_status->switched; (*status)->text_status = old_status->node_status; (*status)->prop_status = old_status->prop_status; (*status)->repos_text_status = old_status->repos_node_status; (*status)->repos_prop_status = old_status->repos_prop_status; /* Some values might be inherited from properties */ if (old_status->node_status == svn_wc_status_modified || old_status->node_status == svn_wc_status_conflicted) (*status)->text_status = old_status->text_status; /* (Currently a no-op, but just make sure it is ok) */ if (old_status->repos_node_status == svn_wc_status_modified || old_status->repos_node_status == svn_wc_status_conflicted) (*status)->text_status = old_status->repos_text_status; if (old_status->node_status == svn_wc_status_added) (*status)->prop_status = svn_wc_status_none; /* No separate info */ /* Find pristine_text_status value */ switch (old_status->text_status) { case svn_wc_status_none: case svn_wc_status_normal: case svn_wc_status_modified: (*status)->pristine_text_status = old_status->text_status; break; case svn_wc_status_conflicted: default: /* ### Fetch compare data, or fall back to the documented not retrieved behavior? */ (*status)->pristine_text_status = svn_wc_status_none; break; } /* Find pristine_prop_status value */ switch (old_status->prop_status) { case svn_wc_status_none: case svn_wc_status_normal: case svn_wc_status_modified: if (old_status->node_status != svn_wc_status_added && old_status->node_status != svn_wc_status_deleted && old_status->node_status != svn_wc_status_replaced) { (*status)->pristine_prop_status = old_status->prop_status; } else (*status)->pristine_prop_status = svn_wc_status_none; break; case svn_wc_status_conflicted: default: /* ### Fetch compare data, or fall back to the documented not retrieved behavior? */ (*status)->pristine_prop_status = svn_wc_status_none; break; } if (old_status->versioned && old_status->conflicted && old_status->node_status != svn_wc_status_obstructed && (old_status->kind == svn_node_file || old_status->node_status != svn_wc_status_missing)) { svn_boolean_t text_conflict_p, prop_conflict_p; /* The entry says there was a conflict, but the user might have marked it as resolved by deleting the artifact files, so check for that. */ SVN_ERR(svn_wc__internal_conflicted_p(&text_conflict_p, &prop_conflict_p, NULL, wc_ctx->db, local_abspath, scratch_pool)); if (text_conflict_p) (*status)->text_status = svn_wc_status_conflicted; if (prop_conflict_p) (*status)->prop_status = svn_wc_status_conflicted; } return SVN_NO_ERROR; }