Author: julianfoad
Date: Thu Jun  4 16:25:07 2015
New Revision: 1683586

URL: http://svn.apache.org/r1683586
Log:
On the 'move-tracking-2' branch: Provide more simple APIs for clarity,
instead of accessing structure fields directly.

* subversion/include/private/svn_branch.h,
  subversion/libsvn_delta/branch.c
  (svn_branch_repos_t): Correct a comment.
  (svn_branch_repos_get_revision,
   svn_branch_repos_get_root_branch,
   svn_branch_revision_root_get_base): New.
  (svn_branch_repos_find_el_rev_by_id,
   svn_branch_repos_find_el_rev_by_path_rev): Use them.

* subversion/svnmover/svnmover.c
  (wc_commit,
   do_update,
   do_revert): Use them.

Modified:
    subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h
    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/include/private/svn_branch.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h?rev=1683586&r1=1683585&r2=1683586&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h 
(original)
+++ subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h 
Thu Jun  4 16:25:07 2015
@@ -71,7 +71,7 @@ typedef struct svn_branch_state_t svn_br
  */
 typedef struct svn_branch_repos_t
 {
-  /* Array of (svn_branch_revision_info_t *), indexed by revision number. */
+  /* Array of (svn_branch_revision_root_t *), indexed by revision number. */
   apr_array_header_t *rev_roots;
 
   /* The pool in which this object lives. */
@@ -82,6 +82,19 @@ typedef struct svn_branch_repos_t
 svn_branch_repos_t *
 svn_branch_repos_create(apr_pool_t *result_pool);
 
+/* Return a pointer to revision REVNUM of the repository REPOS.
+ */
+struct svn_branch_revision_root_t *
+svn_branch_repos_get_revision(const svn_branch_repos_t *repos,
+                              svn_revnum_t revnum);
+
+/* Return a pointer to the root branch of revision REVNUM of the
+ * repository REPOS.
+ */
+struct svn_branch_state_t *
+svn_branch_repos_get_root_branch(const svn_branch_repos_t *repos,
+                                 svn_revnum_t revnum);
+
 /* Set *EL_REV_P to the el-rev-id of the element at branch id BRANCH_ID,
  * element id EID, in revision REVNUM in REPOS.
  *
@@ -155,6 +168,12 @@ svn_branch_revision_root_create(svn_bran
                                 struct svn_branch_state_t *root_branch,
                                 apr_pool_t *result_pool);
 
+/* Return the revision root that represents the base revision (or,
+ * potentially, txn) of the revision or txn REV_ROOT.
+ */
+svn_branch_revision_root_t *
+svn_branch_revision_root_get_base(svn_branch_revision_root_t *rev_root);
+
 /* Return all the branches in REV_ROOT.
  *
  * Return an empty array if there are none.

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=1683586&r1=1683585&r2=1683586&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c 
(original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c Thu 
Jun  4 16:25:07 2015
@@ -64,6 +64,24 @@ svn_branch_repos_create(apr_pool_t *resu
   return repos;
 }
 
+struct svn_branch_revision_root_t *
+svn_branch_repos_get_revision(const svn_branch_repos_t *repos,
+                              svn_revnum_t revnum)
+{
+  assert(revnum < repos->rev_roots->nelts);
+  return svn_array_get(repos->rev_roots, (int)revnum);
+}
+
+struct svn_branch_state_t *
+svn_branch_repos_get_root_branch(const svn_branch_repos_t *repos,
+                                 svn_revnum_t revnum)
+{
+  svn_branch_revision_root_t *rev_root
+    = svn_branch_repos_get_revision(repos, revnum);
+
+  return rev_root->root_branch;
+}
+
 svn_branch_revision_root_t *
 svn_branch_revision_root_create(svn_branch_repos_t *repos,
                                 svn_revnum_t rev,
@@ -82,6 +100,13 @@ svn_branch_revision_root_create(svn_bran
   return rev_root;
 }
 
+svn_branch_revision_root_t *
+svn_branch_revision_root_get_base(svn_branch_revision_root_t *rev_root)
+{
+  return svn_branch_repos_get_revision(rev_root->repos,
+                                       (int)rev_root->base_rev);
+}
+
 int
 svn_branch_allocate_new_eid(svn_branch_revision_root_t *rev_root)
 {
@@ -1257,7 +1282,7 @@ svn_branch_repos_find_el_rev_by_id(svn_b
     return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
                              _("No such revision %ld"), revnum);
 
-  rev_root = svn_array_get(repos->rev_roots, (int)(revnum));
+  rev_root = svn_branch_repos_get_revision(repos, revnum);
   el_rev->rev = revnum;
   el_rev->branch
     = svn_branch_revision_root_get_branch_by_id(rev_root, branch_id,
@@ -1283,16 +1308,16 @@ svn_branch_repos_find_el_rev_by_path_rev
                                 apr_pool_t *scratch_pool)
 {
   svn_branch_el_rev_id_t *el_rev = apr_palloc(result_pool, sizeof(*el_rev));
-  const svn_branch_revision_root_t *rev_root;
+  const svn_branch_state_t *root_branch;
 
   if (revnum < 0 || revnum >= repos->rev_roots->nelts)
     return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
                              _("No such revision %ld"), revnum);
 
-  rev_root = svn_array_get(repos->rev_roots, (int)(revnum));
+  root_branch = svn_branch_repos_get_root_branch(repos, revnum);
   el_rev->rev = revnum;
   svn_branch_find_nested_branch_element_by_rrpath(&el_rev->branch, 
&el_rev->eid,
-                                                  rev_root->root_branch, 
rrpath,
+                                                  root_branch, rrpath,
                                                   scratch_pool);
 
   /* Any path must at least be within the repository root branch */

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=1683586&r1=1683585&r2=1683586&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c 
(original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Thu Jun  
4 16:25:07 2015
@@ -433,7 +433,7 @@ wc_commit(svn_revnum_t *new_rev_p,
 {
   const char *branch_info_dir = NULL;
   svn_branch_revision_root_t *left_txn
-    = svn_array_get(wc->edit_txn->repos->rev_roots, (int)wc->base_revision);
+    = svn_branch_revision_root_get_base(wc->edit_txn);
   svn_branch_revision_root_t *right_txn = wc->edit_txn;
   svn_branch_revision_root_t *commit_txn;
   svn_editor3_t *commit_editor;
@@ -1494,7 +1494,7 @@ do_update(svnmover_wc_t *wc,
 {
   /* Keep hold of the previous WC txn */
   svn_branch_revision_root_t *previous_base_state
-    = svn_array_get(wc->edit_txn->repos->rev_roots, (int)wc->base_revision);
+    = svn_branch_revision_root_get_base(wc->edit_txn);
   svn_branch_revision_root_t *previous_working_txn = wc->edit_txn;
   svn_branch_el_rev_id_t *yca, *src, *tgt;
 
@@ -2110,7 +2110,7 @@ do_revert(svnmover_wc_t *wc,
           apr_pool_t *scratch_pool)
 {
   svn_branch_revision_root_t *base_txn
-    = svn_array_get(wc->edit_txn->repos->rev_roots, (int)wc->base_revision);
+    = svn_branch_revision_root_get_base(wc->edit_txn);
 
   /* Replay the inverse of the current edit txn, into the current edit txn */
   SVN_ERR(replay(wc->editor, wc->edit_txn->root_branch,


Reply via email to