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/11/03 19:13:47 UTC

svn commit: r1712362 - in /subversion/branches/move-tracking-2/subversion: libsvn_delta/branch.c svnmover/svnmover.c

Author: julianfoad
Date: Tue Nov  3 18:13:47 2015
New Revision: 1712362

URL: http://svn.apache.org/viewvc?rev=1712362&view=rev
Log:
On the 'move-tracking-2' branch: Make 'svnmover' more strict about
'flattening' a branch state into a proper tree and only querying for paths
when it is 'flat'.

* subversion/libsvn_delta/branch.c
  (svn_branch_state_priv_t): Add an 'is_flat' flag.
  (branch_txn_branch,
   branch_state_purge,
   branch_state_create,
   svn_branch_state_parse): Mark the branch state as 'flat'.
  (branch_map_set): Mark the branch state as 'not flat'.
  (svn_branch_get_element_tree_at_eid,
   svn_branch_get_path_by_eid,
   svn_branch_get_eid_by_path): Assert the branch state is 'flat'

* subversion/svnmover/svnmover.c
  (do_copy,
   do_mkdir,
   do_put_file,
   mk_branch,
   do_branch,
   do_branch_into,
   do_copy_and_delete,
   do_branch_and_delete,
   do_branch_into_and_delete,
   do_move): Always calculate the paths for display before modifying the
    branch.

Modified:
    subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c
    subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c

Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c?rev=1712362&r1=1712361&r2=1712362&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c Tue Nov  3 18:13:47 2015
@@ -70,6 +70,8 @@ struct svn_branch_state_priv_t
   /* EID -> svn_branch_el_rev_content_t mapping. */
   svn_element_tree_t *element_tree;
 
+  svn_boolean_t is_flat;
+
 };
 
 static svn_branch_state_t *
