You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2009/12/18 03:09:00 UTC

svn commit: r892108 - in /subversion/branches/issue-3550-dev/subversion: libsvn_fs_base/ libsvn_fs_base/bdb/ libsvn_fs_base/util/ tests/libsvn_fs_base/

Author: cmpilato
Date: Fri Dec 18 02:08:45 2009
New Revision: 892108

URL: http://svn.apache.org/viewvc?rev=892108&view=rev
Log:
On the 'issue-3550-dev' branch, teach the path change record-fetching
code to skip the folding if it's already been done.  Also, rename a
structure member variable for clarity.

* subversion/libsvn_fs_base/revs-txns.h,
* subversion/libsvn_fs_base/revs-txns.c
  (svn_fs_base__txn_get_changes_info): Was
    svn_fs_base__txn_get_changes_id(), and now also populates
    'changes_folded' and 'num_changes' return variables.

* subversion/libsvn_fs_base/bdb/changes-table.c
  (svn_fs_bdb__changes_fetch): Add 'prefolded' parameter.  If it's
    set, shortcut the whole folding process.

* subversion/libsvn_fs_base/bdb/changes-table.h
  (svn_fs_bdb__changes_fetch): Add 'prefolded' parameter.

* subversion/libsvn_fs_base/fs.h
  (struct transaction_t): Rename 'changes_prefolded' member to
    'changes_folded'.

* subversion/libsvn_fs_base/bdb/txn-table.c
  (svn_fs_bdb__create_txn): Track renamed structure member.

* subversion/libsvn_fs_base/tree.c
  (add_change, verify_locks, txn_body_paths_changed): Update calls to
    svn_fs_base__txn_get_changes_info() and svn_fs_bdb__changes_fetch().

* subversion/libsvn_fs_base/util/fs_skels.c
  (svn_fs_base__parse_transaction_skel,
   svn_fs_base__unparse_transaction_skel): Track renamed structure member.

* subversion/tests/libsvn_fs_base/changes-test.c
  (txn_body_changes_fetch): Update call to svn_fs_bdb__changes_fetch().
  (txn_body_changes_fetch_by_txn_id): Update calls to
    svn_fs_base__txn_get_changes_info() and svn_fs_bdb__changes_fetch().

