You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2015/10/21 13:47:24 UTC
svn commit: r1709806 - in /subversion/branches/move-tracking-2/subversion:
include/private/svn_editor3e.h libsvn_delta/editor3e.c svnmover/svnmover.c
Author: julianfoad
Date: Wed Oct 21 11:47:24 2015
New Revision: 1709806
URL: http://svn.apache.org/viewvc?rev=1709806&view=rev
Log:
On the 'move-tracking-2' branch: Replace the 'change detection editor' with
a simpler and more definite change detector.
* subversion/include/private/svn_editor3e.h,
subversion/libsvn_delta/editor3e.c
(svn_editor3__change_detection_editor): Delete, along with the local
struct and functions implementating it.
* subversion/svnmover/svnmover.c
(element_differences): Change the input data type.
(txn_is_changed): New.
(wc_commit): Use 'txn_is_changed' instead of the change detection editor.
(branch_merge_subtree_r,
subtree_diff): Track the change to 'element_differences'.
Modified:
subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h
subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c
subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
Modified: subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h?rev=1709806&r1=1709805&r2=1709806&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h (original)
+++ subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h Wed Oct 21 11:47:24 2015
@@ -1032,16 +1032,6 @@ svn_editor3__get_debug_editor(svn_editor
apr_pool_t *result_pool);
#endif
-/* After driving this editor, *CHANGE_DETECTED will be true iff an editor
- * method was called that can make a change. This does not necessarily mean
- * a non-empty change was actually made.
- */
-svn_error_t *
-svn_editor3__change_detection_editor(svn_editor3_t **editor_p,
- svn_boolean_t *change_detected,
- svn_editor3_t *wrapped_editor,
- apr_pool_t *result_pool);
-
/** Callback to retrieve a node's kind and content. This is
* needed by the various editor shims in order to effect backwards
* compatibility.
Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c?rev=1709806&r1=1709805&r2=1709806&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c Wed Oct 21 11:47:24 2015
@@ -665,209 +665,3 @@ svn_editor3__get_debug_editor(svn_editor
}
#endif
-
-/*
- * ===================================================================
- */
-
-typedef struct change_detection_baton_t
-{
- svn_editor3_t *wrapped_editor;
-
- svn_boolean_t *change_detected;
-
-} change_detection_baton_t;
-
-static svn_error_t *
-change_detection_new_eid(void *baton,
- svn_branch_eid_t *eid_p,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- SVN_ERR(svn_editor3_new_eid(eb->wrapped_editor,
- eid_p));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_open_branch(void *baton,
- const char **new_branch_id_p,
- svn_branch_rev_bid_t *predecessor,
- const char *outer_branch_id,
- int outer_eid,
- int root_eid,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- SVN_ERR(svn_editor3_open_branch(eb->wrapped_editor,
- new_branch_id_p,
- predecessor,
- outer_branch_id, outer_eid, root_eid,
- result_pool));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_branch(void *baton,
- const char **new_branch_id_p,
- svn_branch_rev_bid_eid_t *from,
- const char *outer_branch_id,
- int outer_eid,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- SVN_ERR(svn_editor3_branch(eb->wrapped_editor,
- new_branch_id_p,
- from, outer_branch_id, outer_eid,
- result_pool));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_alter(void *baton,
- const char *branch_id,
- svn_branch_eid_t eid,
- svn_branch_eid_t new_parent_eid,
- const char *new_name,
- const svn_element_payload_t *new_payload,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- *eb->change_detected = TRUE;
- SVN_ERR(svn_editor3_alter(eb->wrapped_editor,
- branch_id, eid,
- new_parent_eid, new_name, new_payload));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_copy_one(void *baton,
- const svn_branch_rev_bid_eid_t *src_el_rev,
- const char *branch_id,
- svn_branch_eid_t local_eid,
- svn_branch_eid_t new_parent_eid,
- const char *new_name,
- const svn_element_payload_t *new_payload,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- *eb->change_detected = TRUE;
- SVN_ERR(svn_editor3_copy_one(eb->wrapped_editor,
- src_el_rev,
- branch_id, local_eid,
- new_parent_eid, new_name, new_payload));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_copy_tree(void *baton,
- const svn_branch_rev_bid_eid_t *src_el_rev,
- const char *branch_id,
- svn_branch_eid_t new_parent_eid,
- const char *new_name,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- *eb->change_detected = TRUE;
- SVN_ERR(svn_editor3_copy_tree(eb->wrapped_editor,
- src_el_rev,
- branch_id, new_parent_eid, new_name));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_delete(void *baton,
- const char *branch_id,
- svn_branch_eid_t eid,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- *eb->change_detected = TRUE;
- SVN_ERR(svn_editor3_delete(eb->wrapped_editor,
- branch_id, eid));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_payload_resolve(void *baton,
- svn_element_content_t *element,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- SVN_ERR(svn_editor3_payload_resolve(eb->wrapped_editor,
- element));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_sequence_point(void *baton,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- SVN_ERR(svn_editor3_sequence_point(eb->wrapped_editor));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_complete(void *baton,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- SVN_ERR(svn_editor3_complete(eb->wrapped_editor));
- return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-change_detection_abort(void *baton,
- apr_pool_t *scratch_pool)
-{
- change_detection_baton_t *eb = baton;
-
- SVN_ERR(svn_editor3_abort(eb->wrapped_editor));
- return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_editor3__change_detection_editor(svn_editor3_t **editor_p,
- svn_boolean_t *change_detected,
- svn_editor3_t *wrapped_editor,
- apr_pool_t *result_pool)
-{
- static const svn_editor3_cb_funcs_t wrapper_funcs = {
- change_detection_new_eid,
- change_detection_open_branch,
- change_detection_branch,
- change_detection_alter,
- change_detection_copy_one,
- change_detection_copy_tree,
- change_detection_delete,
- change_detection_payload_resolve,
- change_detection_sequence_point,
- change_detection_complete,
- change_detection_abort
- };
- change_detection_baton_t *eb = apr_palloc(result_pool, sizeof(*eb));
-
- eb->wrapped_editor = wrapped_editor;
- eb->change_detected = change_detected;
- *change_detected = FALSE;
-
- *editor_p = svn_editor3_create(&wrapper_funcs, eb,
- NULL, NULL, /* cancellation */
- result_pool);
-
- return SVN_NO_ERROR;
-}
-
Modified: subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c?rev=1709806&r1=1709805&r2=1709806&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Wed Oct 21 11:47:24 2015
@@ -273,8 +273,8 @@ wc_create(svnmover_wc_t **wc_p,
static svn_error_t *
element_differences(apr_hash_t **diff_p,
svn_editor3_t *editor,
- svn_branch_subtree_t *left,
- svn_branch_subtree_t *right,
+ const svn_element_tree_t *left,
+ const svn_element_tree_t *right,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
@@ -288,13 +288,13 @@ element_differences(apr_hash_t **diff_p,
for (SVN_HASH_ITER(hi, scratch_pool,
apr_hash_overlay(scratch_pool,
- left->tree->e_map, right->tree->e_map)))
+ left->e_map, right->e_map)))
{
int e = svn_int_hash_this_key(hi->apr_hi);
svn_element_content_t *element_left
- = svn_element_tree_get(left->tree, e);
+ = svn_element_tree_get(left, e);
svn_element_content_t *element_right
- = svn_element_tree_get(right->tree, e);
+ = svn_element_tree_get(right, e);
/* If node payload is given by reference, resolve it to full payload */
if (element_left)
@@ -322,6 +322,69 @@ element_differences(apr_hash_t **diff_p,
return SVN_NO_ERROR;
}
+/* Set *IS_CHANGED to true if EDIT_TXN differs from its base txn, else to
+ * false.
+ */
+static svn_error_t *
+txn_is_changed(svn_editor3_t *editor,
+ svn_branch_txn_t *edit_txn,
+ svn_boolean_t *is_changed,
+ apr_pool_t *scratch_pool)
+{
+ SVN_ITER_T(svn_branch_state_t) *bi;
+ svn_branch_txn_t *base_txn
+ = svn_branch_repos_get_base_revision_root(edit_txn);
+ apr_array_header_t *edit_branches
+ = svn_branch_txn_get_branches(edit_txn, scratch_pool);
+ apr_array_header_t *base_branches
+ = svn_branch_txn_get_branches(base_txn, scratch_pool);
+
+ *is_changed = FALSE;
+
+ /* If any previous branch is now missing, that's a change. */
+ for (SVN_ARRAY_ITER(bi, base_branches, scratch_pool))
+ {
+ svn_branch_state_t *base_branch = bi->val;
+ svn_branch_state_t *edit_branch
+ = svn_branch_txn_get_branch_by_id(edit_txn, base_branch->bid,
+ scratch_pool);
+
+ if (! edit_branch)
+ {
+ *is_changed = TRUE;
+ return SVN_NO_ERROR;
+ }
+ }
+
+ /* If any current branch is new or changed, that's a change. */
+ for (SVN_ARRAY_ITER(bi, edit_branches, scratch_pool))
+ {
+ svn_branch_state_t *edit_branch = bi->val;
+ svn_branch_state_t *base_branch
+ = svn_branch_txn_get_branch_by_id(base_txn, edit_branch->bid,
+ scratch_pool);
+ apr_hash_t *diff;
+
+ if (! base_branch)
+ {
+ *is_changed = TRUE;
+ return SVN_NO_ERROR;
+ }
+
+ SVN_ERR(element_differences(&diff, editor,
+ svn_branch_get_element_tree(edit_branch),
+ svn_branch_get_element_tree(base_branch),
+ scratch_pool, scratch_pool));
+ if (apr_hash_count(diff))
+ {
+ *is_changed = TRUE;
+ return SVN_NO_ERROR;
+ }
+ }
+
+ return SVN_NO_ERROR;
+}
+
/* Replay differences between S_LEFT and S_RIGHT into EDITOR:EDIT_BRANCH.
*
* S_LEFT and/or S_RIGHT may be null meaning an empty set.
@@ -344,7 +407,7 @@ subtree_replay(svn_editor3_t *editor,
s_right = svn_branch_subtree_create(NULL, 0 /*root_eid*/, scratch_pool);
SVN_ERR(element_differences(&diff_left_right,
- editor, s_left, s_right,
+ editor, s_left->tree, s_right->tree,
scratch_pool, scratch_pool));
/* Go through the per-element differences. */
@@ -575,10 +638,6 @@ wc_commit(svn_revnum_t *new_rev_p,
NULL /*lock_tokens*/, FALSE /*keep_locks*/,
branch_info_dir,
scratch_pool));
- SVN_ERR(svn_editor3__change_detection_editor(&commit_editor,
- &change_detected,
- commit_editor,
- scratch_pool));
/*SVN_ERR(svn_editor3__get_debug_editor(&wc->editor, wc->editor, scratch_pool));*/
edit_root_branch_id = wc->working->branch_id;
@@ -608,6 +667,8 @@ wc_commit(svn_revnum_t *new_rev_p,
wc->base->branch,
wc->working->branch,
scratch_pool));
+ SVN_ERR(txn_is_changed(commit_editor, commit_txn, &change_detected,
+ scratch_pool));
if (change_detected)
{
ccbb.edit_txn = commit_txn;
@@ -1541,12 +1602,12 @@ branch_merge_subtree_r(svn_editor3_t *ed
s_tgt = svn_branch_get_subtree(tgt->branch, tgt->eid, scratch_pool);
s_yca = svn_branch_get_subtree(yca->branch, yca->eid, scratch_pool);
SVN_ERR(element_differences(&diff_yca_src,
- editor, s_yca, s_src,
+ editor, s_yca->tree, s_src->tree,
scratch_pool, scratch_pool));
/* ### We only need to query for YCA:TO differences in elements that are
different in YCA:FROM, but right now we ask for all differences. */
SVN_ERR(element_differences(&diff_yca_tgt,
- editor, s_yca, s_tgt,
+ editor, s_yca->tree, s_tgt->tree,
scratch_pool, scratch_pool));
all_elements = apr_hash_overlay(scratch_pool,
@@ -1804,7 +1865,7 @@ subtree_diff(apr_hash_t **diff_changes,
*diff_changes = apr_hash_make(result_pool);
SVN_ERR(element_differences(&diff_left_right,
- editor, s_left, s_right,
+ editor, s_left->tree, s_right->tree,
result_pool, scratch_pool));
for (hi = apr_hash_first(scratch_pool, diff_left_right);