@@ -282,6 +284,7 @@ branch_txn_branch(svn_branch_txn_t *txn,
   /* Populate the mapping from the 'from' source */
   SVN_ERR(svn_branch_instantiate_elements(new_branch, from_subtree,
                                           scratch_pool));
+  new_branch->priv->is_flat = TRUE;
 
   if (new_branch_p)
     *new_branch_p = new_branch;
@@ -985,6 +988,7 @@ branch_map_set(svn_branch_state_t *branc
     branch_validate_element(branch, eid, element);
 
   svn_element_tree_set(branch->priv->element_tree, eid, element);
+  branch->priv->is_flat = FALSE;
   assert_branch_state_invariants(branch, map_pool);
 }
 
@@ -1046,7 +1050,7 @@ svn_branch_get_element_tree_at_eid(svn_b
   svn_element_tree_t *new_subtree;
   svn_element_content_t *subtree_root_element;
 
-  SVN_BRANCH_SEQUENCE_POINT(branch);
+  SVN_ERR_ASSERT_NO_RETURN(branch->priv->is_flat);
 
   new_subtree = svn_element_tree_create(branch->priv->element_tree->e_map, eid,
                                         result_pool);
@@ -1073,6 +1077,7 @@ branch_state_purge(svn_branch_state_t *b
   svn_element_tree_purge_orphans(branch->priv->element_tree->e_map,
                                  branch->priv->element_tree->root_eid,
                                  scratch_pool);
+  branch->priv->is_flat = TRUE;
   return SVN_NO_ERROR;
 }
 
@@ -1085,6 +1090,7 @@ svn_branch_get_path_by_eid(const svn_bra
   svn_element_content_t *element;
 
   SVN_ERR_ASSERT_NO_RETURN(EID_IS_ALLOCATED(branch, eid));
+  SVN_ERR_ASSERT_NO_RETURN(branch->priv->is_flat);
 
   for (; ! IS_BRANCH_ROOT_EID(branch, eid); eid = element->parent_eid)
     {
@@ -1104,6 +1110,8 @@ svn_branch_get_eid_by_path(const svn_bra
 {
   apr_hash_index_t *hi;
 
+  SVN_ERR_ASSERT_NO_RETURN(branch->priv->is_flat);
+
   /* ### This is a crude, linear search */
   for (hi = apr_hash_first(scratch_pool, branch->priv->element_tree->e_map);
        hi; hi = apr_hash_next(hi))
@@ -1303,6 +1311,7 @@ branch_state_create(const char *bid,
   b->txn = txn;
   b->priv->element_tree = svn_element_tree_create(NULL, root_eid, result_pool);
   assert_branch_state_invariants(b, result_pool);
+  b->priv->is_flat = TRUE;
   return b;
 }
 
@@ -1479,6 +1488,7 @@ svn_branch_state_parse(svn_branch_state_
         }
     }
 
+  branch_state->priv->is_flat = TRUE;
   *new_branch = branch_state;
   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=1712362&r1=1712361&r2=1712362&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Tue Nov  3 18:13:47 2015
@@ -1716,14 +1716,15 @@ do_copy(svn_branch_el_rev_id_t *from_el_
   svn_branch_rev_bid_eid_t *src_el_rev
     = svn_branch_rev_bid_eid_create(from_el_rev->rev, from_branch_id,
                                     from_el_rev->eid, scratch_pool);
+  const char *from_path = el_rev_id_to_path(from_el_rev, scratch_pool);
+  const char *to_path = branch_peid_name_to_path(to_branch, to_parent_eid,
+                                                 new_name, scratch_pool);
 
   SVN_ERR(svn_branch_state_copy_tree(to_branch,
                                      src_el_rev, to_parent_eid, new_name,
                                      scratch_pool));
   svnmover_notify_v("A+   %s (from %s)",
-                    branch_peid_name_to_path(to_branch, to_parent_eid, new_name,
-                                             scratch_pool),
-                    el_rev_id_to_path(from_el_rev, scratch_pool));
+                    to_path, from_path);
 
   return SVN_NO_ERROR;
 }
@@ -1753,14 +1754,15 @@ do_mkdir(svn_branch_txn_t *txn,
   svn_element_payload_t *payload
     = svn_element_payload_create_dir(props, scratch_pool);
   int new_eid;
+  const char *path = branch_peid_name_to_path(to_branch, to_parent_eid,
+                                              new_name, scratch_pool);
 
   SVN_ERR(svn_branch_txn_new_eid(txn, &new_eid, scratch_pool));
   SVN_ERR(svn_branch_state_alter_one(to_branch, new_eid,
                                      to_parent_eid, new_name, payload,
                                      scratch_pool));
   svnmover_notify_v("A    %s",
-                    branch_peid_name_to_path(to_branch, to_parent_eid, new_name,
-                                             scratch_pool));
+                    path);
   return SVN_NO_ERROR;
 }
 
@@ -1819,15 +1821,20 @@ do_put_file(svn_branch_txn_t *txn,
 
   if (file_el_rev->eid != -1)
     {
+      const char *path = el_rev_id_to_path(file_el_rev, scratch_pool);
+
       SVN_ERR(svn_branch_state_alter_one(file_el_rev->branch, file_el_rev->eid,
                                          parent_eid, name, payload,
                                          scratch_pool));
       svnmover_notify_v("M    %s",
-                        el_rev_id_to_path(file_el_rev, scratch_pool));
+                        path);
     }
   else
     {
       int new_eid;
+      const char *path
+        = branch_peid_name_to_path(parent_el_rev->branch, parent_eid, name,
+                                   scratch_pool);
 
       SVN_ERR(svn_branch_txn_new_eid(txn, &new_eid, scratch_pool));
       SVN_ERR(svn_branch_state_alter_one(parent_el_rev->branch, new_eid,
@@ -1835,7 +1842,7 @@ do_put_file(svn_branch_txn_t *txn,
                                          scratch_pool));
       file_el_rev->eid = new_eid;
       svnmover_notify_v("A    %s",
-                        el_rev_id_to_path(file_el_rev, scratch_pool));
+                        path);
     }
   return SVN_NO_ERROR;
 }
@@ -1954,6 +1961,8 @@ mk_branch(const char **new_branch_id_p,
   int new_outer_eid, new_inner_eid;
   const char *new_branch_id;
   svn_branch_state_t *new_branch;
+  const char *path = branch_peid_name_to_path(outer_branch, outer_parent_eid,
+                                              outer_name, scratch_pool);
 
   SVN_ERR(svn_branch_txn_new_eid(txn, &new_outer_eid, scratch_pool));
   SVN_ERR(svn_branch_state_alter_one(outer_branch, new_outer_eid,
@@ -1971,8 +1980,7 @@ mk_branch(const char **new_branch_id_p,
                                      -1, "", payload, scratch_pool));
 
   svnmover_notify_v("A    %s (branch %s)",
-                    svn_branch_get_path_by_eid(outer_branch, new_outer_eid,
-                                               scratch_pool),
+                    path,
                     new_branch->bid);
   if (new_branch_id_p)
     *new_branch_id_p = new_branch->bid;
@@ -2006,6 +2014,9 @@ do_branch(svn_branch_state_t **new_branc
   int to_outer_eid;
   const char *new_branch_id;
   svn_branch_state_t *new_branch;
+  const char *to_path
+    = branch_peid_name_to_path(to_outer_branch,
+                               to_outer_parent_eid, new_name, scratch_pool);
 
   /* assign new eid to root element (outer branch) */
   SVN_ERR(svn_branch_txn_new_eid(txn, &to_outer_eid, scratch_pool));
@@ -2021,8 +2032,7 @@ do_branch(svn_branch_state_t **new_branc
                                        scratch_pool), scratch_pool));
 
   svnmover_notify_v("A+   %s (branch %s)",
-                    svn_branch_get_path_by_eid(to_outer_branch, to_outer_eid,
-                                               scratch_pool),
+                    to_path,
                     new_branch->bid);
 
   if (new_branch_p)
@@ -2077,6 +2087,8 @@ do_branch_into(svn_branch_state_t *from_
 {
   svn_branch_subtree_t *from_subtree;
   svn_element_content_t *new_root_content;
+  const char *to_path = branch_peid_name_to_path(to_branch, to_parent_eid,
+                                                 new_name, scratch_pool);
 
   /* Source element must exist */
   if (! svn_branch_get_path_by_eid(from_branch, from_eid, scratch_pool))
@@ -2103,8 +2115,7 @@ do_branch_into(svn_branch_state_t *from_
   SVN_ERR(svn_branch_instantiate_elements_r(to_branch, *from_subtree,
                                             scratch_pool));
   svnmover_notify_v("A+   %s (subtree)",
-                    svn_branch_get_path_by_eid(to_branch, from_eid,
-                                               scratch_pool));
+                    to_path);
 
   return SVN_NO_ERROR;
 }
@@ -2121,11 +2132,18 @@ do_copy_and_delete(svn_branch_el_rev_id_
                    const char *to_name,
                    apr_pool_t *scratch_pool)
 {
+  const char *from_path
+    = svn_branch_get_rrpath_by_eid(el_rev->branch, el_rev->eid, scratch_pool);
+
   SVN_ERR_ASSERT(! is_branch_root_element(el_rev->branch, el_rev->eid));
 
   SVN_ERR(do_copy(el_rev, to_branch, to_parent_eid, to_name,
                   scratch_pool));
-  SVN_ERR(do_delete(el_rev->branch, el_rev->eid, scratch_pool));
+
+  SVN_ERR(svn_branch_state_delete_one(el_rev->branch, el_rev->eid,
+                                      scratch_pool));
+  svnmover_notify_v("D    %s", from_path);
+
   return SVN_NO_ERROR;
 }
 
@@ -2150,6 +2168,8 @@ do_branch_and_delete(svn_branch_txn_t *e
     = svn_branch_rev_bid_eid_create(el_rev->rev, from_branch_id,
                                     el_rev->eid, scratch_pool);
   svn_branch_state_t *new_branch;
+  const char *from_path
+    = svn_branch_get_rrpath_by_eid(el_rev->branch, el_rev->eid, scratch_pool);
 
   SVN_ERR_ASSERT(! is_branch_root_element(el_rev->branch, el_rev->eid));
 
@@ -2157,7 +2177,9 @@ do_branch_and_delete(svn_branch_txn_t *e
                     to_outer_branch, to_outer_parent_eid, to_name,
                     scratch_pool, scratch_pool));
 
-  SVN_ERR(do_delete(el_rev->branch, el_rev->eid, scratch_pool));
+  SVN_ERR(svn_branch_state_delete_one(el_rev->branch, el_rev->eid,
+                                      scratch_pool));
+  svnmover_notify_v("D    %s", from_path);
 
   return SVN_NO_ERROR;
 }
@@ -2181,6 +2203,9 @@ do_branch_into_and_delete(svn_branch_el_
                           const char *to_name,
                           apr_pool_t *scratch_pool)
 {
+  const char *from_path
+    = svn_branch_get_rrpath_by_eid(el_rev->branch, el_rev->eid, scratch_pool);
+
   SVN_ERR_ASSERT(! is_branch_root_element(el_rev->branch, el_rev->eid));
 
   /* This is supposed to be used for moving to a *different* branch.
@@ -2194,7 +2219,9 @@ do_branch_into_and_delete(svn_branch_el_
                          to_branch, to_parent_eid, to_name,
                          scratch_pool));
 
-  SVN_ERR(do_delete(el_rev->branch, el_rev->eid, scratch_pool));
+  SVN_ERR(svn_branch_state_delete_one(el_rev->branch, el_rev->eid,
+                                      scratch_pool));
+  svnmover_notify_v("D    %s", from_path);
 
   return SVN_NO_ERROR;
 }
@@ -2290,6 +2317,9 @@ do_move(svn_branch_el_rev_id_t *el_rev,
         apr_pool_t *scratch_pool)
 {
   const char *from_path = el_rev_id_to_path(el_rev, scratch_pool);
+  const char *to_path
+    = branch_peid_name_to_path(to_parent_el_rev->branch,
+                               to_parent_el_rev->eid, to_name, scratch_pool);
   /* New payload shall be the same as before */
   svn_element_content_t *existing_element
     = svn_branch_get_element(el_rev->branch, el_rev->eid);
@@ -2298,10 +2328,7 @@ do_move(svn_branch_el_rev_id_t *el_rev,
                             to_parent_el_rev->eid, to_name,
                             existing_element->payload, scratch_pool));
   svnmover_notify_v("V    %s (from %s)",
-                    branch_peid_name_to_path(to_parent_el_rev->branch,
-                                             to_parent_el_rev->eid, to_name,
-                                             scratch_pool),
-                    from_path);
+                    to_path, from_path);
   return SVN_NO_ERROR;
 }