Modified:
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.c
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.h
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.h
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c
    subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/util/fs_skels.c
    subversion/branches/issue-3550-dev/subversion/tests/libsvn_fs_base/changes-test.c

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.c?rev=892108&r1=892107&r2=892108&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.c (original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.c Fri Dec 18 02:08:45 2009
@@ -330,6 +330,7 @@
 svn_fs_bdb__changes_fetch(apr_hash_t **changes_p,
                           svn_fs_t *fs,
                           const char *key,
+                          svn_boolean_t prefolded,
                           trail_t *trail,
                           apr_pool_t *pool)
 {
@@ -378,38 +379,54 @@
         goto cleanup;
 
       /* ... and merge it with our return hash.  */
-      err = fold_change(changes, change);
-      if (err)
-        goto cleanup;
-
-      /* Now, if our change was a deletion or replacement, we have to
-         blow away any changes thus far on paths that are (or, were)
-         children of this path.
-         ### i won't bother with another iteration pool here -- at
-             most we talking about a few extra dups of paths into what
-             is already a temporary subpool.
-      */
-      if ((change->kind == svn_fs_path_change_delete)
-          || (change->kind == svn_fs_path_change_replace))
+      if (prefolded)
         {
-          apr_hash_index_t *hi;
-
-          for (hi = apr_hash_first(subpool, changes);
-               hi;
-               hi = apr_hash_next(hi))
+          svn_fs_path_change2_t *new_change;
+          new_change = svn_fs__path_change_create_internal(
+                          svn_fs_base__id_copy(change->noderev_id, pool),
+                          change->kind, pool);
+          new_change->text_mod = change->text_mod;
+          new_change->prop_mod = change->prop_mod;
+          new_change->node_kind = svn_node_unknown;
+          new_change->copyfrom_known = FALSE;
+          apr_hash_set(changes, apr_pstrdup(pool, change->path),
+                       APR_HASH_KEY_STRING, new_change);
+        }
+      else
+        {
+          err = fold_change(changes, change);
+          if (err)
+            goto cleanup;
+
+          /* Now, if our change was a deletion or replacement, we have to
+             blow away any changes thus far on paths that are (or, were)
+             children of this path.
+             ### i won't bother with another iteration pool here -- at
+                 most we talking about a few extra dups of paths into what
+                 is already a temporary subpool.
+          */
+          if ((change->kind == svn_fs_path_change_delete)
+              || (change->kind == svn_fs_path_change_replace))
             {
-              /* KEY is the path. */
-              const void *hashkey;
-              apr_ssize_t klen;
-              apr_hash_this(hi, &hashkey, &klen, NULL);
-
-              /* If we come across our own path, ignore it. */
-              if (strcmp(change->path, hashkey) == 0)
-                continue;
-
-              /* If we come across a child of our path, remove it. */
-              if (svn_uri_is_child(change->path, hashkey, subpool))
-                apr_hash_set(changes, hashkey, klen, NULL);
+              apr_hash_index_t *hi;
+
+              for (hi = apr_hash_first(subpool, changes);
+                   hi;
+                   hi = apr_hash_next(hi))
+                {
+                  /* KEY is the path. */
+                  const void *hashkey;
+                  apr_ssize_t klen;
+                  apr_hash_this(hi, &hashkey, &klen, NULL);
+
+                  /* If we come across our own path, ignore it. */
+                  if (strcmp(change->path, hashkey) == 0)
+                    continue;
+
+                  /* If we come across a child of our path, remove it. */
+                  if (svn_uri_is_child(change->path, hashkey, subpool))
+                    apr_hash_set(changes, hashkey, klen, NULL);
+                }
             }
         }
 

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.h
URL: http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.h?rev=892108&r1=892107&r2=892108&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.h (original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/changes-table.h Fri Dec 18 02:08:45 2009
@@ -88,10 +88,14 @@
 /* Return a hash *CHANGES_P, keyed on const char * paths, and
    containing svn_fs_path_change2_t * values representing summarized
    changed records associated with KEY in FS, as part of TRAIL.
-   Allocate the array and its items in POOL.  */
+   Allocate the array and its items in POOL.
+
+   If PREFOLDED is TRUE, assume the change records have already been
+   collapsed into a single all-inclusive change record per path.  */
 svn_error_t *svn_fs_bdb__changes_fetch(apr_hash_t **changes_p,
                                        svn_fs_t *fs,
                                        const char *key,
+                                       svn_boolean_t prefolded,
                                        trail_t *trail,
                                        apr_pool_t *pool);
 

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c?rev=892108&r1=892107&r2=892108&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c (original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/bdb/txn-table.c Fri Dec 18 02:08:45 2009
@@ -175,7 +175,7 @@
   txn.copies = NULL;
   txn.revision = SVN_INVALID_REVNUM;
   txn.changes_id = changes_id;
-  txn.changes_prefolded = FALSE;
+  txn.changes_folded = FALSE;
   txn.num_changes = -1;
   SVN_ERR(svn_fs_bdb__put_txn(fs, &txn, txn_name, trail, pool));
 

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h?rev=892108&r1=892107&r2=892108&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h (original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/fs.h Fri Dec 18 02:08:45 2009
@@ -172,7 +172,7 @@
 
   /* TRUE iff the changes records for this transaction are known to be
      prefolded. */
-  svn_boolean_t changes_prefolded;
+  svn_boolean_t changes_folded;
 
   /* Number of changed paths associated with this transaction, or -1
      to mean "unknown". */

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c?rev=892108&r1=892107&r2=892108&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c (original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.c Fri Dec 18 02:08:45 2009
@@ -345,15 +345,19 @@
 
 
 svn_error_t *
-svn_fs_base__txn_get_changes_id(const char **changes_id,
-                                svn_fs_t *fs,
-                                const char *txn_name,
-                                trail_t *trail,
-                                apr_pool_t *pool)
+svn_fs_base__txn_get_changes_info(const char **changes_id,
+                                  svn_boolean_t *changes_folded,
+                                  int *num_changes,
+                                  svn_fs_t *fs,
+                                  const char *txn_name,
+                                  trail_t *trail,
+                                  apr_pool_t *pool)
 {
   transaction_t *txn;
   SVN_ERR(get_txn(&txn, fs, txn_name, FALSE, trail, pool));
   *changes_id = txn->changes_id;
+  *changes_folded = txn->changes_folded;
+  *num_changes = txn->num_changes;
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.h
URL: http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.h?rev=892108&r1=892107&r2=892108&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.h (original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/revs-txns.h Fri Dec 18 02:08:45 2009
@@ -93,12 +93,17 @@
 
 /* Set *CHANGES_ID to the key into the `changes' table (allocated from
    POOL) by which changed path records associated with FS transaction
-   TXN_NAME are found.  Do all of this as part of TRAIL.  */
-svn_error_t *svn_fs_base__txn_get_changes_id(const char **changes_id,
-                                             svn_fs_t *fs,
-                                             const char *txn_name,
-                                             trail_t *trail,
-                                             apr_pool_t *pool);
+   TXN_NAME are found.  Set *CHANGES_FOLDED to TRUE if those changed
+   path records have already been folded; set it to FALSE otherwise.
+   Set *NUM_CHANGES to the number of changed path records, if known,
+   or to -1 otherwise.  Do all of this as part of TRAIL.  */
+svn_error_t *svn_fs_base__txn_get_changes_info(const char **changes_id,
+                                               svn_boolean_t *changes_folded,
+                                               int *num_changes,
+                                               svn_fs_t *fs,
+                                               const char *txn_name,
+                                               trail_t *trail,
+                                               apr_pool_t *pool);
 
 
 /* Retrieve information about the Subversion transaction TXN_NAME from

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c?rev=892108&r1=892107&r2=892108&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c (original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/tree.c Fri Dec 18 02:08:45 2009
@@ -962,13 +962,17 @@
 {
   change_t change;
   const char *changes_id;
+  svn_boolean_t changes_folded;
+  int num_changes;
+
   change.path = svn_fs__canonicalize_abspath(path, pool);
   change.noderev_id = noderev_id;
   change.kind = change_kind;
   change.text_mod = text_mod;
   change.prop_mod = prop_mod;
-  SVN_ERR(svn_fs_base__txn_get_changes_id(&changes_id, fs, txn_id,
-                                          trail, pool));
+  SVN_ERR(svn_fs_base__txn_get_changes_info(&changes_id, &changes_folded,
+                                            &num_changes, fs, txn_id,
+                                            trail, pool));
   return svn_fs_bdb__changes_add(fs, changes_id, &change, trail, pool);
 }
 
@@ -2489,6 +2493,8 @@
 {
   apr_pool_t *subpool = svn_pool_create(pool);
   const char *changes_id;
+  svn_boolean_t changes_folded;
+  int num_changes;
   apr_hash_t *changes;
   apr_hash_index_t *hi;
   apr_array_header_t *changed_paths;
@@ -2496,10 +2502,11 @@
   int i;
 
   /* Fetch the changes for this transaction. */
-  SVN_ERR(svn_fs_base__txn_get_changes_id(&changes_id, trail->fs, txn_name,
-                                          trail, trail->pool));
+  SVN_ERR(svn_fs_base__txn_get_changes_info(&changes_id, &changes_folded,
+                                            &num_changes, trail->fs, txn_name,
+                                            trail, trail->pool));
   SVN_ERR(svn_fs_bdb__changes_fetch(&changes, trail->fs, txn_name,
-                                    trail, pool));
+                                    changes_folded, trail, pool));
 
   /* Make an array of the changed paths, and sort them depth-first-ily.  */
   changed_paths = apr_array_make(pool, apr_hash_count(changes) + 1,
@@ -4120,6 +4127,8 @@
 {
   struct paths_changed_args *args = baton;
   const char *txn_id, *changes_id;
+  svn_boolean_t changes_folded;
+  int num_changes;
   svn_fs_t *fs = args->root->fs;
 
   /* Get the transaction ID from ROOT. */
@@ -4129,10 +4138,11 @@
   else
     txn_id = args->root->txn;
 
-  SVN_ERR(svn_fs_base__txn_get_changes_id(&changes_id, fs, txn_id,
-                                          trail, trail->pool));
+  SVN_ERR(svn_fs_base__txn_get_changes_info(&changes_id, &changes_folded,
+                                            &num_changes, fs, txn_id,
+                                            trail, trail->pool));
   return svn_fs_bdb__changes_fetch(&(args->changes), fs, changes_id,
-                                   trail, trail->pool);
+                                   changes_folded, trail, trail->pool);
 }
 
 

Modified: subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/util/fs_skels.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/util/fs_skels.c?rev=892108&r1=892107&r2=892108&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/util/fs_skels.c (original)
+++ subversion/branches/issue-3550-dev/subversion/libsvn_fs_base/util/fs_skels.c Fri Dec 18 02:08:45 2009
@@ -509,9 +509,9 @@
                              changes_info->children->data,
                              changes_info->children->len);
       if (strcmp(state, "folded") == 0)
-        transaction->changes_prefolded = TRUE;
+        transaction->changes_folded = TRUE;
       else if (strcmp(state, "unfolded") == 0)
-        transaction->changes_prefolded = FALSE;
+        transaction->changes_folded = FALSE;
       else
         return skel_err("transaction");
 
@@ -1044,7 +1044,7 @@
                           changes_info_skel);
 
       /* CHANGES_STATE */
-      svn_skel__prepend(svn_skel__str_atom(transaction->changes_prefolded
+      svn_skel__prepend(svn_skel__str_atom(transaction->changes_folded
                                              ? "folded" : "unfolded",
                                            pool),
                         changes_info_skel);

Modified: subversion/branches/issue-3550-dev/subversion/tests/libsvn_fs_base/changes-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-3550-dev/subversion/tests/libsvn_fs_base/changes-test.c?rev=892108&r1=892107&r2=892108&view=diff
==============================================================================
--- subversion/branches/issue-3550-dev/subversion/tests/libsvn_fs_base/changes-test.c (original)
+++ subversion/branches/issue-3550-dev/subversion/tests/libsvn_fs_base/changes-test.c Fri Dec 18 02:08:45 2009
@@ -151,7 +151,7 @@
 {
   struct changes_args *b = baton;
   return svn_fs_bdb__changes_fetch(&(b->changes), b->fs, b->key,
-                                   trail, trail->pool);
+                                   FALSE, trail, trail->pool);
 }
 
 
@@ -160,10 +160,14 @@
 {
   struct changes_args *b = baton;
   const char *changes_id;
-  SVN_ERR(svn_fs_base__txn_get_changes_id(&changes_id, trail->fs, b->key,
-                                          trail, trail->pool));
+  svn_boolean_t changes_folded;
+  int num_changes;
+
+  SVN_ERR(svn_fs_base__txn_get_changes_info(&changes_id, &changes_folded,
+                                            &num_changes, trail->fs, b->key,
+                                            trail, trail->pool));
   return svn_fs_bdb__changes_fetch(&(b->changes), b->fs, changes_id,
-                                   trail, trail->pool);
+                                   changes_folded, trail, trail->pool);
 }
 
 static svn_error_t *