You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2012/04/23 14:33:03 UTC
svn commit: r1329209 [7/38] - in /subversion/branches/javahl-ra: ./ build/
build/ac-macros/ build/generator/ build/generator/templates/ build/win32/
contrib/client-side/emacs/ contrib/client-side/vim/
contrib/server-side/mod_dontdothat/ notes/ notes/ap...
Modified: subversion/branches/javahl-ra/subversion/libsvn_client/copy.c
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_client/copy.c?rev=1329209&r1=1329208&r2=1329209&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_client/copy.c (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_client/copy.c Mon Apr 23 12:32:48 2012
@@ -44,7 +44,9 @@
#include "svn_private_config.h"
#include "private/svn_wc_private.h"
+#include "private/svn_ra_private.h"
#include "private/svn_mergeinfo_private.h"
+#include "private/svn_client_private.h"
/*
@@ -68,71 +70,6 @@
/*** Code. ***/
-/* Obtain the implied mergeinfo and the existing mergeinfo of the
- source path, combine them and return the result in
- *TARGET_MERGEINFO. One of LOCAL_ABSPATH and SRC_URL must be valid,
- the other must be NULL. */
-static svn_error_t *
-calculate_target_mergeinfo(svn_ra_session_t *ra_session,
- apr_hash_t **target_mergeinfo,
- const char *local_abspath,
- const char *src_url,
- svn_revnum_t src_revnum,
- svn_client_ctx_t *ctx,
- apr_pool_t *pool)
-{
- svn_boolean_t locally_added = FALSE;
- apr_hash_t *src_mergeinfo = NULL;
-
- SVN_ERR_ASSERT((local_abspath && !src_url) || (!local_abspath && src_url));
-
- /* If we have a schedule-add WC path (which was not copied from
- elsewhere), it doesn't have any repository mergeinfo, so don't
- bother checking. */
- if (local_abspath)
- {
- const char *repos_root_url;
- const char *repos_relpath;
-
- SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
-
- SVN_ERR(svn_wc__node_get_origin(NULL, &src_revnum,
- &repos_relpath, &repos_root_url,
- NULL,
- ctx->wc_ctx, local_abspath, FALSE,
- pool, pool));
-
- if (repos_relpath)
- {
- src_url = svn_path_url_add_component2(repos_root_url, repos_relpath,
- pool);
- }
- else
- locally_added = TRUE;
- }
-
- if (! locally_added)
- {
- /* Fetch any existing (explicit) mergeinfo. We'll temporarily
- reparent to the target URL here, just to keep the code simple.
- We could, as an alternative, first see if the target URL was a
- child of the session URL and use the relative "remainder",
- falling back to this reparenting as necessary. */
- const char *old_session_url = NULL;
- SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url,
- ra_session, src_url, pool));
- SVN_ERR(svn_client__get_repos_mergeinfo(&src_mergeinfo, ra_session,
- "", src_revnum,
- svn_mergeinfo_inherited,
- TRUE, pool));
- if (old_session_url)
- SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
- }
-
- *target_mergeinfo = src_mergeinfo;
- return SVN_NO_ERROR;
-}
-
/* Extend the mergeinfo for the single WC path TARGET_WCPATH, adding
MERGEINFO to any mergeinfo pre-existing in the WC. */
static svn_error_t *
@@ -240,47 +177,41 @@ get_copy_pair_ancestors(const apr_array_
}
-struct do_wc_to_wc_copies_with_write_lock_baton {
- const apr_array_header_t *copy_pairs;
- svn_client_ctx_t *ctx;
- const char *dst_parent;
-};
-
/* The guts of do_wc_to_wc_copies */
static svn_error_t *
-do_wc_to_wc_copies_with_write_lock(void *baton,
- apr_pool_t *result_pool,
+do_wc_to_wc_copies_with_write_lock(const apr_array_header_t *copy_pairs,
+ const char *dst_parent,
+ svn_client_ctx_t *ctx,
apr_pool_t *scratch_pool)
{
- struct do_wc_to_wc_copies_with_write_lock_baton *b = baton;
int i;
apr_pool_t *iterpool = svn_pool_create(scratch_pool);
svn_error_t *err = SVN_NO_ERROR;
- for (i = 0; i < b->copy_pairs->nelts; i++)
+ for (i = 0; i < copy_pairs->nelts; i++)
{
const char *dst_abspath;
- svn_client__copy_pair_t *pair = APR_ARRAY_IDX(b->copy_pairs, i,
+ svn_client__copy_pair_t *pair = APR_ARRAY_IDX(copy_pairs, i,
svn_client__copy_pair_t *);
svn_pool_clear(iterpool);
/* Check for cancellation */
- if (b->ctx->cancel_func)
- SVN_ERR(b->ctx->cancel_func(b->ctx->cancel_baton));
+ if (ctx->cancel_func)
+ SVN_ERR(ctx->cancel_func(ctx->cancel_baton));
/* Perform the copy */
dst_abspath = svn_dirent_join(pair->dst_parent_abspath, pair->base_name,
iterpool);
- err = svn_wc_copy3(b->ctx->wc_ctx, pair->src_abspath_or_url, dst_abspath,
+ err = svn_wc_copy3(ctx->wc_ctx, pair->src_abspath_or_url, dst_abspath,
FALSE /* metadata_only */,
- b->ctx->cancel_func, b->ctx->cancel_baton,
- b->ctx->notify_func2, b->ctx->notify_baton2, iterpool);
+ ctx->cancel_func, ctx->cancel_baton,
+ ctx->notify_func2, ctx->notify_baton2, iterpool);
if (err)
break;
}
svn_pool_destroy(iterpool);
- svn_io_sleep_for_timestamps(b->dst_parent, scratch_pool);
+ svn_io_sleep_for_timestamps(dst_parent, scratch_pool);
SVN_ERR(err);
return SVN_NO_ERROR;
}
@@ -293,7 +224,6 @@ do_wc_to_wc_copies(const apr_array_heade
apr_pool_t *pool)
{
const char *dst_parent, *dst_parent_abspath;
- struct do_wc_to_wc_copies_with_write_lock_baton baton;
SVN_ERR(get_copy_pair_ancestors(copy_pairs, NULL, &dst_parent, NULL, pool));
if (copy_pairs->nelts == 1)
@@ -301,40 +231,31 @@ do_wc_to_wc_copies(const apr_array_heade
SVN_ERR(svn_dirent_get_absolute(&dst_parent_abspath, dst_parent, pool));
- baton.copy_pairs = copy_pairs;
- baton.ctx = ctx;
- baton.dst_parent = dst_parent;
- SVN_ERR(svn_wc__call_with_write_lock(do_wc_to_wc_copies_with_write_lock,
- &baton, ctx->wc_ctx, dst_parent_abspath,
- FALSE, pool, pool));
+ SVN_WC__CALL_WITH_WRITE_LOCK(
+ do_wc_to_wc_copies_with_write_lock(copy_pairs, dst_parent, ctx, pool),
+ ctx->wc_ctx, dst_parent_abspath, FALSE, pool);
return SVN_NO_ERROR;
}
-struct do_wc_to_wc_moves_with_locks_baton {
- svn_client_ctx_t *ctx;
- svn_client__copy_pair_t *pair;
- const char *dst_parent_abspath;
- svn_boolean_t lock_src;
- svn_boolean_t lock_dst;
-};
-
/* The locked bit of do_wc_to_wc_moves. */
static svn_error_t *
-do_wc_to_wc_moves_with_locks2(void *baton,
- apr_pool_t *result_pool,
+do_wc_to_wc_moves_with_locks2(svn_client__copy_pair_t *pair,
+ const char *dst_parent_abspath,
+ svn_boolean_t lock_src,
+ svn_boolean_t lock_dst,
+ svn_client_ctx_t *ctx,
apr_pool_t *scratch_pool)
{
- struct do_wc_to_wc_moves_with_locks_baton *b = baton;
const char *dst_abspath;
- dst_abspath = svn_dirent_join(b->dst_parent_abspath, b->pair->base_name,
+ dst_abspath = svn_dirent_join(dst_parent_abspath, pair->base_name,
scratch_pool);
- SVN_ERR(svn_wc_move(b->ctx->wc_ctx, b->pair->src_abspath_or_url,
+ SVN_ERR(svn_wc_move(ctx->wc_ctx, pair->src_abspath_or_url,
dst_abspath, FALSE /* metadata_only */,
- b->ctx->cancel_func, b->ctx->cancel_baton,
- b->ctx->notify_func2, b->ctx->notify_baton2,
+ ctx->cancel_func, ctx->cancel_baton,
+ ctx->notify_func2, ctx->notify_baton2,
scratch_pool));
return SVN_NO_ERROR;
@@ -342,18 +263,21 @@ do_wc_to_wc_moves_with_locks2(void *bato
/* Wrapper to add an optional second lock */
static svn_error_t *
-do_wc_to_wc_moves_with_locks1(void *baton,
- apr_pool_t *result_pool,
+do_wc_to_wc_moves_with_locks1(svn_client__copy_pair_t *pair,
+ const char *dst_parent_abspath,
+ svn_boolean_t lock_src,
+ svn_boolean_t lock_dst,
+ svn_client_ctx_t *ctx,
apr_pool_t *scratch_pool)
{
- struct do_wc_to_wc_moves_with_locks_baton *b = baton;
-
- if (b->lock_dst)
- SVN_ERR(svn_wc__call_with_write_lock(do_wc_to_wc_moves_with_locks2, b,
- b->ctx->wc_ctx, b->dst_parent_abspath,
- FALSE, result_pool, scratch_pool));
+ if (lock_dst)
+ SVN_WC__CALL_WITH_WRITE_LOCK(
+ do_wc_to_wc_moves_with_locks2(pair, dst_parent_abspath, lock_src,
+ lock_dst, ctx, scratch_pool),
+ ctx->wc_ctx, dst_parent_abspath, FALSE, scratch_pool);
else
- SVN_ERR(do_wc_to_wc_moves_with_locks2(b, result_pool, scratch_pool));
+ SVN_ERR(do_wc_to_wc_moves_with_locks2(pair, dst_parent_abspath, lock_src,
+ lock_dst, ctx, scratch_pool));
return SVN_NO_ERROR;
}
@@ -373,7 +297,7 @@ do_wc_to_wc_moves(const apr_array_header
for (i = 0; i < copy_pairs->nelts; i++)
{
const char *src_parent_abspath;
- struct do_wc_to_wc_moves_with_locks_baton baton;
+ svn_boolean_t lock_src, lock_dst;
svn_client__copy_pair_t *pair = APR_ARRAY_IDX(copy_pairs, i,
svn_client__copy_pair_t *);
@@ -397,32 +321,33 @@ do_wc_to_wc_moves(const apr_array_header
|| svn_dirent_is_child(src_parent_abspath, pair->dst_parent_abspath,
iterpool))
{
- baton.lock_src = TRUE;
- baton.lock_dst = FALSE;
+ lock_src = TRUE;
+ lock_dst = FALSE;
}
- else if (svn_dirent_is_child(pair->dst_parent_abspath, src_parent_abspath,
+ else if (svn_dirent_is_child(pair->dst_parent_abspath,
+ src_parent_abspath,
iterpool))
{
- baton.lock_src = FALSE;
- baton.lock_dst = TRUE;
+ lock_src = FALSE;
+ lock_dst = TRUE;
}
else
{
- baton.lock_src = TRUE;
- baton.lock_dst = TRUE;
+ lock_src = TRUE;
+ lock_dst = TRUE;
}
/* Perform the copy and then the delete. */
- baton.ctx = ctx;
- baton.pair = pair;
- baton.dst_parent_abspath = pair->dst_parent_abspath;
- if (baton.lock_src)
- SVN_ERR(svn_wc__call_with_write_lock(do_wc_to_wc_moves_with_locks1,
- &baton,
- ctx->wc_ctx, src_parent_abspath,
- FALSE, iterpool, iterpool));
+ if (lock_src)
+ SVN_WC__CALL_WITH_WRITE_LOCK(
+ do_wc_to_wc_moves_with_locks1(pair, pair->dst_parent_abspath,
+ lock_src, lock_dst, ctx, iterpool),
+ ctx->wc_ctx, src_parent_abspath,
+ FALSE, iterpool);
else
- SVN_ERR(do_wc_to_wc_moves_with_locks1(&baton, iterpool, iterpool));
+ SVN_ERR(do_wc_to_wc_moves_with_locks1(pair, pair->dst_parent_abspath,
+ lock_src, lock_dst, ctx,
+ iterpool));
}
svn_pool_destroy(iterpool);
@@ -525,6 +450,16 @@ verify_wc_srcs_and_dsts(const apr_array_
SVN_ERR(svn_client__make_local_parents(pair->dst_parent_abspath,
TRUE, ctx, iterpool));
}
+ else if (make_parents && dst_parent_kind == svn_node_dir)
+ {
+ /* Check if parent is already versioned */
+ SVN_ERR(svn_wc_read_kind(&dst_parent_kind, ctx->wc_ctx,
+ pair->dst_parent_abspath, FALSE, iterpool));
+
+ if (dst_parent_kind == svn_node_none)
+ SVN_ERR(svn_client__make_local_parents(pair->dst_parent_abspath,
+ TRUE, ctx, iterpool));
+ }
else if (dst_parent_kind != svn_node_dir)
{
return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
@@ -762,7 +697,6 @@ repos_to_repos_copy(const apr_array_head
apr_array_header_t *path_infos;
const char *top_url, *top_url_all, *top_url_dst;
const char *message, *repos_root;
- svn_revnum_t youngest = SVN_INVALID_REVNUM;
svn_ra_session_t *ra_session = NULL;
const svn_delta_editor_t *editor;
void *edit_baton;
@@ -818,9 +752,10 @@ repos_to_repos_copy(const apr_array_head
/* Go ahead and grab mergeinfo from the source, too. */
SVN_ERR(svn_ra_reparent(ra_session, pair->src_abspath_or_url, pool));
- SVN_ERR(calculate_target_mergeinfo(ra_session, &mergeinfo, NULL,
- pair->src_abspath_or_url,
- pair->src_revnum, ctx, pool));
+ SVN_ERR(svn_client__get_repos_mergeinfo(
+ &mergeinfo, ra_session,
+ pair->src_abspath_or_url, pair->src_revnum,
+ svn_mergeinfo_inherited, TRUE /*squelch_incapable*/, pool));
if (mergeinfo)
SVN_ERR(svn_mergeinfo_to_string(&info->mergeinfo, mergeinfo, pool));
@@ -995,7 +930,7 @@ repos_to_repos_copy(const apr_array_head
}
else
{
- const char *old_url = NULL;
+ const char *old_url;
src_rel = NULL;
SVN_ERR_ASSERT(! is_move);
@@ -1015,7 +950,7 @@ repos_to_repos_copy(const apr_array_head
/* Figure out the basename that will result from this operation,
and ensure that we aren't trying to overwrite existing paths. */
dst_rel = svn_uri_skip_ancestor(top_url, pair->dst_abspath_or_url, pool);
- SVN_ERR(svn_ra_check_path(ra_session, dst_rel, youngest,
+ SVN_ERR(svn_ra_check_path(ra_session, dst_rel, SVN_INVALID_REVNUM,
&dst_kind, pool));
if (dst_kind != svn_node_none)
return svn_error_createf(SVN_ERR_FS_ALREADY_EXISTS, NULL,
@@ -1059,14 +994,16 @@ repos_to_repos_copy(const apr_array_head
path_driver_info_t *);
item = svn_client_commit_item3_create(pool);
- item->url = svn_path_url_add_component2(top_url, info->dst_path, pool);
+ item->url = svn_path_url_add_component2(top_url, info->dst_path,
+ pool);
item->state_flags = SVN_CLIENT_COMMIT_ITEM_ADD;
APR_ARRAY_PUSH(commit_items, svn_client_commit_item3_t *) = item;
if (is_move && (! info->resurrection))
{
item = apr_pcalloc(pool, sizeof(*item));
- item->url = svn_path_url_add_component2(top_url, info->src_path, pool);
+ item->url = svn_path_url_add_component2(top_url, info->src_path,
+ pool);
item->state_flags = SVN_CLIENT_COMMIT_ITEM_DELETE;
APR_ARRAY_PUSH(commit_items, svn_client_commit_item3_t *) = item;
}
@@ -1112,6 +1049,9 @@ repos_to_repos_copy(const apr_array_head
message, ctx, pool));
/* Fetch RA commit editor. */
+ SVN_ERR(svn_ra__register_editor_shim_callbacks(ra_session,
+ svn_client__get_shim_callbacks(ctx->wc_ctx,
+ NULL, pool)));
SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton,
commit_revprops,
commit_callback,
@@ -1126,7 +1066,7 @@ repos_to_repos_copy(const apr_array_head
cb_baton.is_move = is_move;
/* Call the path-based editor driver. */
- err = svn_delta_path_driver(editor, edit_baton, youngest, paths,
+ err = svn_delta_path_driver(editor, edit_baton, SVN_INVALID_REVNUM, paths,
path_driver_cb_func, &cb_baton, pool);
if (err)
{
@@ -1175,7 +1115,8 @@ check_url_kind(void *baton,
/* ### Copy ...
* COMMIT_INFO_P is ...
- * COPY_PAIRS is ...
+ * COPY_PAIRS is ... such that each 'src_abspath_or_url' is a local abspath
+ * and each 'dst_abspath_or_url' is a URL.
* MAKE_PARENTS is ...
* REVPROP_TABLE is ...
* CTX is ... */
@@ -1194,6 +1135,7 @@ wc_to_repos_copy(const apr_array_header_
const char *top_src_abspath;
svn_ra_session_t *ra_session;
const svn_delta_editor_t *editor;
+ apr_hash_t *relpath_map = NULL;
void *edit_baton;
svn_client__committables_t *committables;
apr_array_header_t *commit_items;
@@ -1214,7 +1156,9 @@ wc_to_repos_copy(const apr_array_header_
/* Verify that all the source paths exist, are versioned, etc.
We'll do so by querying the base revisions of those things (which
- we'll need to know later anyway). */
+ we'll need to know later anyway).
+ ### Should we use the 'origin' revision instead of 'base'?
+ */
for (i = 0; i < copy_pairs->nelts; i++)
{
svn_client__copy_pair_t *pair = APR_ARRAY_IDX(copy_pairs, i,
@@ -1375,17 +1319,26 @@ wc_to_repos_copy(const apr_array_header_
svn_client__copy_pair_t *);
svn_client_commit_item3_t *item =
APR_ARRAY_IDX(commit_items, i, svn_client_commit_item3_t *);
+ svn_client__pathrev_t *src_origin;
svn_pool_clear(iterpool);
+ SVN_ERR(svn_client__wc_node_get_origin(&src_origin,
+ pair->src_abspath_or_url,
+ ctx, iterpool, iterpool));
+
/* Set the mergeinfo for the destination to the combined merge
info known to the WC and the repository. */
item->outgoing_prop_changes = apr_array_make(pool, 1,
sizeof(svn_prop_t *));
- SVN_ERR(calculate_target_mergeinfo(ra_session, &mergeinfo,
- pair->src_abspath_or_url,
- NULL, SVN_INVALID_REVNUM,
- ctx, iterpool));
+ /* Repository mergeinfo (or NULL if it's locally added)... */
+ if (src_origin)
+ SVN_ERR(svn_client__get_repos_mergeinfo(
+ &mergeinfo, ra_session, src_origin->url, src_origin->rev,
+ svn_mergeinfo_inherited, TRUE /*sqelch_inc.*/, iterpool));
+ else
+ mergeinfo = NULL;
+ /* ... and WC mergeinfo. */
SVN_ERR(svn_client__parse_mergeinfo(&wc_mergeinfo, ctx->wc_ctx,
pair->src_abspath_or_url,
iterpool, iterpool));
@@ -1418,12 +1371,38 @@ wc_to_repos_copy(const apr_array_header_
SVN_ERR(svn_client__condense_commit_items(&top_dst_url,
commit_items, pool));
+#ifdef ENABLE_EV2_SHIMS
+ if (commit_items)
+ {
+ relpath_map = apr_hash_make(pool);
+ for (i = 0; i < commit_items->nelts; i++)
+ {
+ svn_client_commit_item3_t *item = APR_ARRAY_IDX(commit_items, i,
+ svn_client_commit_item3_t *);
+ const char *relpath;
+
+ if (!item->path)
+ continue;
+
+ svn_pool_clear(iterpool);
+ SVN_ERR(svn_wc__node_get_origin(NULL, NULL, &relpath, NULL, NULL, NULL,
+ ctx->wc_ctx, item->path, FALSE, pool,
+ iterpool));
+ if (relpath)
+ apr_hash_set(relpath_map, relpath, APR_HASH_KEY_STRING, item->path);
+ }
+ }
+#endif
+
/* Open an RA session to DST_URL. */
SVN_ERR(svn_client__open_ra_session_internal(&ra_session, NULL, top_dst_url,
NULL, commit_items,
FALSE, FALSE, ctx, pool));
/* Fetch RA commit editor. */
+ SVN_ERR(svn_ra__register_editor_shim_callbacks(ra_session,
+ svn_client__get_shim_callbacks(ctx->wc_ctx, relpath_map,
+ pool)));
SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton,
commit_revprops,
commit_callback,
@@ -1526,7 +1505,7 @@ repos_to_wc_copy_single(svn_client__copy
pair->src_original,
tmp_abspath,
&pair->src_peg_revision,
- &pair->src_op_revision, NULL,
+ &pair->src_op_revision,
svn_depth_infinity,
ignore_externals, FALSE,
&sleep_needed, ctx, pool);
@@ -1581,27 +1560,18 @@ repos_to_wc_copy_single(svn_client__copy
else if (pair->src_kind == svn_node_file)
{
- svn_stream_t *fstream;
- const char *new_text_path;
apr_hash_t *new_props;
const char *src_rel;
- svn_stream_t *new_base_contents;
-
- SVN_ERR(svn_stream_open_unique(&fstream, &new_text_path, NULL,
- svn_io_file_del_on_pool_cleanup, pool,
- pool));
+ svn_stream_t *new_base_contents = svn_stream_buffered(pool);
SVN_ERR(svn_ra_get_path_relative_to_session(ra_session, &src_rel,
pair->src_abspath_or_url,
pool));
/* Fetch the file content. While doing so, resolve pair->src_revnum
* to an actual revision number if it's 'invalid' meaning 'head'. */
- SVN_ERR(svn_ra_get_file(ra_session, src_rel, pair->src_revnum, fstream,
+ SVN_ERR(svn_ra_get_file(ra_session, src_rel, pair->src_revnum,
+ new_base_contents,
&pair->src_revnum, &new_props, pool));
- SVN_ERR(svn_stream_close(fstream));
-
- SVN_ERR(svn_stream_open_readonly(&new_base_contents, new_text_path,
- pool, pool));
SVN_ERR(svn_wc_add_repos_file4(
ctx->wc_ctx, dst_abspath,
new_base_contents, NULL, new_props, NULL,
@@ -1613,9 +1583,10 @@ repos_to_wc_copy_single(svn_client__copy
/* Record the implied mergeinfo (before the notification callback
is invoked for the root node). */
- SVN_ERR(calculate_target_mergeinfo(ra_session, &src_mergeinfo, NULL,
- pair->src_abspath_or_url,
- pair->src_revnum, ctx, pool));
+ SVN_ERR(svn_client__get_repos_mergeinfo(
+ &src_mergeinfo, ra_session,
+ pair->src_abspath_or_url, pair->src_revnum,
+ svn_mergeinfo_inherited, TRUE /*squelch_incapable*/, pool));
SVN_ERR(extend_wc_mergeinfo(dst_abspath, src_mergeinfo, ctx, pool));
/* Do our own notification for the root node, even if we could possibly
@@ -1773,29 +1744,6 @@ repos_to_wc_copy_locked(const apr_array_
return SVN_NO_ERROR;
}
-struct repos_to_wc_copy_baton {
- const apr_array_header_t *copy_pairs;
- const char *top_dst_path;
- svn_boolean_t ignore_externals;
- svn_ra_session_t *ra_session;
- svn_client_ctx_t *ctx;
-};
-
-/* Implements svn_wc__with_write_lock_func_t. */
-static svn_error_t *
-repos_to_wc_copy_cb(void *baton,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
-{
- struct repos_to_wc_copy_baton *b = baton;
-
- SVN_ERR(repos_to_wc_copy_locked(b->copy_pairs, b->top_dst_path,
- b->ignore_externals, b->ra_session,
- b->ctx, scratch_pool));
-
- return SVN_NO_ERROR;
-}
-
static svn_error_t *
repos_to_wc_copy(const apr_array_header_t *copy_pairs,
svn_boolean_t make_parents,
@@ -1807,7 +1755,6 @@ repos_to_wc_copy(const apr_array_header_
const char *top_src_url, *top_dst_path;
apr_pool_t *iterpool = svn_pool_create(pool);
const char *lock_abspath;
- struct repos_to_wc_copy_baton baton;
int i;
/* Get the real path for the source, based upon its peg revision. */
@@ -1907,15 +1854,10 @@ repos_to_wc_copy(const apr_array_header_
}
svn_pool_destroy(iterpool);
- baton.copy_pairs = copy_pairs;
- baton.top_dst_path = top_dst_path;
- baton.ignore_externals = ignore_externals;
- baton.ra_session = ra_session;
- baton.ctx = ctx;
-
- SVN_ERR(svn_wc__call_with_write_lock(repos_to_wc_copy_cb, &baton,
- ctx->wc_ctx, lock_abspath,
- FALSE, pool, pool));
+ SVN_WC__CALL_WITH_WRITE_LOCK(
+ repos_to_wc_copy_locked(copy_pairs, top_dst_path, ignore_externals,
+ ra_session, ctx, pool),
+ ctx->wc_ctx, lock_abspath, FALSE, pool);
return SVN_NO_ERROR;
}
@@ -2170,7 +2112,7 @@ try_copy(const apr_array_header_t *sourc
SVN_ERR(svn_wc__node_get_origin(NULL, ©from_rev,
©from_repos_relpath,
©from_repos_root_url,
- NULL,
+ NULL, NULL,
ctx->wc_ctx,
pair->src_abspath_or_url,
TRUE, iterpool, iterpool));
Modified: subversion/branches/javahl-ra/subversion/libsvn_client/delete.c
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_client/delete.c?rev=1329209&r1=1329208&r2=1329209&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_client/delete.c (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_client/delete.c Mon Apr 23 12:32:48 2012
@@ -39,6 +39,7 @@
#include "private/svn_client_private.h"
#include "private/svn_wc_private.h"
+#include "private/svn_ra_private.h"
#include "svn_private_config.h"
@@ -187,6 +188,9 @@ single_repos_delete(svn_ra_session_t *ra
log_msg, ctx, pool));
/* Fetch RA commit editor */
+ SVN_ERR(svn_ra__register_editor_shim_callbacks(ra_session,
+ svn_client__get_shim_callbacks(ctx->wc_ctx,
+ NULL, pool)));
SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton,
commit_revprops,
commit_callback,
@@ -272,6 +276,12 @@ delete_urls_multi_repos(const apr_array_
APR_ARRAY_PUSH(relpaths_list, const char *) = repos_relpath;
}
+ /* Check we identified a non-root relpath. Return an RA error
+ code for 1.6 compatibility. */
+ if (!repos_relpath || !*repos_relpath)
+ return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
+ "URL '%s' not within a repository", uri);
+
/* Now, test to see if the thing actually exists. */
SVN_ERR(svn_ra_check_path(ra_session, repos_relpath, SVN_INVALID_REVNUM,
&kind, pool));
@@ -368,30 +378,6 @@ svn_client__wc_delete_many(const apr_arr
return SVN_NO_ERROR;
}
-/* Callback baton for delete_with_write_lock_baton. */
-struct delete_with_write_lock_baton
-{
- const apr_array_header_t *targets;
- svn_boolean_t force;
- svn_boolean_t keep_local;
- svn_client_ctx_t *ctx;
-};
-
-/* Implements svn_wc__with_write_lock_func_t. */
-static svn_error_t *
-delete_with_write_lock_func(void *baton,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
-{
- struct delete_with_write_lock_baton *args = baton;
-
- return svn_client__wc_delete_many(args->targets, args->force,
- FALSE, args->keep_local,
- args->ctx->notify_func2,
- args->ctx->notify_baton2,
- args->ctx, scratch_pool);
-}
-
svn_error_t *
svn_client_delete4(const apr_array_header_t *paths,
svn_boolean_t force,
@@ -417,8 +403,6 @@ svn_client_delete4(const apr_array_heade
}
else
{
- struct delete_with_write_lock_baton dwwlb;
- const char *wcroot_abspath;
const char *local_abspath;
apr_hash_t *wcroots;
apr_hash_index_t *hi;
@@ -432,6 +416,7 @@ svn_client_delete4(const apr_array_heade
iterpool = svn_pool_create(pool);
for (i = 0; i < paths->nelts; i++)
{
+ const char *wcroot_abspath;
apr_array_header_t *targets;
svn_pool_clear(iterpool);
@@ -474,17 +459,17 @@ svn_client_delete4(const apr_array_heade
/* Delete the targets from each working copy in turn. */
for (hi = apr_hash_first(pool, wcroots); hi; hi = apr_hash_next(hi))
{
+ const char *wcroot_abspath = svn__apr_hash_index_key(hi);
+ const apr_array_header_t *targets = svn__apr_hash_index_val(hi);
+
svn_pool_clear(iterpool);
- wcroot_abspath = svn__apr_hash_index_key(hi);
- dwwlb.targets = svn__apr_hash_index_val(hi);
- dwwlb.force = force;
- dwwlb.keep_local = keep_local;
- dwwlb.ctx = ctx;
- SVN_ERR(svn_wc__call_with_write_lock(delete_with_write_lock_func,
- &dwwlb, ctx->wc_ctx,
- wcroot_abspath, TRUE,
- iterpool, iterpool));
+ SVN_WC__CALL_WITH_WRITE_LOCK(
+ svn_client__wc_delete_many(targets, force, FALSE, keep_local,
+ ctx->notify_func2, ctx->notify_baton2,
+ ctx, iterpool),
+ ctx->wc_ctx, wcroot_abspath, TRUE /* lock_anchor */,
+ iterpool);
}
svn_pool_destroy(iterpool);
}
Modified: subversion/branches/javahl-ra/subversion/libsvn_client/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_client/deprecated.c?rev=1329209&r1=1329208&r2=1329209&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_client/deprecated.c (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_client/deprecated.c Mon Apr 23 12:32:48 2012
@@ -44,6 +44,7 @@
#include "client.h"
#include "mergeinfo.h"
+#include "private/svn_opt_private.h"
#include "private/svn_wc_private.h"
#include "svn_private_config.h"
@@ -385,6 +386,27 @@ svn_client_args_to_target_array(apr_arra
/*** From commit.c ***/
svn_error_t *
+svn_client_import4(const char *path,
+ const char *url,
+ svn_depth_t depth,
+ svn_boolean_t no_ignore,
+ svn_boolean_t ignore_unknown_node_types,
+ const apr_hash_t *revprop_table,
+ svn_commit_callback2_t commit_callback,
+ void *commit_baton,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *pool)
+{
+ return svn_error_trace(svn_client_import5(path, url, depth, no_ignore,
+ ignore_unknown_node_types,
+ revprop_table,
+ NULL, NULL,
+ commit_callback, commit_baton,
+ ctx, pool));
+}
+
+
+svn_error_t *
svn_client_import3(svn_commit_info_t **commit_info_p,
const char *path,
const char *url,
@@ -863,7 +885,7 @@ svn_client_diff5(const apr_array_header_
return svn_client_diff6(diff_options, path1, revision1, path2,
revision2, relative_to_dir, depth,
ignore_ancestry, no_diff_deleted,
- show_copies_as_adds, ignore_content_type,
+ show_copies_as_adds, ignore_content_type, FALSE,
use_git_diff_format, header_encoding,
outstream, errstream, changelists, ctx, pool);
}
@@ -991,6 +1013,7 @@ svn_client_diff_peg5(const apr_array_hea
no_diff_deleted,
show_copies_as_adds,
ignore_content_type,
+ FALSE,
use_git_diff_format,
header_encoding,
outstream,
@@ -1362,16 +1385,11 @@ svn_client_log4(const apr_array_header_t
apr_pool_t *pool)
{
apr_array_header_t *revision_ranges;
- svn_opt_revision_range_t *range;
-
- range = apr_palloc(pool, sizeof(svn_opt_revision_range_t));
- range->start = *start;
- range->end = *end;
revision_ranges = apr_array_make(pool, 1,
sizeof(svn_opt_revision_range_t *));
-
- APR_ARRAY_PUSH(revision_ranges, svn_opt_revision_range_t *) = range;
+ APR_ARRAY_PUSH(revision_ranges, svn_opt_revision_range_t *)
+ = svn_opt__revision_range_create(start, end, pool);
return svn_client_log5(targets, peg_revision, revision_ranges, limit,
discover_changed_paths, strict_node_history,
@@ -1577,13 +1595,11 @@ svn_client_merge_peg2(const char *source
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
- svn_opt_revision_range_t range;
apr_array_header_t *ranges_to_merge =
apr_array_make(pool, 1, sizeof(svn_opt_revision_range_t *));
- range.start = *revision1;
- range.end = *revision2;
- APR_ARRAY_PUSH(ranges_to_merge, svn_opt_revision_range_t *) = ⦥
+ APR_ARRAY_PUSH(ranges_to_merge, svn_opt_revision_range_t *)
+ = svn_opt__revision_range_create(revision1, revision2, pool);
return svn_client_merge_peg3(source, ranges_to_merge,
peg_revision,
target_wcpath,
Modified: subversion/branches/javahl-ra/subversion/libsvn_client/diff.c
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_client/diff.c?rev=1329209&r1=1329208&r2=1329209&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_client/diff.c (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_client/diff.c Mon Apr 23 12:32:48 2012
@@ -147,18 +147,25 @@ display_mergeinfo_diff(const char *old_m
If TOKEN is empty, or is already terminated by an EOL marker,
return TOKEN unmodified. Else, return a new string consisting
of the concatenation of TOKEN and the system's default EOL marker.
- The new string is allocated from POOL. */
+ The new string is allocated from POOL.
+ If HAD_EOL is not NULL, indicate in *HAD_EOL if the token had a EOL. */
static const svn_string_t *
-maybe_append_eol(const svn_string_t *token, apr_pool_t *pool)
+maybe_append_eol(const svn_string_t *token, svn_boolean_t *had_eol,
+ apr_pool_t *pool)
{
const char *curp;
+ if (had_eol)
+ *had_eol = FALSE;
+
if (token->len == 0)
return token;
curp = token->data + token->len - 1;
if (*curp == '\r')
{
+ if (had_eol)
+ *had_eol = TRUE;
return token;
}
else if (*curp != '\n')
@@ -167,6 +174,8 @@ maybe_append_eol(const svn_string_t *tok
}
else
{
+ if (had_eol)
+ *had_eol = TRUE;
return token;
}
}
@@ -665,18 +674,19 @@ display_prop_diffs(const apr_array_heade
const svn_string_t *tmp;
const svn_string_t *orig;
const svn_string_t *val;
+ svn_boolean_t val_has_eol;
/* The last character in a property is often not a newline.
- Since the diff is not useful anyway for patching properties an
- eol character is appended when needed to remove those pescious
- ' \ No newline at end of file' lines. */
- tmp = original_value ? original_value
+ An eol character is appended to prevent the diff API to add a
+ ' \ No newline at end of file' line. We add
+ ' \ No newline at end of property' manually if needed. */
+ tmp = original_value ? original_value
: svn_string_create_empty(iterpool);
- orig = maybe_append_eol(tmp, iterpool);
+ orig = maybe_append_eol(tmp, NULL, iterpool);
tmp = propchange->value ? propchange->value :
svn_string_create_empty(iterpool);
- val = maybe_append_eol(tmp, iterpool);
+ val = maybe_append_eol(tmp, &val_has_eol, iterpool);
SVN_ERR(svn_diff_mem_string_diff(&diff, orig, val, &options,
iterpool));
@@ -695,7 +705,12 @@ display_prop_diffs(const apr_array_heade
svn_dirent_local_style(path,
iterpool),
encoding, orig, val, iterpool));
-
+ if (!val_has_eol)
+ {
+ const char *s = "\\ No newline at end of property" APR_EOL_STR;
+ apr_size_t len = strlen(s);
+ SVN_ERR(svn_stream_write(outstream, s, &len));
+ }
}
}
svn_pool_destroy(iterpool);
@@ -762,6 +777,9 @@ struct diff_cmd_baton {
relative to for output generation (see issue #2723). */
const char *relative_to_dir;
+ /* Whether property differences are ignored. */
+ svn_boolean_t ignore_prop_diff;
+
/* Whether we're producing a git-style diff. */
svn_boolean_t use_git_diff_format;
@@ -787,6 +805,17 @@ struct diff_cmd_baton {
};
+/* A helper function that marks a path as visited. It copies PATH
+ * into the correct pool before referencing it from the hash table. */
+static void
+mark_path_as_visited(struct diff_cmd_baton *diff_cmd_baton, const char *path)
+{
+ const char *p;
+
+ p = apr_pstrdup(apr_hash_pool_get(diff_cmd_baton->visited_paths), path);
+ apr_hash_set(diff_cmd_baton->visited_paths, p, APR_HASH_KEY_STRING, p);
+}
+
/* An helper for diff_dir_props_changed, diff_file_changed and diff_file_added
*/
static svn_error_t *
@@ -802,6 +831,10 @@ diff_props_changed(svn_wc_notify_state_t
apr_array_header_t *props;
svn_boolean_t show_diff_header;
+ /* If property differences are ignored, there's nothing to do. */
+ if (diff_cmd_baton->ignore_prop_diff)
+ return SVN_NO_ERROR;
+
SVN_ERR(svn_categorize_props(propchanges, NULL, NULL, &props,
scratch_pool));
@@ -833,8 +866,7 @@ diff_props_changed(svn_wc_notify_state_t
/* We've printed the diff header so now we can mark the path as
* visited. */
if (show_diff_header)
- apr_hash_set(diff_cmd_baton->visited_paths, path,
- APR_HASH_KEY_STRING, path);
+ mark_path_as_visited(diff_cmd_baton, path);
}
if (state)
@@ -1050,9 +1082,7 @@ diff_content_changed(const char *path,
subpool));
/* We have a printed a diff for this path, mark it as visited. */
- apr_hash_set(diff_cmd_baton->visited_paths, path,
- APR_HASH_KEY_STRING, path);
-
+ mark_path_as_visited(diff_cmd_baton, path);
}
}
@@ -1314,7 +1344,7 @@ static const svn_wc_diff_callbacks4_t di
diff_dir_opened,
diff_dir_added,
diff_dir_props_changed,
- diff_dir_closed
+ diff_dir_closed
};
/*-----------------------------------------------------------------*/
@@ -1432,6 +1462,84 @@ check_paths(svn_boolean_t *is_repos1,
return SVN_NO_ERROR;
}
+/* Raise an error if the diff target URL does not exist at REVISION.
+ * If REVISION does not equal OTHER_REVISION, mention both revisions in
+ * the error message. Use RA_SESSION to contact the repository.
+ * Use POOL for temporary allocations. */
+static svn_error_t *
+check_diff_target_exists(const char *url,
+ svn_revnum_t revision,
+ svn_revnum_t other_revision,
+ svn_ra_session_t *ra_session,
+ apr_pool_t *pool)
+{
+ svn_node_kind_t kind;
+ const char *session_url;
+
+ SVN_ERR(svn_ra_get_session_url(ra_session, &session_url, pool));
+
+ if (strcmp(url, session_url) != 0)
+ SVN_ERR(svn_ra_reparent(ra_session, url, pool));
+
+ SVN_ERR(svn_ra_check_path(ra_session, "", revision, &kind, pool));
+ if (kind == svn_node_none)
+ {
+ if (revision == other_revision)
+ return svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
+ _("Diff target '%s' was not found in the "
+ "repository at revision '%ld'"),
+ url, revision);
+ else
+ return svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
+ _("Diff target '%s' was not found in the "
+ "repository at revision '%ld' or '%ld'"),
+ url, revision, other_revision);
+ }
+
+ if (strcmp(url, session_url) != 0)
+ SVN_ERR(svn_ra_reparent(ra_session, session_url, pool));
+
+ return SVN_NO_ERROR;
+}
+
+
+/* Return in *RESOLVED_URL the URL which PATH_OR_URL@PEG_REVISION has in
+ * REVISION. If the object has no location in REVISION, set *RESOLVED_URL
+ * to NULL. */
+static svn_error_t *
+resolve_pegged_diff_target_url(const char **resolved_url,
+ svn_ra_session_t *ra_session,
+ const char *path_or_url,
+ const svn_opt_revision_t *peg_revision,
+ const svn_opt_revision_t *revision,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *scratch_pool)
+{
+ svn_error_t *err;
+
+ /* Check if the PATH_OR_URL exists at REVISION. */
+ err = svn_client__repos_locations(resolved_url, NULL,
+ NULL, NULL,
+ ra_session,
+ path_or_url,
+ peg_revision,
+ revision,
+ NULL,
+ ctx, scratch_pool);
+ if (err)
+ {
+ if (err->apr_err == SVN_ERR_CLIENT_UNRELATED_RESOURCES)
+ {
+ svn_error_clear(err);
+ *resolved_url = NULL;
+ }
+ else
+ return svn_error_trace(err);
+ }
+
+ return SVN_NO_ERROR;
+}
+
/** Prepare a repos repos diff between PATH_OR_URL1 and
* PATH_OR_URL2@PEG_REVISION, in the revision range REVISION1:REVISION2.
* Return URLs and peg revisions in *URL1, *REV1 and in *URL2, *REV2.
@@ -1498,14 +1606,35 @@ diff_prepare_repos_repos(const char **ur
actual URLs will be. */
if (peg_revision->kind != svn_opt_revision_unspecified)
{
- SVN_ERR(svn_client__repos_locations(url1, NULL,
- url2, NULL,
- *ra_session,
- path_or_url2,
- peg_revision,
- revision1,
- revision2,
- ctx, pool));
+ const char *resolved_url1;
+ const char *resolved_url2;
+
+ SVN_ERR(resolve_pegged_diff_target_url(&resolved_url2, *ra_session,
+ path_or_url2, peg_revision,
+ revision2, ctx, pool));
+
+ SVN_ERR(svn_ra_reparent(*ra_session, *url1, pool));
+ SVN_ERR(resolve_pegged_diff_target_url(&resolved_url1, *ra_session,
+ path_or_url1, peg_revision,
+ revision1, ctx, pool));
+
+ /* Either or both URLs might have changed as a result of resolving
+ * the PATH_OR_URL@PEG_REVISION's history. If only one of the URLs
+ * could be resolved, use the same URL for URL1 and URL2, so we can
+ * show a diff that adds or removes the object (see issue #4153). */
+ if (resolved_url2)
+ {
+ *url2 = resolved_url2;
+ if (!resolved_url1)
+ *url1 = resolved_url2;
+ }
+ if (resolved_url1)
+ {
+ *url1 = resolved_url1;
+ if (!resolved_url2)
+ *url2 = resolved_url1;
+ }
+
/* Reparent the session, since *URL2 might have changed as a result
the above call. */
SVN_ERR(svn_ra_reparent(*ra_session, *url2, pool));
@@ -1516,11 +1645,6 @@ diff_prepare_repos_repos(const char **ur
(path_or_url2 == *url2) ? NULL : abspath_or_url2,
*ra_session, revision2, pool));
SVN_ERR(svn_ra_check_path(*ra_session, "", *rev2, &kind2, pool));
- if (kind2 == svn_node_none)
- return svn_error_createf
- (SVN_ERR_FS_NOT_FOUND, NULL,
- _("'%s' was not found in the repository at revision %ld"),
- *url2, *rev2);
/* Do the same for the first target. */
SVN_ERR(svn_ra_reparent(*ra_session, *url1, pool));
@@ -1528,18 +1652,84 @@ diff_prepare_repos_repos(const char **ur
(strcmp(path_or_url1, *url1) == 0) ? NULL : abspath_or_url1,
*ra_session, revision1, pool));
SVN_ERR(svn_ra_check_path(*ra_session, "", *rev1, &kind1, pool));
- if (kind1 == svn_node_none)
- return svn_error_createf
- (SVN_ERR_FS_NOT_FOUND, NULL,
- _("'%s' was not found in the repository at revision %ld"),
- *url1, *rev1);
+
+ /* Either both URLs must exist at their respective revisions,
+ * or one of them may be missing from one side of the diff. */
+ if (kind1 == svn_node_none && kind2 == svn_node_none)
+ {
+ if (strcmp(*url1, *url2) == 0)
+ return svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
+ _("Diff target '%s' was not found in the "
+ "repository at revisions '%ld' and '%ld'"),
+ *url1, *rev1, *rev2);
+ else
+ return svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
+ _("Diff targets '%s' and '%s' were not found "
+ "in the repository at revisions '%ld' and "
+ "'%ld'"),
+ *url1, *url2, *rev1, *rev2);
+ }
+ else if (kind1 == svn_node_none)
+ SVN_ERR(check_diff_target_exists(*url1, *rev2, *rev1, *ra_session, pool));
+ else if (kind2 == svn_node_none)
+ SVN_ERR(check_diff_target_exists(*url2, *rev1, *rev2, *ra_session, pool));
/* Choose useful anchors and targets for our two URLs. */
*anchor1 = *url1;
*anchor2 = *url2;
*target1 = "";
*target2 = "";
- if ((kind1 == svn_node_file) || (kind2 == svn_node_file))
+ if ((kind1 == svn_node_none) || (kind2 == svn_node_none))
+ {
+ svn_node_kind_t kind;
+ const char *repos_root;
+ const char *new_anchor;
+ svn_revnum_t rev;
+
+ /* The diff target does not exist on one side of the diff.
+ * This can happen if the target was added or deleted within the
+ * revision range being diffed.
+ * However, we don't know how deep within a added/deleted subtree the
+ * diff target is. Find a common parent that exists on both sides of
+ * the diff and use it as anchor for the diff operation.
+ *
+ * ### This can fail due to authz restrictions (like in issue #3242).
+ * ### But it is the only option we have right now to try to get
+ * ### a usable diff in this situation. */
+
+ SVN_ERR(svn_ra_get_repos_root2(*ra_session, &repos_root, pool));
+
+ /* Since we already know that one of the URLs does exist,
+ * look for an existing parent of the URL which doesn't exist. */
+ new_anchor = (kind1 == svn_node_none ? *anchor1 : *anchor2);
+ rev = (kind1 == svn_node_none ? *rev1 : *rev2);
+ do
+ {
+ if (strcmp(new_anchor, repos_root) != 0)
+ {
+ new_anchor = svn_path_uri_decode(svn_uri_dirname(new_anchor,
+ pool),
+ pool);
+ if (*base_path)
+ *base_path = svn_dirent_dirname(*base_path, pool);
+ }
+
+ SVN_ERR(svn_ra_reparent(*ra_session, new_anchor, pool));
+ SVN_ERR(svn_ra_check_path(*ra_session, "", rev, &kind, pool));
+
+ }
+ while (kind != svn_node_dir);
+ *anchor1 = *anchor2 = new_anchor;
+ /* Diff targets must be relative to the new anchor. */
+ *target1 = svn_uri_skip_ancestor(new_anchor, *url1, pool);
+ *target2 = svn_uri_skip_ancestor(new_anchor, *url2, pool);
+ SVN_ERR_ASSERT(*target1 && *target2);
+ if (kind1 == svn_node_none)
+ kind1 = svn_node_dir;
+ else
+ kind2 = svn_node_dir;
+ }
+ else if ((kind1 == svn_node_file) || (kind2 == svn_node_file))
{
svn_uri_split(anchor1, target1, *url1, pool);
svn_uri_split(anchor2, target2, *url2, pool);
@@ -1591,6 +1781,478 @@ unsupported_diff_error(svn_error_t *chil
"that is not yet supported"));
}
+/* Try to get properties for LOCAL_ABSPATH and return them in the property
+ * hash *PROPS. If there are no properties because LOCAL_ABSPATH is not
+ * versioned, return an empty property hash. */
+static svn_error_t *
+get_props(apr_hash_t **props,
+ const char *local_abspath,
+ svn_wc_context_t *wc_ctx,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ svn_error_t *err;
+
+ err = svn_wc_prop_list2(props, wc_ctx, local_abspath, result_pool,
+ scratch_pool);
+ if (err)
+ {
+ if (err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND ||
+ err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY ||
+ err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED)
+ {
+ svn_error_clear(err);
+ *props = apr_hash_make(result_pool);
+ }
+ else
+ return svn_error_trace(err);
+ }
+
+ return SVN_NO_ERROR;
+}
+
+/* Produce a diff between two arbitrary files at LOCAL_ABSPATH1 and
+ * LOCAL_ABSPATH2, using the diff callbacks from CALLBACKS.
+ * Use PATH as the name passed to diff callbacks.
+ * FILE1_IS_EMPTY and FILE2_IS_EMPTY are used as hints which diff callback
+ * function to use to compare the files (added/deleted/changed).
+ *
+ * If ORIGINAL_PROPS_OVERRIDE is not NULL, use it as original properties
+ * instead of reading properties from LOCAL_ABSPATH1. This is required when
+ * a file replaces a directory, where LOCAL_ABSPATH1 is an empty file that
+ * file content must be diffed against, but properties to diff against come
+ * from the replaced directory. */
+static svn_error_t *
+do_arbitrary_files_diff(const char *local_abspath1,
+ const char *local_abspath2,
+ const char *path,
+ svn_boolean_t file1_is_empty,
+ svn_boolean_t file2_is_empty,
+ apr_hash_t *original_props_override,
+ const svn_wc_diff_callbacks4_t *callbacks,
+ struct diff_cmd_baton *diff_cmd_baton,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *scratch_pool)
+{
+ apr_hash_t *original_props;
+ apr_hash_t *modified_props;
+ apr_array_header_t *prop_changes;
+ svn_string_t *original_mime_type = NULL;
+ svn_string_t *modified_mime_type = NULL;
+
+ if (ctx->cancel_func)
+ SVN_ERR(ctx->cancel_func(ctx->cancel_baton));
+
+ if (diff_cmd_baton->ignore_prop_diff)
+ {
+ original_props = apr_hash_make(scratch_pool);
+ modified_props = apr_hash_make(scratch_pool);
+ }
+ else
+ {
+ /* Try to get properties from either file. It's OK if the files do not
+ * have properties, or if they are unversioned. */
+ if (original_props_override)
+ original_props = original_props_override;
+ else
+ SVN_ERR(get_props(&original_props, local_abspath1, ctx->wc_ctx,
+ scratch_pool, scratch_pool));
+ SVN_ERR(get_props(&modified_props, local_abspath2, ctx->wc_ctx,
+ scratch_pool, scratch_pool));
+ }
+
+ SVN_ERR(svn_prop_diffs(&prop_changes, modified_props, original_props,
+ scratch_pool));
+
+ if (!diff_cmd_baton->force_binary)
+ {
+ /* Try to determine the mime-type of each file. */
+ original_mime_type = apr_hash_get(original_props, SVN_PROP_MIME_TYPE,
+ APR_HASH_KEY_STRING);
+ if (!file1_is_empty && !original_mime_type)
+ {
+ const char *mime_type;
+ SVN_ERR(svn_io_detect_mimetype2(&mime_type, local_abspath1,
+ ctx->mimetypes_map, scratch_pool));
+
+ if (mime_type)
+ original_mime_type = svn_string_create(mime_type, scratch_pool);
+ }
+
+ modified_mime_type = apr_hash_get(modified_props, SVN_PROP_MIME_TYPE,
+ APR_HASH_KEY_STRING);
+ if (!file2_is_empty && !modified_mime_type)
+ {
+ const char *mime_type;
+ SVN_ERR(svn_io_detect_mimetype2(&mime_type, local_abspath1,
+ ctx->mimetypes_map, scratch_pool));
+
+ if (mime_type)
+ modified_mime_type = svn_string_create(mime_type, scratch_pool);
+ }
+ }
+
+ /* Produce the diff. */
+ if (file1_is_empty && !file2_is_empty)
+ SVN_ERR(callbacks->file_added(NULL, NULL, NULL, path,
+ local_abspath1, local_abspath2,
+ /* ### TODO get real revision info
+ * for versioned files? */
+ SVN_INVALID_REVNUM, SVN_INVALID_REVNUM,
+ original_mime_type ?
+ original_mime_type->data : NULL,
+ modified_mime_type ?
+ modified_mime_type->data : NULL,
+ /* ### TODO get copyfrom? */
+ NULL, SVN_INVALID_REVNUM,
+ prop_changes, original_props,
+ diff_cmd_baton, scratch_pool));
+ else if (!file1_is_empty && file2_is_empty)
+ SVN_ERR(callbacks->file_deleted(NULL, NULL, path,
+ local_abspath1, local_abspath2,
+ original_mime_type ?
+ original_mime_type->data : NULL,
+ modified_mime_type ?
+ modified_mime_type->data : NULL,
+ original_props,
+ diff_cmd_baton, scratch_pool));
+ else
+ SVN_ERR(callbacks->file_changed(NULL, NULL, NULL, path,
+ local_abspath1, local_abspath2,
+ /* ### TODO get real revision info
+ * for versioned files? */
+ SVN_INVALID_REVNUM, SVN_INVALID_REVNUM,
+ original_mime_type ?
+ original_mime_type->data : NULL,
+ modified_mime_type ?
+ modified_mime_type->data : NULL,
+ prop_changes, original_props,
+ diff_cmd_baton, scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
+struct arbitrary_diff_walker_baton {
+ /* The root directories of the trees being compared. */
+ const char *root1_abspath;
+ const char *root2_abspath;
+
+ /* TRUE if recursing within an added subtree of root2_abspath that
+ * does not exist in root1_abspath. */
+ svn_boolean_t recursing_within_added_subtree;
+
+ /* TRUE if recursing within an administrative (.i.e. .svn) directory. */
+ svn_boolean_t recursing_within_adm_dir;
+
+ /* The absolute path of the adm dir if RECURSING_WITHIN_ADM_DIR is TRUE.
+ * Else this is NULL.*/
+ const char *adm_dir_abspath;
+
+ /* A path to an empty file used for diffs that add/delete files. */
+ const char *empty_file_abspath;
+
+ const svn_wc_diff_callbacks4_t *callbacks;
+ struct diff_cmd_baton *callback_baton;
+ svn_client_ctx_t *ctx;
+ apr_pool_t *pool;
+} arbitrary_diff_walker_baton;
+
+/* Forward declaration needed because this function has a cyclic
+ * dependency with do_arbitrary_dirs_diff(). */
+static svn_error_t *
+arbitrary_diff_walker(void *baton, const char *local_abspath,
+ const apr_finfo_t *finfo,
+ apr_pool_t *scratch_pool);
+
+/* Produce a diff between two arbitrary directories at LOCAL_ABSPATH1 and
+ * LOCAL_ABSPATH2, using the provided diff callbacks to show file changes
+ * and, for versioned nodes, property changes.
+ *
+ * If ROOT_ABSPATH1 and ROOT_ABSPATH2 are not NULL, show paths in diffs
+ * relative to these roots, rather than relative to LOCAL_ABSPATH1 and
+ * LOCAL_ABSPATH2. This is needed when crawling a subtree that exists
+ * only within LOCAL_ABSPATH2. */
+static svn_error_t *
+do_arbitrary_dirs_diff(const char *local_abspath1,
+ const char *local_abspath2,
+ const char *root_abspath1,
+ const char *root_abspath2,
+ const svn_wc_diff_callbacks4_t *callbacks,
+ struct diff_cmd_baton *callback_baton,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *scratch_pool)
+{
+ apr_file_t *empty_file;
+ svn_node_kind_t kind1;
+
+ struct arbitrary_diff_walker_baton b;
+
+ /* If LOCAL_ABSPATH1 is not a directory, crawl LOCAL_ABSPATH2 instead
+ * and compare it to LOCAL_ABSPATH1, showing only additions.
+ * This case can only happen during recursion from arbitrary_diff_walker(),
+ * because do_arbitrary_nodes_diff() prevents this from happening at
+ * the root of the comparison. */
+ SVN_ERR(svn_io_check_resolved_path(local_abspath1, &kind1, scratch_pool));
+ b.recursing_within_added_subtree = (kind1 != svn_node_dir);
+
+ b.root1_abspath = root_abspath1 ? root_abspath1 : local_abspath1;
+ b.root2_abspath = root_abspath2 ? root_abspath2 : local_abspath2;
+ b.recursing_within_adm_dir = FALSE;
+ b.adm_dir_abspath = NULL;
+ b.callbacks = callbacks;
+ b.callback_baton = callback_baton;
+ b.ctx = ctx;
+ b.pool = scratch_pool;
+
+ SVN_ERR(svn_io_open_unique_file3(&empty_file, &b.empty_file_abspath,
+ NULL, svn_io_file_del_on_pool_cleanup,
+ scratch_pool, scratch_pool));
+
+ SVN_ERR(svn_io_dir_walk2(b.recursing_within_added_subtree ? local_abspath2
+ : local_abspath1,
+ 0, arbitrary_diff_walker, &b, scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
+/* An implementation of svn_io_walk_func_t.
+ * Note: LOCAL_ABSPATH is the path being crawled and can be on either side
+ * of the diff depending on baton->recursing_within_added_subtree. */
+static svn_error_t *
+arbitrary_diff_walker(void *baton, const char *local_abspath,
+ const apr_finfo_t *finfo,
+ apr_pool_t *scratch_pool)
+{
+ struct arbitrary_diff_walker_baton *b = baton;
+ const char *local_abspath1;
+ const char *local_abspath2;
+ svn_node_kind_t kind1;
+ svn_node_kind_t kind2;
+ const char *child_relpath;
+ apr_hash_t *dirents1;
+ apr_hash_t *dirents2;
+ apr_hash_t *merged_dirents;
+ apr_array_header_t *sorted_dirents;
+ int i;
+ apr_pool_t *iterpool;
+
+ if (b->ctx->cancel_func)
+ SVN_ERR(b->ctx->cancel_func(b->ctx->cancel_baton));
+
+ if (finfo->filetype != APR_DIR)
+ return SVN_NO_ERROR;
+
+ if (b->recursing_within_adm_dir)
+ {
+ if (svn_dirent_skip_ancestor(b->adm_dir_abspath, local_abspath))
+ return SVN_NO_ERROR;
+ else
+ {
+ b->recursing_within_adm_dir = FALSE;
+ b->adm_dir_abspath = NULL;
+ }
+ }
+ else if (strcmp(svn_dirent_basename(local_abspath, scratch_pool),
+ SVN_WC_ADM_DIR_NAME) == 0)
+ {
+ b->recursing_within_adm_dir = TRUE;
+ b->adm_dir_abspath = apr_pstrdup(b->pool, local_abspath);
+ return SVN_NO_ERROR;
+ }
+
+ if (b->recursing_within_added_subtree)
+ child_relpath = svn_dirent_skip_ancestor(b->root2_abspath, local_abspath);
+ else
+ child_relpath = svn_dirent_skip_ancestor(b->root1_abspath, local_abspath);
+ if (!child_relpath)
+ return SVN_NO_ERROR;
+
+ local_abspath1 = svn_dirent_join(b->root1_abspath, child_relpath,
+ scratch_pool);
+ SVN_ERR(svn_io_check_resolved_path(local_abspath1, &kind1, scratch_pool));
+
+ local_abspath2 = svn_dirent_join(b->root2_abspath, child_relpath,
+ scratch_pool);
+ SVN_ERR(svn_io_check_resolved_path(local_abspath2, &kind2, scratch_pool));
+
+ if (kind1 == svn_node_dir)
+ SVN_ERR(svn_io_get_dirents3(&dirents1, local_abspath1,
+ TRUE, /* only_check_type */
+ scratch_pool, scratch_pool));
+ else
+ dirents1 = apr_hash_make(scratch_pool);
+
+ if (kind2 == svn_node_dir)
+ {
+ apr_hash_t *original_props;
+ apr_hash_t *modified_props;
+ apr_array_header_t *prop_changes;
+
+ /* Show any property changes for this directory. */
+ SVN_ERR(get_props(&original_props, local_abspath1, b->ctx->wc_ctx,
+ scratch_pool, scratch_pool));
+ SVN_ERR(get_props(&modified_props, local_abspath2, b->ctx->wc_ctx,
+ scratch_pool, scratch_pool));
+ SVN_ERR(svn_prop_diffs(&prop_changes, modified_props, original_props,
+ scratch_pool));
+ if (prop_changes->nelts > 0)
+ SVN_ERR(diff_props_changed(NULL, NULL, child_relpath,
+ b->recursing_within_added_subtree,
+ prop_changes, original_props,
+ b->callback_baton, scratch_pool));
+
+ /* Read directory entries. */
+ SVN_ERR(svn_io_get_dirents3(&dirents2, local_abspath2,
+ TRUE, /* only_check_type */
+ scratch_pool, scratch_pool));
+ }
+ else
+ dirents2 = apr_hash_make(scratch_pool);
+
+ /* Compare dirents1 to dirents2 and show added/deleted/changed files. */
+ merged_dirents = apr_hash_merge(scratch_pool, dirents1, dirents2,
+ NULL, NULL);
+ sorted_dirents = svn_sort__hash(merged_dirents,
+ svn_sort_compare_items_as_paths,
+ scratch_pool);
+ iterpool = svn_pool_create(scratch_pool);
+ for (i = 0; i < sorted_dirents->nelts; i++)
+ {
+ svn_sort__item_t elt = APR_ARRAY_IDX(sorted_dirents, i, svn_sort__item_t);
+ const char *name = elt.key;
+ svn_io_dirent2_t *dirent1;
+ svn_io_dirent2_t *dirent2;
+ const char *child1_abspath;
+ const char *child2_abspath;
+
+ svn_pool_clear(iterpool);
+
+ if (b->ctx->cancel_func)
+ SVN_ERR(b->ctx->cancel_func(b->ctx->cancel_baton));
+
+ if (strcmp(name, SVN_WC_ADM_DIR_NAME) == 0)
+ continue;
+
+ dirent1 = apr_hash_get(dirents1, name, APR_HASH_KEY_STRING);
+ if (!dirent1)
+ {
+ dirent1 = svn_io_dirent2_create(iterpool);
+ dirent1->kind = svn_node_none;
+ }
+ dirent2 = apr_hash_get(dirents2, name, APR_HASH_KEY_STRING);
+ if (!dirent2)
+ {
+ dirent2 = svn_io_dirent2_create(iterpool);
+ dirent2->kind = svn_node_none;
+ }
+
+ child1_abspath = svn_dirent_join(local_abspath1, name, iterpool);
+ child2_abspath = svn_dirent_join(local_abspath2, name, iterpool);
+
+ if (dirent1->special)
+ SVN_ERR(svn_io_check_resolved_path(child1_abspath, &dirent1->kind,
+ iterpool));
+ if (dirent2->special)
+ SVN_ERR(svn_io_check_resolved_path(child1_abspath, &dirent2->kind,
+ iterpool));
+
+ if (dirent1->kind == svn_node_dir &&
+ dirent2->kind == svn_node_dir)
+ continue;
+
+ /* Files that exist only in dirents1. */
+ if (dirent1->kind == svn_node_file &&
+ (dirent2->kind == svn_node_dir || dirent2->kind == svn_node_none))
+ SVN_ERR(do_arbitrary_files_diff(child1_abspath, b->empty_file_abspath,
+ svn_relpath_join(child_relpath, name,
+ iterpool),
+ FALSE, TRUE, NULL,
+ b->callbacks, b->callback_baton,
+ b->ctx, iterpool));
+
+ /* Files that exist only in dirents2. */
+ if (dirent2->kind == svn_node_file &&
+ (dirent1->kind == svn_node_dir || dirent1->kind == svn_node_none))
+ {
+ apr_hash_t *original_props;
+
+ SVN_ERR(get_props(&original_props, child1_abspath, b->ctx->wc_ctx,
+ scratch_pool, scratch_pool));
+ SVN_ERR(do_arbitrary_files_diff(b->empty_file_abspath, child2_abspath,
+ svn_relpath_join(child_relpath, name,
+ iterpool),
+ TRUE, FALSE, original_props,
+ b->callbacks, b->callback_baton,
+ b->ctx, iterpool));
+ }
+
+ /* Files that exist in dirents1 and dirents2. */
+ if (dirent1->kind == svn_node_file && dirent2->kind == svn_node_file)
+ SVN_ERR(do_arbitrary_files_diff(child1_abspath, child2_abspath,
+ svn_relpath_join(child_relpath, name,
+ iterpool),
+ FALSE, FALSE, NULL,
+ b->callbacks, b->callback_baton,
+ b->ctx, scratch_pool));
+
+ /* Directories that only exist in dirents2. These aren't crawled
+ * by this walker so we have to crawl them separately. */
+ if (dirent2->kind == svn_node_dir &&
+ (dirent1->kind == svn_node_file || dirent1->kind == svn_node_none))
+ SVN_ERR(do_arbitrary_dirs_diff(child1_abspath, child2_abspath,
+ b->root1_abspath, b->root2_abspath,
+ b->callbacks, b->callback_baton,
+ b->ctx, iterpool));
+ }
+
+ svn_pool_destroy(iterpool);
+
+ return SVN_NO_ERROR;
+}
+
+/* Produce a diff between two files or two directories at LOCAL_ABSPATH1
+ * and LOCAL_ABSPATH2, using the provided diff callbacks to show changes
+ * in files. The files and directories involved may be part of a working
+ * copy or they may be unversioned. For versioned files, show property
+ * changes, too. */
+static svn_error_t *
+do_arbitrary_nodes_diff(const char *local_abspath1,
+ const char *local_abspath2,
+ const svn_wc_diff_callbacks4_t *callbacks,
+ struct diff_cmd_baton *callback_baton,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *scratch_pool)
+{
+ svn_node_kind_t kind1;
+ svn_node_kind_t kind2;
+
+ SVN_ERR(svn_io_check_resolved_path(local_abspath1, &kind1, scratch_pool));
+ SVN_ERR(svn_io_check_resolved_path(local_abspath2, &kind2, scratch_pool));
+ if (kind1 != kind2)
+ return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
+ _("'%s' is not the same node kind as '%s'"),
+ local_abspath1, local_abspath2);
+
+ if (kind1 == svn_node_file)
+ SVN_ERR(do_arbitrary_files_diff(local_abspath1, local_abspath2,
+ svn_dirent_basename(local_abspath2,
+ scratch_pool),
+ FALSE, FALSE, NULL,
+ callbacks, callback_baton,
+ ctx, scratch_pool));
+ else if (kind1 == svn_node_dir)
+ SVN_ERR(do_arbitrary_dirs_diff(local_abspath1, local_abspath2,
+ NULL, NULL,
+ callbacks, callback_baton,
+ ctx, scratch_pool));
+ else
+ return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
+ _("'%s' is not a file or directory"),
+ kind1 == svn_node_none ?
+ local_abspath1 : local_abspath2);
+ return SVN_NO_ERROR;
+}
+
/* Perform a diff between two working-copy paths.
@@ -1622,16 +2284,18 @@ diff_wc_wc(const char *path1,
SVN_ERR(svn_dirent_get_absolute(&abspath1, path1, pool));
- /* Currently we support only the case where path1 and path2 are the
- same path. */
if ((strcmp(path1, path2) != 0)
|| (! ((revision1->kind == svn_opt_revision_base)
&& (revision2->kind == svn_opt_revision_working))))
- return unsupported_diff_error
- (svn_error_create
- (SVN_ERR_INCORRECT_PARAMS, NULL,
- _("Only diffs between a path's text-base "
- "and its working files are supported at this time")));
+ {
+ const char *abspath2;
+
+ SVN_ERR(svn_dirent_get_absolute(&abspath2, path2, pool));
+ return svn_error_trace(do_arbitrary_nodes_diff(abspath1, abspath2,
+ callbacks,
+ callback_baton,
+ ctx, pool));
+ }
/* Resolve named revisions to real numbers. */
err = svn_client__get_revision_number(&callback_baton->revnum1, NULL,
@@ -1870,7 +2534,7 @@ diff_repos_wc(const char *path_or_url1,
SVN_ERR(svn_ra_has_capability(ra_session, &server_supports_depth,
SVN_RA_CAPABILITY_DEPTH, pool));
- SVN_ERR(svn_wc_get_diff_editor6(&diff_editor, &diff_edit_baton,
+ SVN_ERR(svn_wc__get_diff_editor(&diff_editor, &diff_edit_baton,
ctx->wc_ctx,
anchor_abspath,
target,
@@ -2027,8 +2691,8 @@ diff_summarize_wc_wc(svn_client_diff_sum
return unsupported_diff_error
(svn_error_create
(SVN_ERR_INCORRECT_PARAMS, NULL,
- _("Only diffs between a path's text-base "
- "and its working files are supported at this time")));
+ _("Summarized diffs are only supported between a path's text-base "
+ "and its working files at this time")));
/* Find the node kind of PATH1 so that we know whether the diff drive will
be anchored at PATH1 or its parent dir. */
@@ -2280,6 +2944,7 @@ svn_client_diff6(const apr_array_header_
svn_boolean_t no_diff_deleted,
svn_boolean_t show_copies_as_adds,
svn_boolean_t ignore_content_type,
+ svn_boolean_t ignore_prop_diff,
svn_boolean_t use_git_diff_format,
const char *header_encoding,
svn_stream_t *outstream,
@@ -2309,6 +2974,7 @@ svn_client_diff6(const apr_array_header_
diff_cmd_baton.force_empty = FALSE;
diff_cmd_baton.force_binary = ignore_content_type;
+ diff_cmd_baton.ignore_prop_diff = ignore_prop_diff;
diff_cmd_baton.relative_to_dir = relative_to_dir;
diff_cmd_baton.use_git_diff_format = use_git_diff_format;
diff_cmd_baton.no_diff_deleted = no_diff_deleted;
@@ -2337,6 +3003,7 @@ svn_client_diff_peg6(const apr_array_hea
svn_boolean_t no_diff_deleted,
svn_boolean_t show_copies_as_adds,
svn_boolean_t ignore_content_type,
+ svn_boolean_t ignore_prop_diff,
svn_boolean_t use_git_diff_format,
const char *header_encoding,
svn_stream_t *outstream,
@@ -2362,6 +3029,7 @@ svn_client_diff_peg6(const apr_array_hea
diff_cmd_baton.force_empty = FALSE;
diff_cmd_baton.force_binary = ignore_content_type;
+ diff_cmd_baton.ignore_prop_diff = ignore_prop_diff;
diff_cmd_baton.relative_to_dir = relative_to_dir;
diff_cmd_baton.use_git_diff_format = use_git_diff_format;
diff_cmd_baton.no_diff_deleted = no_diff_deleted;
Modified: subversion/branches/javahl-ra/subversion/libsvn_client/export.c
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_client/export.c?rev=1329209&r1=1329208&r2=1329209&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_client/export.c (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_client/export.c Mon Apr 23 12:32:48 2012
@@ -42,6 +42,7 @@
#include "client.h"
#include "svn_private_config.h"
+#include "private/svn_subr_private.h"
#include "private/svn_wc_private.h"
@@ -402,7 +403,7 @@ copy_versioned_files(const char *from_ab
const char *repos_relpath;
SVN_ERR(svn_wc__node_get_origin(&is_added, NULL, &repos_relpath,
- NULL, NULL,
+ NULL, NULL, NULL,
ctx->wc_ctx, from_abspath, FALSE,
pool, pool));
@@ -957,8 +958,7 @@ close_file(void *file_baton,
SVN_ERR(svn_checksum_parse_hex(&text_checksum, svn_checksum_md5, text_digest,
pool));
- actual_checksum = svn_checksum__from_digest(fb->text_digest,
- svn_checksum_md5, pool);
+ actual_checksum = svn_checksum__from_digest_md5(fb->text_digest, pool);
/* Note that text_digest can be NULL when talking to certain repositories.
In that case text_checksum will be NULL and the following match code
@@ -1020,6 +1020,55 @@ close_file(void *file_baton,
return SVN_NO_ERROR;
}
+static svn_error_t *
+fetch_kind_func(svn_kind_t *kind,
+ void *baton,
+ const char *path,
+ svn_revnum_t base_revision,
+ apr_pool_t *scratch_pool)
+{
+ /* We know the root of the edit is a directory. */
+ if (path[0] == '\0')
+ *kind = svn_kind_dir;
+
+ /* ### TODO: We could possibly fetch the kind of the object in question
+ from the server with a second ra_session, but right now this
+ seems to work. */
+ else
+ *kind = svn_kind_unknown;
+
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fetch_props_func(apr_hash_t **props,
+ void *baton,
+ const char *path,
+ svn_revnum_t base_revision,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ /* Always use empty props, since the node won't have pre-existing props
+ (This is an export, remember?) */
+ *props = apr_hash_make(result_pool);
+
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fetch_base_func(const char **filename,
+ void *baton,
+ const char *path,
+ svn_revnum_t base_revision,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ /* An export always gets text against the empty stream (i.e, full texts). */
+ *filename = NULL;
+
+ return SVN_NO_ERROR;
+}
+
/*** Public Interfaces ***/
@@ -1180,9 +1229,15 @@ svn_client_export5(svn_revnum_t *result_
&edit_baton,
pool));
+ shim_callbacks->fetch_kind_func = fetch_kind_func;
+ shim_callbacks->fetch_props_func = fetch_props_func;
+ shim_callbacks->fetch_base_func = fetch_base_func;
+ shim_callbacks->fetch_baton = eb;
+
SVN_ERR(svn_editor__insert_shims(&export_editor, &edit_baton,
export_editor, edit_baton,
- shim_callbacks, pool, pool));
+ NULL, NULL, shim_callbacks,
+ pool, pool));
/* Manufacture a basic 'report' to the update reporter. */
SVN_ERR(svn_ra_do_update2(ra_session,