subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1710011 - in /subversion/branches/move-tracking-2/subversion: include/private/svn_branch.h libsvn_delta/branch.c libsvn_delta/branch_nested.c libsvn_delta/branch_private.h libsvn_delta/compat3e.c svnmover/svnmover.c
Date Thu, 22 Oct 2015 13:08:48 GMT
Author: julianfoad
Date: Thu Oct 22 13:08:47 2015
New Revision: 1710011

URL: http://svn.apache.org/viewvc?rev=1710011&view=rev
Log:
On the 'move-tracking-2' branch: Hide some data members in the branch txn
class.

This continues the refactoring to use branch txn/state objects instead of
a single 'editor'.

* subversion/include/private/svn_branch.h
  (svn_branch_txn_t): Move 'first_eid', 'next_eid' from here.
  (svn_branch_txn_get_num_new_eids): New.

* subversion/libsvn_delta/branch.c
  (svn_branch_txn_priv_t): Move 'first_eid', 'next_eid' to here.
  (branch_txn_get_num_new_eids,
   svn_branch_txn_get_num_new_eids): New.
  (branch_txn_create): Add it to the vtable.
  (EID_IS_ALLOCATED,
   branch_txn_new_eid,
   svn_branch_txn_finalize_eids,
   svn_branch_txn_parse,
   svn_branch_txn_serialize): Track the move.

* subversion/libsvn_delta/branch_nested.c
  (nested_branch_txn_get_num_new_eids): New.
  (svn_nested_branch_txn_create): Add it to the vtable.

* subversion/libsvn_delta/branch_private.h
  (branch_txn_v_get_num_new_eids_t): New.
  (svn_branch_txn_vtable_t): Add it to the vtable.

* subversion/libsvn_delta/compat3e.c
  (editor3_alter): Remove an obsolete usage.

* subversion/svnmover/svnmover.c
  (subtree_replay): Remove direct access to the 'first_eid' field.
  (allocate_eids): New.
  (wc_commit): Allocate here instead, using the new method instead of direct
    access.

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/libsvn_delta/branch_nested.c
    subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h
    subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.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=1710011&r1=1710010&r2=1710011&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 Oct 22
13:08:47 2015
@@ -154,11 +154,6 @@ typedef struct svn_branch_txn_t
      on which this transaction is based. */
   svn_revnum_t base_rev;
 
-  /* The range of element ids assigned. */
-  /* EIDs local to the txn are negative, assigned by decrementing FIRST_EID
-   * (skipping -1). */
-  int first_eid, next_eid;
-
 } svn_branch_txn_t;
 
 /* Create a new branch txn object.
@@ -192,6 +187,11 @@ svn_branch_txn_get_branch_by_id(const sv
                                 const char *branch_id,
                                 apr_pool_t *scratch_pool);
 
+svn_error_t *
+svn_branch_txn_get_num_new_eids(const svn_branch_txn_t *txn,
+                                int *num_new_eids_p,
+                                apr_pool_t *scratch_pool);
+
 /* Assign a new txn-scope element id in TXN.
  */
 svn_error_t *

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=1710011&r1=1710010&r2=1710011&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c Thu Oct 22 13:08:47
2015
@@ -41,7 +41,8 @@
 
 /* Is EID allocated (no matter whether an element with this id exists)? */
 #define EID_IS_ALLOCATED(branch, eid) \
-  ((eid) >= (branch)->txn->first_eid && (eid) < (branch)->txn->next_eid)
+  ((eid) >= (branch)->txn->priv->first_eid \
+   && (eid) < (branch)->txn->priv->next_eid)
 
 #define IS_BRANCH_ROOT_EID(branch, eid) \
   ((eid) == (branch)->priv->element_tree->root_eid)
@@ -57,6 +58,11 @@ struct svn_branch_txn_priv_t
   /* All branches. */
   apr_array_header_t *branches;
 
+  /* The range of element ids assigned. */
+  /* EIDs local to the txn are negative, assigned by decrementing FIRST_EID
+   * (skipping -1). */
+  int first_eid, next_eid;
+
 };
 
 struct svn_branch_state_priv_t
@@ -177,13 +183,24 @@ branch_txn_delete_branch(svn_branch_txn_
 
 /* An #svn_branch_txn_t method. */
 static svn_error_t *
+branch_txn_get_num_new_eids(const svn_branch_txn_t *txn,
+                            int *num_new_eids_p,
+                            apr_pool_t *scratch_pool)
+{
+  if (num_new_eids_p)
+    *num_new_eids_p = -1 - txn->priv->first_eid;
+  return SVN_NO_ERROR;
+}
+
+/* An #svn_branch_txn_t method. */
+static svn_error_t *
 branch_txn_new_eid(svn_branch_txn_t *txn,
                    svn_branch_eid_t *eid_p,
                    apr_pool_t *scratch_pool)
 {
-  int eid = (txn->first_eid < 0) ? txn->first_eid - 1 : -2;
+  int eid = (txn->priv->first_eid < 0) ? txn->priv->first_eid - 1 : -2;
 
-  txn->first_eid = eid;
+  txn->priv->first_eid = eid;
   if (eid_p)
     *eid_p = eid;
   return SVN_NO_ERROR;
@@ -369,6 +386,17 @@ svn_branch_txn_delete_branch(svn_branch_
 }
 
 svn_error_t *
+svn_branch_txn_get_num_new_eids(const svn_branch_txn_t *txn,
+                                int *num_new_eids_p,
+                                apr_pool_t *scratch_pool)
+{
+  SVN_ERR(txn->vtable->get_num_new_eids(txn,
+                                        num_new_eids_p,
+                                        scratch_pool));
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
 svn_branch_txn_new_eid(svn_branch_txn_t *txn,
                         int *new_eid_p,
                         apr_pool_t *scratch_pool)
@@ -478,6 +506,7 @@ branch_txn_create(svn_branch_repos_t *re
     branch_txn_add_branch,
     branch_txn_add_new_branch,
     branch_txn_delete_branch,
+    branch_txn_get_num_new_eids,
     branch_txn_new_eid,
     branch_txn_open_branch,
     branch_txn_branch,
@@ -567,18 +596,18 @@ svn_error_t *
 svn_branch_txn_finalize_eids(svn_branch_txn_t *txn,
                              apr_pool_t *scratch_pool)
 {
-  int n_txn_eids = (-1) - txn->first_eid;
+  int n_txn_eids = (-1) - txn->priv->first_eid;
   int mapping_offset;
   apr_array_header_t *branches = branch_txn_get_branches(txn, scratch_pool);
   int i;
 
-  if (txn->first_eid == 0)
+  if (txn->priv->first_eid == 0)
     return SVN_NO_ERROR;
 
   /* mapping from txn-local (negative) EID to committed (positive) EID is:
        txn_local_eid == -2  =>  committed_eid := (txn.next_eid + 0)
        txn_local_eid == -3  =>  committed_eid := (txn.next_eid + 1) ... */
-  mapping_offset = txn->next_eid - 2;
+  mapping_offset = txn->priv->next_eid - 2;
 
   for (i = 0; i < branches->nelts; i++)
     {
@@ -587,8 +616,8 @@ svn_branch_txn_finalize_eids(svn_branch_
       SVN_ERR(branch_finalize_eids(b, mapping_offset, scratch_pool));
     }
 
-  txn->next_eid += n_txn_eids;
-  txn->first_eid = 0;
+  txn->priv->next_eid += n_txn_eids;
+  txn->priv->first_eid = 0;
   return SVN_NO_ERROR;
 }
 
@@ -1420,8 +1449,8 @@ svn_branch_txn_parse(svn_branch_txn_t **
   SVN_ERR_ASSERT(n == 4);
 
   txn = branch_txn_create(repos, rev, rev - 1, result_pool);
-  txn->first_eid = first_eid;
-  txn->next_eid = next_eid;
+  txn->priv->first_eid = first_eid;
+  txn->priv->next_eid = next_eid;
 
   /* parse the branches */
   for (j = 0; j < num_branches; j++)
@@ -1511,7 +1540,7 @@ svn_branch_txn_serialize(svn_stream_t *s
                             "r%ld: eids %d %d "
                             "branches %d\n",
                             txn->rev,
-                            txn->first_eid, txn->next_eid,
+                            txn->priv->first_eid, txn->priv->next_eid,
                             branches->nelts));
 
   for (SVN_ARRAY_ITER(bi, branches, scratch_pool))

Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_nested.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_nested.c?rev=1710011&r1=1710010&r2=1710011&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_nested.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_nested.c Thu Oct 22
13:08:47 2015
@@ -432,6 +432,20 @@ nested_branch_txn_delete_branch(svn_bran
 /* Implements nested branching.
  * An #svn_branch_txn_t method. */
 static svn_error_t *
+nested_branch_txn_get_num_new_eids(const svn_branch_txn_t *txn,
+                                   int *num_new_eids_p,
+                                   apr_pool_t *scratch_pool)
+{
+  /* Just forwarding: nothing more is needed. */
+  SVN_ERR(svn_branch_txn_get_num_new_eids(txn->priv->wrapped_txn,
+                                          num_new_eids_p,
+                                          scratch_pool));
+  return SVN_NO_ERROR;
+}
+
+/* Implements nested branching.
+ * An #svn_branch_txn_t method. */
+static svn_error_t *
 nested_branch_txn_new_eid(svn_branch_txn_t *txn,
                           svn_branch_eid_t *eid_p,
                           apr_pool_t *scratch_pool)
@@ -563,6 +577,7 @@ svn_nested_branch_txn_create(svn_branch_
     nested_branch_txn_add_branch,
     nested_branch_txn_add_new_branch,
     nested_branch_txn_delete_branch,
+    nested_branch_txn_get_num_new_eids,
     nested_branch_txn_new_eid,
     nested_branch_txn_open_branch,
     nested_branch_txn_branch,

Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h?rev=1710011&r1=1710010&r2=1710011&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h Thu Oct 22
13:08:47 2015
@@ -74,6 +74,11 @@ typedef svn_error_t *(*branch_txn_v_dele
   const char *bid,
   apr_pool_t *scratch_pool);
 
+typedef svn_error_t *(*branch_txn_v_get_num_new_eids_t)(
+  const svn_branch_txn_t *txn,
+  int *num_new_eids_p,
+  apr_pool_t *scratch_pool);
+
 typedef svn_error_t *(*branch_txn_v_new_eid_t)(
   svn_branch_txn_t *txn,
   svn_branch_eid_t *eid_p,
@@ -119,6 +124,7 @@ struct svn_branch_txn_vtable_t
   branch_txn_v_add_branch_t add_branch;
   branch_txn_v_add_new_branch_t add_new_branch;
   branch_txn_v_delete_branch_t delete_branch;
+  branch_txn_v_get_num_new_eids_t get_num_new_eids;
   branch_txn_v_new_eid_t new_eid;
   branch_txn_v_open_branch_t open_branch;
   branch_txn_v_branch_t branch;

Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c?rev=1710011&r1=1710010&r2=1710011&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c Thu Oct 22 13:08:47
2015
@@ -1223,13 +1223,6 @@ editor3_alter(void *baton,
   svn_branch_state_t *branch
     = svn_branch_txn_get_branch_by_id(eb->txn, branch_id, scratch_pool);
 
-  /* ### Ensure the requested EIDs are allocated... This is not the
-         right way to do it. Instead the Editor should map 'to be
-         created' EIDs to new EIDs? See BRANCH-README. */
-  while (eid < eb->txn->first_eid
-         || (new_parent_eid < eb->txn->first_eid))
-    SVN_ERR(svn_branch_txn_new_eid(eb->txn, NULL, scratch_pool));
-
   if (! new_payload->is_subbranch_root)
     {
       SVN_DBG(("alter(e%d): parent e%d, name '%s', kind %s",

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=1710011&r1=1710010&r2=1710011&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Thu Oct 22 13:08:47
2015
@@ -405,12 +405,6 @@ subtree_replay(svn_branch_state_t *edit_
                      || svn_element_payload_invariants(e1->payload));
       if (e0 || e1)
         {
-          /* Ensure the requested EIDs are allocated. */
-          /* ### Doesn't seem like the right way... See BRANCH-README. */
-          while (eid < edit_branch->txn->first_eid
-                 || (e1 && (e1->parent_eid < edit_branch->txn->first_eid)))
-            SVN_ERR(svn_branch_txn_new_eid(edit_branch->txn, NULL, scratch_pool));
-
           if (e0 && e1)
             {
               SVN_DBG(("replay: alter e%d", eid));
@@ -587,6 +581,27 @@ do_topbranch(svn_branch_state_t **new_br
              apr_pool_t *result_pool,
              apr_pool_t *scratch_pool);
 
+/* Allocate the same number of new EIDs in NEW_TXN as are already
+ * allocated in OLD_TXN.
+ */
+static svn_error_t *
+allocate_eids(svn_branch_txn_t *new_txn,
+              const svn_branch_txn_t *old_txn,
+              apr_pool_t *scratch_pool)
+{
+  int num_new_eids;
+  int i;
+
+  SVN_ERR(svn_branch_txn_get_num_new_eids(old_txn, &num_new_eids,
+                                          scratch_pool));
+  for (i = 0; i < num_new_eids; i++)
+    {
+      SVN_ERR(svn_branch_txn_new_eid(new_txn, NULL, scratch_pool));
+    }
+
+  return SVN_NO_ERROR;
+}
+
 /* Commit the changes from WC into the repository.
  *
  * Open a new commit txn to the repo. Replay the changes from WC into it.
@@ -665,6 +680,8 @@ wc_commit(svn_revnum_t *new_rev_p,
                            from, scratch_pool, scratch_pool));
       edit_root_branch_id = edit_root_branch->bid;
     }
+  /* Allocate all the new eids we'll need in this new txn */
+  SVN_ERR(allocate_eids(commit_txn, wc->working->branch->txn, scratch_pool));
   SVN_ERR(replay(commit_txn, edit_root_branch,
                  wc->base->branch,
                  wc->working->branch,



Mime
View raw message